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

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

 



Jeff,

> That's more or less how the problem presents itself, but it's not that
> we issue an fstrim on a block and it gets zeroed.  That would be fine
> from the file system perspective.  It's that the fstrim is issued and
> unrelated blocks are zeroed.  Once I saw the storage layer was
> responsible, I stopped digging and passed it to Hannes.

--- 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;

This first hunk disables the ability for the user to set the
provisioning_mode to SD_LBP_ZERO. Zero mode is only triggered through
sysfs and is never set by the kernel since there is no way we can detect
if a device is capable. Zero mode predates any of the thin provisioning
knobs being added to the SCSI protocol. This mode is how enterprise
arrays used to work, and is akin to zero block detection on modern SSDs.

@@ -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]);

The only place we ever set lbpme (and thus enable discard) is if the
device sets the LBPME field in READ CAPACITY(16). So there should not be
any way for this code to do anything. If sdkp->lbpme is unset, discard
is already disabled (unless the device temporarily reports lbpme and
then switches it off!?).

Under the assumption that this patch actually fixed the problem, it
smells like there was a udev or user script at play here that twiddled
the provisioning mode in sysfs.

I concur that the discard detection logic is gnarly because we support
several iterations of what turned out to be a constantly moving target
in the SCSI spec. But I don't see how the kernel would go down the path
of automatically enabling discards unless the device reported LBPME in
the first place.

Definitely need more data.

-- 
Martin K. Petersen	Oracle Linux Engineering



[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