mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
block: fix lbmd_guard_tag_type assignment in FS_IOC_GETLBMD_CAP
The blk_get_meta_cap() implementation directly assigns bi->csum_type to
the UAPI field lbmd_guard_tag_type. This is not right as the kernel enum
blk_integrity_checksum values are not guaranteed to match the UAPI
defined values.
Fix this by explicitly mapping internal checksum types to UAPI-defined
constants to ensure compatibility and correctness, especially for the
devices using CRC64 PI.
Fixes: 9eb22f7fed
("fs: add ioctl to query metadata and protection info capabilities")
Reported-by: Vincent Fu <vincent.fu@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Link: https://lore.kernel.org/20250722120755.87501-1-anuj20.g@samsung.com
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
42b0ef01e6
commit
bc5b0c8feb
@ -83,7 +83,21 @@ int blk_get_meta_cap(struct block_device *bdev, unsigned int cmd,
|
|||||||
if (meta_cap.lbmd_opaque_size && !bi->pi_offset)
|
if (meta_cap.lbmd_opaque_size && !bi->pi_offset)
|
||||||
meta_cap.lbmd_opaque_offset = bi->pi_tuple_size;
|
meta_cap.lbmd_opaque_offset = bi->pi_tuple_size;
|
||||||
|
|
||||||
meta_cap.lbmd_guard_tag_type = bi->csum_type;
|
switch (bi->csum_type) {
|
||||||
|
case BLK_INTEGRITY_CSUM_NONE:
|
||||||
|
meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_NONE;
|
||||||
|
break;
|
||||||
|
case BLK_INTEGRITY_CSUM_IP:
|
||||||
|
meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_IP;
|
||||||
|
break;
|
||||||
|
case BLK_INTEGRITY_CSUM_CRC:
|
||||||
|
meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC16_T10DIF;
|
||||||
|
break;
|
||||||
|
case BLK_INTEGRITY_CSUM_CRC64:
|
||||||
|
meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC64_NVME;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (bi->csum_type != BLK_INTEGRITY_CSUM_NONE)
|
if (bi->csum_type != BLK_INTEGRITY_CSUM_NONE)
|
||||||
meta_cap.lbmd_app_tag_size = 2;
|
meta_cap.lbmd_app_tag_size = 2;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user