Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: sd: Keep the discard mode stable

There is a scenario where a large number of discard commands are issued
when the iscsi initiator connects to the target and then performs a session
rescan operation. There is a time window, most of the commands are in UNMAP
mode, and some discard commands become WRITE SAME with UNMAP.

The discard mode has been negotiated during the SCSI probe. If the mode is
temporarily changed from UNMAP to WRITE SAME with UNMAP, an I/O ERROR may
occur because the target may not implement WRITE SAME with UNMAP. Keep the
discard mode stable to fix this issue.

Signed-off-by: Li Feng <fengli@smartx.com>
Link: https://lore.kernel.org/r/20240718080751.313102-2-fengli@smartx.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Li Feng and committed by
Martin K. Petersen
f874d721 ffed586b

+2 -4
+2 -4
drivers/scsi/sd.c
··· 2711 2711 2712 2712 if (buffer[14] & 0x40) /* LBPRZ */ 2713 2713 sdkp->lbprz = 1; 2714 - 2715 - sd_config_discard(sdkp, lim, SD_LBP_WS16); 2716 2714 } 2717 2715 2718 2716 sdkp->capacity = lba + 1; ··· 3363 3365 sdkp->unmap_alignment = 3364 3366 get_unaligned_be32(&vpd->data[32]) & ~(1 << 31); 3365 3367 3366 - sd_config_discard(sdkp, lim, sd_discard_mode(sdkp)); 3367 - 3368 3368 config_atomic: 3369 3369 sdkp->max_atomic = get_unaligned_be32(&vpd->data[44]); 3370 3370 sdkp->atomic_alignment = get_unaligned_be32(&vpd->data[48]); ··· 3750 3754 sd_read_block_characteristics(sdkp, &lim); 3751 3755 sd_zbc_read_zones(sdkp, &lim, buffer); 3752 3756 } 3757 + 3758 + sd_config_discard(sdkp, &lim, sd_discard_mode(sdkp)); 3753 3759 3754 3760 sd_print_capacity(sdkp, old_capacity); 3755 3761