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>
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 6a9a0f0..1345935 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 789f55e..eb89793 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 b53e66d..53036b1 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 d4801f8..8ad2f6e 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 a2d2aa7..38f922f 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)