Re: [PATCH] sd: disable logical block provisioning if 'lbpme' is not set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/18/19 10:56 AM, Jean Delvare wrote:
Hi Bart,

Sorry to resend this, my previous reply had a stray backslash in the
headers (no idea why) that confused certain MTA, so at least Hannes did
not receive it.

I take benefit of this resend to update with the latest information, so
keep reading.

On Fri, 15 Feb 2019 07:56:11 -0800, Bart Van Assche wrote:
On Thu, 2019-02-14 at 22:15 +0100, Jean Delvare wrote:
From: Hannes Reinecke <hare@xxxxxxxx>

When evaluating the 'block limits' VPD page we need to check if
the 'lbpme' (logical block provisioning management enable) bit
is set in the READ CAPACITY (16) output.
If it isn't we can safely assume that we cannot use DISCARD on
this device.

[JD: forward-ported to kernel v4.20]

Signed-off-by: Hannes Reinecke <hare@xxxxxxxx>
Signed-off-by: Jean Delvare <jdelvare@xxxxxxxx>
---
Hannes, please double-check that my forward-port is correct.

  drivers/scsi/sd.c |   11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)

--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -411,6 +411,13 @@ provisioning_mode_store(struct device *d
  	if (mode < 0)
  		return -EINVAL;
+ /*
+	 * If logical block provisioning isn't enabled we can only
+	 * select 'disable' here.
+	 */
+	if (!sdkp->lbpme && mode != SD_LBP_DISABLE)
+		return -EINVAL;
+
  	sd_config_discard(sdkp, mode);
return count;
@@ -2942,8 +2949,10 @@ static void sd_read_block_limits(struct
sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]); - if (!sdkp->lbpme)
+		if (!sdkp->lbpme) {
+			sd_config_discard(sdkp, SD_LBP_DISABLE);
  			goto out;
+		}
lba_count = get_unaligned_be32(&buffer[20]);
  		desc_count = get_unaligned_be32(&buffer[24]);

What is the impact of this patch on SATA SSDs? Since these SSDs do not support
logical provisioning, does this patch break trim support for these SSDs?

None.

SATA SSDs as provided by libata will always set the 'lbpme' bit if TRIM is supported:

		if (ata_id_has_trim(args->id) &&
		    !(dev->horkage & ATA_HORKAGE_NOTRIM)) {
			rbuf[14] |= 0x80; /* LBPME */

			if (ata_id_has_zero_after_trim(args->id) &&
			    dev->horkage & ATA_HORKAGE_ZERO_AFTER_TRIM) {
				ata_dev_info(dev, "Enabling discard_zeroes_data\n");
				rbuf[14] |= 0x40; /* LBPRZ */
			}
		}

Of course, I cannot speak for other SATL implementations (mpt3sas etc), but they are known to have other issues, too, so I don't really care.

Cheers,

Hannes
--
Dr. Hannes Reinecke		               zSeries & Storage
hare@xxxxxxxx			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux