aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2022-05-27 17:51:55 +0000
committerBrian Behlendorf <[email protected]>2022-05-31 12:04:17 -0700
commit5e4aedaca7cee981ed21ac856fd27b4682bb7888 (patch)
tree23c0d38859f58856a4f763c1b4bb49ec5a8c0cb6 /include
parent5f264996f4dc2d5279afe96698688a20c281c473 (diff)
Linux 5.19 compat: bdev_max_discard_sectors()
Linux 5.19 commit torvalds/linux@70200574cc removed the blk_queue_discard() helper function. The preferred interface is to now use the bdev_max_discard_sectors() function to check for discard support. Reviewed-by: Tony Hutter <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #13515
Diffstat (limited to 'include')
-rw-r--r--include/os/linux/kernel/linux/blkdev_compat.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h
index 9fa8884bb..084d48c87 100644
--- a/include/os/linux/kernel/linux/blkdev_compat.h
+++ b/include/os/linux/kernel/linux/blkdev_compat.h
@@ -495,6 +495,25 @@ blk_queue_discard_granularity(struct request_queue *q, unsigned int dg)
}
/*
+ * 5.19 API,
+ * bdev_max_discard_sectors()
+ *
+ * 2.6.32 API,
+ * blk_queue_discard()
+ */
+static inline boolean_t
+bdev_discard_supported(struct block_device *bdev)
+{
+#if defined(HAVE_BDEV_MAX_DISCARD_SECTORS)
+ return (!!bdev_max_discard_sectors(bdev));
+#elif defined(HAVE_BLK_QUEUE_DISCARD)
+ return (!!blk_queue_discard(bdev_get_queue(bdev)));
+#else
+#error "Unsupported kernel"
+#endif
+}
+
+/*
* 4.8 API,
* blk_queue_secure_erase()
*