Blob Blame History Raw
From: NeilBrown <neilb@suse.de>
Date: Thu, 11 May 2017 12:06:59 +0200
Subject: Cause IO to O_DIRECT|O_NONBLOCK devices to use REQ_FAILFAST_DEV
Patch-mainline: Not yet, failfast is poorly defined
References: bnc#750141

Linux can mark IO requests as FAILFAST to the device doesn't try so hard.

This functionality is currently not available via block-special-file access.

It only makes sense with O_DIRECT, and seems to fit with O_NONBLOCK,
so arrange that a block device opened with these two flags causes
REQ_FAILFAST_DEV to be used.

[hare: ported to SLES12 SP3]

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 fs/block_dev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 21f5f57..5eb9bc3d 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -241,6 +241,8 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
 		bio.bi_opf = dio_bio_write_op(iocb);
 		task_io_account_write(ret);
 	}
+	if (file->f_flags & O_NONBLOCK)
+		bio.bi_opf |= REQ_FAILFAST_DEV;
 
 	qc = submit_bio(&bio);
 	for (;;) {
@@ -376,6 +378,8 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 			bio->bi_opf = dio_bio_write_op(iocb);
 			task_io_account_write(bio->bi_iter.bi_size);
 		}
+		if (file->f_flags & O_NONBLOCK)
+			bio->bi_opf |= REQ_FAILFAST_DEV;
 
 		dio->size += bio->bi_iter.bi_size;
 		pos += bio->bi_iter.bi_size;
-- 
1.8.5.6