summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-06-13 10:48:20 +0200
committerJens Axboe <axboe@kernel.dk>2024-06-14 10:20:06 -0600
commit3c3e85ddffae93eba1a257eb6939bf5dc1e93b9e (patch)
treeb69e5827ba95b9079e2d89e05b30ddb0fcf6a193 /include
parent43c5dbe98a3953e07f4fbf89aa137b9207d52378 (diff)
downloadlwn-3c3e85ddffae93eba1a257eb6939bf5dc1e93b9e.tar.gz
lwn-3c3e85ddffae93eba1a257eb6939bf5dc1e93b9e.zip
block: bypass the STABLE_WRITES flag for protection information
Currently registering a checksum-enabled (aka PI) integrity profile sets the QUEUE_FLAG_STABLE_WRITE flag, and unregistering it clears the flag. This can incorrectly clear the flag when the driver requires stable writes even without PI, e.g. in case of iSCSI or NVMe/TCP with data digest enabled. Fix this by looking at the csum_type directly in bdev_stable_writes and not setting the queue flag. Also remove the blk_queue_stable_writes helper as the only user in nvme wants to only look at the actual QUEUE_FLAG_STABLE_WRITE flag as it inherits the integrity configuration by other means. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20240613084839.1044015-11-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include')
-rw-r--r--include/linux/blkdev.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index bdd33388e1ce..f9089750919c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -571,8 +571,6 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q);
#define blk_queue_noxmerges(q) \
test_bit(QUEUE_FLAG_NOXMERGES, &(q)->queue_flags)
#define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags)
-#define blk_queue_stable_writes(q) \
- test_bit(QUEUE_FLAG_STABLE_WRITES, &(q)->queue_flags)
#define blk_queue_io_stat(q) test_bit(QUEUE_FLAG_IO_STAT, &(q)->queue_flags)
#define blk_queue_add_random(q) test_bit(QUEUE_FLAG_ADD_RANDOM, &(q)->queue_flags)
#define blk_queue_zone_resetall(q) \
@@ -1300,8 +1298,14 @@ static inline bool bdev_synchronous(struct block_device *bdev)
static inline bool bdev_stable_writes(struct block_device *bdev)
{
- return test_bit(QUEUE_FLAG_STABLE_WRITES,
- &bdev_get_queue(bdev)->queue_flags);
+ struct request_queue *q = bdev_get_queue(bdev);
+
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+ /* BLK_INTEGRITY_CSUM_NONE is not available in blkdev.h */
+ if (q->integrity.csum_type != 0)
+ return true;
+#endif
+ return test_bit(QUEUE_FLAG_STABLE_WRITES, &q->queue_flags);
}
static inline bool bdev_write_cache(struct block_device *bdev)