summaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev_compat.h
diff options
context:
space:
mode:
authorChunwei Chen <[email protected]>2016-07-27 17:55:32 +0000
committerNed Bass <[email protected]>2016-09-09 13:21:10 -0700
commit6ae0dbdc8a98263eae9d8f1e699a532d9c2971fa (patch)
tree07ba21e49f7f626c19e1df7da2755ef6a5782daf /include/linux/blkdev_compat.h
parenta0591c4370b621d3962f6a8e44fe8ee0c12a8fc2 (diff)
Linux 4.8 compat: REQ_OP and bio_set_op_attrs()
New REQ_OP_* definitions have been introduced to separate the WRITE, READ, and DISCARD operations from the flags. This included changing the encoding of bi_rw. It places REQ_OP_* in high order bits and other stuff in low order bits. This encoding is done through the new helper function bio_set_op_attrs. For complete details refer to: https://github.com/torvalds/linux/commit/f215082 https://github.com/torvalds/linux/commit/4e1b2d5 Signed-off-by: Tim Chase <[email protected]> Signed-off-by: Chunwei Chen <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #4892 Closes #4899
Diffstat (limited to 'include/linux/blkdev_compat.h')
-rw-r--r--include/linux/blkdev_compat.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/include/linux/blkdev_compat.h b/include/linux/blkdev_compat.h
index 748963be8..ec301ee9b 100644
--- a/include/linux/blkdev_compat.h
+++ b/include/linux/blkdev_compat.h
@@ -332,15 +332,30 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
#endif
/*
- * 2.6.32 API change
- * Use the normal I/O patch for discards.
+ * 2.6.28 - 2.6.35 API,
+ * BIO_RW_DISCARD
+ *
+ * 2.6.36 - 4.7 API,
+ * REQ_DISCARD
+ *
+ * 4.8 - 4.x API,
+ * REQ_OP_DISCARD
+ *
+ * In all cases the normal I/O path is used for discards. The only
+ * difference is how the kernel tags individual I/Os as discards.
*/
#ifdef QUEUE_FLAG_DISCARD
-#ifdef HAVE_BIO_RW_DISCARD
-#define VDEV_REQ_DISCARD (1 << BIO_RW_DISCARD)
+static inline boolean_t
+bio_is_discard(struct bio *bio)
+{
+#if defined(HAVE_BIO_RW_DISCARD)
+ return (bio->bi_rw & (1 << BIO_RW_DISCARD));
+#elif defined(REQ_DISCARD)
+ return (bio->bi_rw & REQ_DISCARD);
#else
-#define VDEV_REQ_DISCARD REQ_DISCARD
+ return (bio_op(bio) == REQ_OP_DISCARD);
#endif
+}
#else
#error "Allowing the build will cause discard requests to become writes "
"potentially triggering the DMU_MAX_ACCESS assertion. Please file a "