Skip to content

Commit 78250c0

Browse files
committed
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>
1 parent 72ecad2 commit 78250c0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

fs/block_dev.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ static struct inode *bdev_file_inode(struct file *file)
176176
return file->f_mapping->host;
177177
}
178178

179+
static unsigned int dio_bio_write_op(struct kiocb *iocb)
180+
{
181+
unsigned int op = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE;
182+
183+
/* avoid the need for a I/O completion work item */
184+
if (iocb->ki_flags & IOCB_DSYNC)
185+
op |= REQ_FUA;
186+
return op;
187+
}
188+
179189
#define DIO_INLINE_BIO_VECS 4
180190

181191
static void blkdev_bio_end_io_simple(struct bio *bio)
@@ -226,11 +236,11 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
226236
ret = bio.bi_iter.bi_size;
227237

228238
if (iov_iter_rw(iter) == READ) {
229-
bio_set_op_attrs(&bio, REQ_OP_READ, 0);
239+
bio.bi_opf = REQ_OP_READ;
230240
if (iter_is_iovec(iter))
231241
should_dirty = true;
232242
} else {
233-
bio_set_op_attrs(&bio, REQ_OP_WRITE, REQ_SYNC | REQ_IDLE);
243+
bio.bi_opf = dio_bio_write_op(iocb);
234244
task_io_account_write(ret);
235245
}
236246

0 commit comments

Comments
 (0)