mbox series

[0/3] scsi: disable discard when set target full provisioning

Message ID 20240702030118.2198570-1-haoqian.he@smartx.com
Headers show
Series scsi: disable discard when set target full provisioning | expand

Message

Haoqian He July 2, 2024, 3:01 a.m. UTC
Hi all,

this series has a few fixes for the scsi discard mode changes.
The first disable the disacrd when set the target lun full
provisioning, the reset have some cleanups.

The series based on ("scsi: sd: Keep the discard mode stable"):
https://lore.kernel.org/all/20240619071412.140100-1-fengli@smartx.com

Haoqian He (3):
  scsi: sd: disable discard when set target full provisioning
  scsi: sd: remove scsi_disk field lbpvpd
  scsi: sd: remove some redundant initialization code

 drivers/scsi/sd.c | 34 ++++++++++++++++++----------------
 drivers/scsi/sd.h |  1 -
 2 files changed, 18 insertions(+), 17 deletions(-)

Comments

Damien Le Moal July 2, 2024, 3:33 a.m. UTC | #1
On 7/2/24 12:01, Haoqian He wrote:
> Since the memory allocated by kzalloc for sdkp has been
> initialized to 0, the code that initializes some sdkp
> fields to 0 is no longer needed.
> 
> Signed-off-by: Haoqian He <haoqian.he@smartx.com>
> Signed-off-by: Li Feng <fengli@smartx.com>

Looks OK to me.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Martin K. Petersen July 3, 2024, 2:31 a.m. UTC | #2
Haoqian,

> +	if (!sdkp->lbpvpd)
> +		/* Disable discard if LBP VPD page not provided */
> +		return SD_LBP_DISABLE;

That is not a valid assumption. Many devices which support thin
provisioning either predate the LBP VPD being defined or have decided
not to support that page. The current heuristics are very deliberate.
Haoqian He July 4, 2024, 3:01 a.m. UTC | #3
> 2024年7月2日 11:33,Damien Le Moal <dlemoal@kernel.org> 写道:
> 
> On 7/2/24 12:01, Haoqian He wrote:
>> Since the memory allocated by kzalloc for sdkp has been
>> initialized to 0, the code that initializes some sdkp
>> fields to 0 is no longer needed.
>> 
>> Signed-off-by: Haoqian He <haoqian.he@smartx.com>
>> Signed-off-by: Li Feng <fengli@smartx.com>
> 
> Looks OK to me.
> 
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> 
> -- 
> Damien Le Moal
> Western Digital Research
> 

Hi Martin,

According to the SBC-3 SPEC:
"The device server in a logical unit that supports logical block provisioning
management shall set the LBPME bit to one in the parameter data returned for
a READ CAPACITY (16) command."

So we can use lbpme bit instead of lbpvpd to indicate if the device is thin
provisioned, which was implemented in patch 2 ("scsi: sd: remove scsi_disk
field lbpvpd").

Thanks,
Haoqian