summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2016-11-16 23:15:53 -0700
committerJens Axboe <axboe@fb.com>2016-11-16 23:33:12 -0700
commit3002cc26bfff9f6d62f3f6dc8ae49e087f289ad9 (patch)
tree4bb46403d04aab2e9a24ac8814a941be1cb157d7
parent7b3127b98b3c249f0c9e01a8cdcb5da04fc59d9a (diff)
block: make __blkdev_direct_IO_sync() support O_SYNC/DSYNC
Split the op setting code into a helper, use it in both places. Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--fs/block_dev.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index e2ae7a696d75..1f7584d141f8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -176,6 +176,17 @@ static struct inode *bdev_file_inode(struct file *file)
return file->f_mapping->host;
}
+static void dio_bio_set_write_op(struct bio *bio, struct kiocb *iocb)
+{
+ unsigned int op = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE;
+
+ /* avoid the need for a I/O completion work item */
+ if (iocb->ki_flags & IOCB_DSYNC)
+ op |= REQ_FUA;
+
+ bio->bi_opf = op;
+}
+
#define DIO_INLINE_BIO_VECS 4
static void blkdev_bio_end_io_simple(struct bio *bio)
@@ -230,7 +241,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
if (iter_is_iovec(iter))
should_dirty = true;
} else {
- bio_set_op_attrs(&bio, REQ_OP_WRITE, REQ_SYNC | REQ_IDLE);
+ dio_bio_set_write_op(&bio, iocb);
task_io_account_write(ret);
}
@@ -357,13 +368,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
if (dio->should_dirty)
bio_set_pages_dirty(bio);
} else {
- unsigned int op = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE;
-
- /* avoid the need for a I/O completion work item */
- if (!is_sync && (iocb->ki_flags & IOCB_DSYNC))
- op |= REQ_FUA;
-
- bio->bi_opf = op;
+ dio_bio_set_write_op(bio, iocb);
task_io_account_write(bio->bi_iter.bi_size);
}