public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] scsi: sd: Keep the discard mode stable
@ 2024-06-19  7:14 Li Feng
  2024-06-19  7:16 ` Christoph Hellwig
  2024-06-27  2:43 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Li Feng @ 2024-06-19  7:14 UTC (permalink / raw)
  To: Christoph Hellwig, James E.J. Bottomley, open list,
	open list:SCSI SUBSYSTEM, Martin K. Petersen

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, IO 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>
---
 drivers/scsi/sd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index e01393ed4207..f628ca5ac0ac 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2621,8 +2621,6 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 
 		if (buffer[14] & 0x40) /* LBPRZ */
 			sdkp->lbprz = 1;
-
-		sd_config_discard(sdkp, lim, SD_LBP_WS16);
 	}
 
 	sdkp->capacity = lba + 1;
@@ -3271,8 +3269,6 @@ static void sd_read_block_limits(struct scsi_disk *sdkp,
 		if (vpd->data[32] & 0x80)
 			sdkp->unmap_alignment =
 				get_unaligned_be32(&vpd->data[32]) & ~(1 << 31);
-
-		sd_config_discard(sdkp, lim, sd_discard_mode(sdkp));
 	}
 
  out:
@@ -3671,6 +3667,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
 			sd_read_cpr(sdkp);
 		}
 
+		sd_config_discard(sdkp, &lim, sd_discard_mode(sdkp));
+
 		sd_print_capacity(sdkp, old_capacity);
 
 		sd_read_write_protect_flag(sdkp, buffer);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] scsi: sd: Keep the discard mode stable
  2024-06-19  7:14 [PATCH v2] scsi: sd: Keep the discard mode stable Li Feng
@ 2024-06-19  7:16 ` Christoph Hellwig
  2024-06-27  2:43 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2024-06-19  7:16 UTC (permalink / raw)
  To: Li Feng
  Cc: Christoph Hellwig, James E.J. Bottomley, open list,
	open list:SCSI SUBSYSTEM, Martin K. Petersen

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

(note that this needs the for-6.11/block-limits branch to be pulled
into the scsi tree, which Martin agreed on, but which hasn't happened
yet)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] scsi: sd: Keep the discard mode stable
  2024-06-19  7:14 [PATCH v2] scsi: sd: Keep the discard mode stable Li Feng
  2024-06-19  7:16 ` Christoph Hellwig
@ 2024-06-27  2:43 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2024-06-27  2:43 UTC (permalink / raw)
  To: Li Feng
  Cc: Christoph Hellwig, James E.J. Bottomley, open list,
	open list:SCSI SUBSYSTEM, Martin K. Petersen, Jens Axboe


Li,

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

This is fine with me. It's a subset of what I have pending in my
discovery series but it doesn't look like that will ready in time for
6.11. So let's just grab this for now.

Jens: Probably easiest if you take this through the block-limits branch.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-27  2:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19  7:14 [PATCH v2] scsi: sd: Keep the discard mode stable Li Feng
2024-06-19  7:16 ` Christoph Hellwig
2024-06-27  2:43 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox