Skip to content

Commit e4dc9a4

Browse files
Israel Rukshinmartinkpetersen
authored andcommitted
scsi: target/iblock: Fix protection error with blocks greater than 512B
The sector size of the block layer is 512 bytes, but integrity interval size might be different (in case of 4K block size of the media). At the initiator side the virtual start sector is the one that was originally submitted by the block layer (512 bytes) for the Reftag usage. The initiator converts the Reftag to integrity interval units and sends it to the target. So the target virtual start sector should be calculated at integrity interval units. prepare_fn() and complete_fn() don't remap correctly the Reftag when using incorrect units of the virtual start sector, which leads to the following protection error at the device: "blk_update_request: protection error, dev sdb, sector 2048 op 0x0:(READ) flags 0x10000 phys_seg 1 prio class 0" To fix that, set the seed in integrity interval units. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Israel Rukshin <[email protected]> Reviewed-by: Max Gurtovoy <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 71482fd commit e4dc9a4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/target/target_core_iblock.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,9 @@ iblock_alloc_bip(struct se_cmd *cmd, struct bio *bio,
646646
}
647647

648648
bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio));
649-
bip_set_seed(bip, bio->bi_iter.bi_sector);
649+
/* virtual start sector must be in integrity interval units */
650+
bip_set_seed(bip, bio->bi_iter.bi_sector >>
651+
(bi->interval_exp - SECTOR_SHIFT));
650652

651653
pr_debug("IBLOCK BIP Size: %u Sector: %llu\n", bip->bip_iter.bi_size,
652654
(unsigned long long)bip->bip_iter.bi_sector);

0 commit comments

Comments
 (0)