Re: [PATCH] scsi: sd: Keep the discard mode stable
From: Christoph Hellwig
Date: Tue Jun 18 2024 - 02:47:03 EST
On Mon, Jun 17, 2024 at 05:03:03PM +0800, Li Feng wrote:
> > But more importantly this doesn't really scale to all the variations
> > of reported / guessed at probe time vs overriden. I think you just
> > need an explicit override flag that skips the discard settings.
> >
> I think we only need to prevent the temporary change of discard mode
> from UNMAP to WS16, and this patch should be enough.
>
> Maybe it is a good idea to remove the call to sd_config_discard
> from read_capacity_16 . Because the unmap_alignment/ unmap_granularity
> used by sd_config_discard are assigned in sd_read_block_limits.
>
> sd_read_block_limits is enough to negotiate the discard parameter.
> It is redundant for read_capacity to modify the discard parameter. In this way,
> when the SCSI probe sends read_capacity first and then read block limits,
> it avoids the change of discard from DISABLE to WS16 to UNMAP.
Note that in the linux-next tree for 6.11 we're not only applying
the discard choice to the queue_limits structure and not commiting
it in read_capacity_16. So it will be overriden before it gets
actually applied. Can you check that your issue doesn't show up in
linux-next?