[PATCH 5/8] loop: fallback to buffered IO in case of dio submission

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



DIO submission on underlying file may fail because of unaligned buffer or
start_sector & sector_length, fallback to buffered IO when that happens,
this way will make loop dio mode more reliable.

Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
---
 drivers/block/loop.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d1784f825b6b..fee78a640f75 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -590,6 +590,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
 	cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
 	if (!cmd->use_dio) {
 		atomic_set(&cmd->ref, 1);
+buffered_io:
 		cmd->iocb.ki_flags = 0;
 		cmd->ret = lo_call_backing_rw_iter(file, &cmd->iocb, &iter, rw);
 		lo_rw_aio_do_completion(cmd);
@@ -603,8 +604,13 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
 
 	lo_rw_aio_do_completion(cmd);
 
-	if (ret != -EIOCBQUEUED)
+	if (ret != -EIOCBQUEUED) {
+		if (ret < 0) {
+			cmd->use_dio = false;
+			goto buffered_io;
+		}
 		cmd->iocb.ki_complete(&cmd->iocb, ret, 0);
+	}
 	return 0;
 }
 
-- 
2.31.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux