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

scsi: sd: set max_hw_wzeroes_unmap_sectors if device supports SD_ZERO_*_UNMAP

When the device supports the Write Zeroes command and the zeroing mode
is set to SD_ZERO_WS16_UNMAP or SD_ZERO_WS10_UNMAP, this means that the
device supports unmap Write Zeroes, so set the corresponding
max_hw_write_zeroes_unmap_sectors to max_write_zeroes_sectors on the
device's queue limit.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://lore.kernel.org/20250619111806.3546162-5-yi.zhang@huaweicloud.com
Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Zhang Yi and committed by
Christian Brauner
6dffe079 50634366

+5
+5
drivers/scsi/sd.c
··· 1141 1141 out: 1142 1142 lim->max_write_zeroes_sectors = 1143 1143 sdkp->max_ws_blocks * (logical_block_size >> SECTOR_SHIFT); 1144 + 1145 + if (sdkp->zeroing_mode == SD_ZERO_WS16_UNMAP || 1146 + sdkp->zeroing_mode == SD_ZERO_WS10_UNMAP) 1147 + lim->max_hw_wzeroes_unmap_sectors = 1148 + lim->max_write_zeroes_sectors; 1144 1149 } 1145 1150 1146 1151 static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd)