Skip to content

Commit 7afe939

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: add a bdev_has_integrity_csum helper
Factor out a helper to see if the block device has an integrity checksum from bdev_stable_writes so that it can be reused for other checks. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Anuj Gupta <anuj20.g@samsung.com> Reviewed-by: Kanchan Joshi <joshi.k@samsung.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Tested-by: Anuj Gupta <anuj20.g@samsung.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent a936655 commit 7afe939

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

include/linux/blkdev.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,14 +1477,18 @@ static inline bool bdev_synchronous(struct block_device *bdev)
14771477
return bdev->bd_disk->queue->limits.features & BLK_FEAT_SYNCHRONOUS;
14781478
}
14791479

1480-
static inline bool bdev_stable_writes(struct block_device *bdev)
1480+
static inline bool bdev_has_integrity_csum(struct block_device *bdev)
14811481
{
1482-
struct request_queue *q = bdev_get_queue(bdev);
1482+
struct queue_limits *lim = bdev_limits(bdev);
14831483

1484-
if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
1485-
q->limits.integrity.csum_type != BLK_INTEGRITY_CSUM_NONE)
1486-
return true;
1487-
return q->limits.features & BLK_FEAT_STABLE_WRITES;
1484+
return IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
1485+
lim->integrity.csum_type != BLK_INTEGRITY_CSUM_NONE;
1486+
}
1487+
1488+
static inline bool bdev_stable_writes(struct block_device *bdev)
1489+
{
1490+
return bdev_has_integrity_csum(bdev) ||
1491+
(bdev_limits(bdev)->features & BLK_FEAT_STABLE_WRITES);
14881492
}
14891493

14901494
static inline bool blk_queue_write_cache(struct request_queue *q)

0 commit comments

Comments
 (0)