summaryrefslogtreecommitdiff
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorMike Christie <mchristi@redhat.com>2016-06-05 14:31:42 -0500
committerJens Axboe <axboe@fb.com>2016-06-07 13:41:38 -0600
commitf21508211d2b16e65821abd171378fa6ece126fe (patch)
tree4b85b32a065cf6c28ccd2ad1a2960ec6f4b67634 /include/linux/fs.h
parent4e49ea4a3d276365bf7396c9b77b4d1d5923835a (diff)
block: add REQ_OP definitions and helpers
The following patches separate the operation (WRITE, READ, DISCARD, etc) from the rq_flag_bits flags. This patch adds definitions for request/bio operations (REQ_OPs) and adds request/bio accessors to get/set the op. In this patch the REQ_OPs match the REQ rq_flag_bits ones for compat reasons while all the code is converted to use the op accessors in the set. In the last patches the op will become a number and the accessors and helpers in this patch will be dropped or updated. Signed-off-by: Mike Christie <mchristi@redhat.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 65e4c51ecb3d..62ca2f9cad95 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2465,14 +2465,36 @@ extern bool is_bad_inode(struct inode *);
#ifdef CONFIG_BLOCK
/*
+ * tmp cpmpat. Users used to set the write bit for all non reads, but
+ * we will be dropping the bitmap use for ops. Support both until
+ * the end of the patchset.
+ */
+static inline bool op_is_write(unsigned long flags)
+{
+ if (flags & (REQ_OP_WRITE | REQ_OP_WRITE_SAME | REQ_OP_DISCARD))
+ return true;
+ else
+ return false;
+}
+
+/*
* return READ, READA, or WRITE
*/
-#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK))
+static inline int bio_rw(struct bio *bio)
+{
+ if (op_is_write(op_from_rq_bits(bio->bi_rw)))
+ return WRITE;
+
+ return bio->bi_rw & RWA_MASK;
+}
/*
* return data direction, READ or WRITE
*/
-#define bio_data_dir(bio) ((bio)->bi_rw & 1)
+static inline int bio_data_dir(struct bio *bio)
+{
+ return op_is_write(op_from_rq_bits(bio->bi_rw)) ? WRITE : READ;
+}
extern void check_disk_size_change(struct gendisk *disk,
struct block_device *bdev);