Skip to content

Commit 9972b8c

Browse files
Christoph Hellwigaxboe
authored andcommitted
sd: add a sd_disable_write_same helper
Add helper to disable WRITE SAME when it is not supported and use it instead of sd_config_write_same in the I/O completion handler. This avoids touching more fields than required in the I/O completion handler and prepares for converting sd to use the atomic queue limits API. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent b0dadb8 commit 9972b8c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/scsi/sd.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,13 @@ static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd)
10041004
return sd_setup_write_same10_cmnd(cmd, false);
10051005
}
10061006

1007+
static void sd_disable_write_same(struct scsi_disk *sdkp)
1008+
{
1009+
sdkp->device->no_write_same = 1;
1010+
sdkp->max_ws_blocks = 0;
1011+
blk_queue_max_write_zeroes_sectors(sdkp->disk->queue, 0);
1012+
}
1013+
10071014
static void sd_config_write_same(struct scsi_disk *sdkp)
10081015
{
10091016
struct request_queue *q = sdkp->disk->queue;
@@ -2258,8 +2265,7 @@ static int sd_done(struct scsi_cmnd *SCpnt)
22582265
if (SCpnt->cmnd[1] & 8) { /* UNMAP */
22592266
sd_disable_discard(sdkp);
22602267
} else {
2261-
sdkp->device->no_write_same = 1;
2262-
sd_config_write_same(sdkp);
2268+
sd_disable_write_same(sdkp);
22632269
req->rq_flags |= RQF_QUIET;
22642270
}
22652271
break;

0 commit comments

Comments
 (0)