summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2017-10-19 11:33:29 -0600
committerJens Axboe <axboe@kernel.dk>2017-10-19 11:33:29 -0600
commit9974ae56e3da12c27d5ff55c54962c98397017f5 (patch)
treeeeaf658575d43ea91e504b539fd56c53a8574f3e
parent73d3393ada4f70fa3df5639c8d438f2f034c0ecb (diff)
block: add REQ_OP_FLAGS_ODIRECT
We have a couple of places where we check for REQ_SYNC | REQ_IDLE as an indicator for an O_DIRECT write. Let's formally define a REQ_OP_FLAGS_ODIRECT so that we ensure that the places setting it and checking it are always in sync. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-wbt.c2
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/direct-io.c2
-rw-r--r--fs/iomap.c5
-rw-r--r--include/linux/blk_types.h2
5 files changed, 8 insertions, 5 deletions
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 6a9a0f03a67b..1345935c7ee6 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -571,7 +571,7 @@ static inline bool wbt_should_throttle(struct rq_wb *rwb, struct bio *bio)
/*
* Don't throttle WRITE_ODIRECT
*/
- if ((bio->bi_opf & (REQ_SYNC | REQ_IDLE)) == (REQ_SYNC | REQ_IDLE))
+ if ((bio->bi_opf & REQ_OP_FLAGS_ODIRECT) == REQ_OP_FLAGS_ODIRECT)
return false;
return true;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 789f55e851ae..eb8979374fa8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -178,7 +178,7 @@ static struct inode *bdev_file_inode(struct file *file)
static unsigned int dio_bio_write_op(struct kiocb *iocb)
{
- unsigned int op = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE;
+ unsigned int op = REQ_OP_WRITE | REQ_OP_FLAGS_ODIRECT;
/* avoid the need for a I/O completion work item */
if (iocb->ki_flags & IOCB_DSYNC)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index b53e66d9abd7..53036b125a73 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1239,7 +1239,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
dio->inode = inode;
if (iov_iter_rw(iter) == WRITE) {
dio->op = REQ_OP_WRITE;
- dio->op_flags = REQ_SYNC | REQ_IDLE;
+ dio->op_flags = REQ_OP_FLAGS_ODIRECT;
if (iocb->ki_flags & IOCB_NOWAIT)
dio->op_flags |= REQ_NOWAIT;
} else {
diff --git a/fs/iomap.c b/fs/iomap.c
index d4801f8dd4fd..8ad2f6e58f14 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -837,7 +837,7 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,
get_page(page);
if (bio_add_page(bio, page, len, 0) != len)
BUG();
- bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC | REQ_IDLE);
+ bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_OP_FLAGS_ODIRECT);
atomic_inc(&dio->ref);
return submit_bio(bio);
@@ -921,7 +921,8 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
}
if (dio->flags & IOMAP_DIO_WRITE) {
- bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC | REQ_IDLE);
+ bio_set_op_attrs(bio, REQ_OP_WRITE,
+ REQ_OP_FLAGS_ODIRECT);
task_io_account_write(bio->bi_iter.bi_size);
} else {
bio_set_op_attrs(bio, REQ_OP_READ, 0);
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index a2d2aa709cef..38f922f99796 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -260,6 +260,8 @@ enum req_flag_bits {
#define req_op(req) \
((req)->cmd_flags & REQ_OP_MASK)
+#define REQ_OP_FLAGS_ODIRECT (REQ_SYNC | REQ_IDLE)
+
/* obsolete, don't use in new code */
static inline void bio_set_op_attrs(struct bio *bio, unsigned op,
unsigned op_flags)