]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: use pi_tuple_size in bi_offload_capable()
authorCaleb Sander Mateos <csander@purestorage.com>
Thu, 8 Jan 2026 17:22:12 +0000 (10:22 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 10 Jan 2026 17:22:54 +0000 (10:22 -0700)
bi_offload_capable() returns whether a block device's metadata size
matches its PI tuple size. Use pi_tuple_size instead of switching on
csum_type. This makes the code considerably simpler and less branchy.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio-integrity-auto.c

index 9850c338548d330b20387c674eeb7e6f4a031d88..eb95e29c93bc6625dbdca822b172fe8d9dcc89bd 100644 (file)
@@ -52,19 +52,7 @@ static bool bip_should_check(struct bio_integrity_payload *bip)
 
 static bool bi_offload_capable(struct blk_integrity *bi)
 {
-       switch (bi->csum_type) {
-       case BLK_INTEGRITY_CSUM_CRC64:
-               return bi->metadata_size == sizeof(struct crc64_pi_tuple);
-       case BLK_INTEGRITY_CSUM_CRC:
-       case BLK_INTEGRITY_CSUM_IP:
-               return bi->metadata_size == sizeof(struct t10_pi_tuple);
-       default:
-               pr_warn_once("%s: unknown integrity checksum type:%d\n",
-                       __func__, bi->csum_type);
-               fallthrough;
-       case BLK_INTEGRITY_CSUM_NONE:
-               return false;
-       }
+       return bi->metadata_size == bi->pi_tuple_size;
 }
 
 /**