diff mbox series

[1/2] block: add BLK_FEAT_READ_SYNCHRONOUS feature for synchronous read

Message ID 20240919112952.981-2-qun-wei.lin@mediatek.com (mailing list archive)
State New, archived
Headers show
Series Add BLK_FEAT_READ_SYNCHRONOUS and SWP_READ_SYNCHRONOUS_IO | expand

Commit Message

Qun-wei Lin (林群崴) Sept. 19, 2024, 11:29 a.m. UTC
This commit introduces a new feature flag, BLK_FEAT_READ_SYNCHRONOUS,
which ensures that read operations always complete in the submit context.
This is useful for scenarios where synchronous read operations are required
while allowing write operations to remain asynchronous.

This patch is preparation for optimizing of the operation of the swap
device with next patch.

Signed-off-by: Qun-Wei Lin <qun-wei.lin@mediatek.com>
---
 include/linux/blkdev.h | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 643c9020a35a..a697db11d91c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -332,6 +332,9 @@  typedef unsigned int __bitwise blk_features_t;
 #define BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE \
 	((__force blk_features_t)(1u << 15))
 
+/* read operations always completes in submit context */
+#define BLK_FEAT_READ_SYNCHRONOUS	((__force blk_features_t)(1u << 16))
+
 /*
  * Flags automatically inherited when stacking limits.
  */
@@ -1310,6 +1313,11 @@  static inline bool bdev_synchronous(struct block_device *bdev)
 	return bdev->bd_disk->queue->limits.features & BLK_FEAT_SYNCHRONOUS;
 }
 
+static inline bool bdev_read_synchronous(struct block_device *bdev)
+{
+	return bdev->bd_disk->queue->limits.features & BLK_FEAT_READ_SYNCHRONOUS;
+}
+
 static inline bool bdev_stable_writes(struct block_device *bdev)
 {
 	struct request_queue *q = bdev_get_queue(bdev);