From: Martin K. Petersen <hidden> Date: 2014-11-07 05:08:11
This update is mainly motivated by an attempt to make the
discard_zeroes_data reporting more accurate. As we have discussed
several times in the past we are stuck with pretty weak guarantees from
the T10/T13 standards. And as a result we feel compelled to tighten up
the scenarios under which we advertise discard_zeroes_data since several
applications and subsystems depend on it being accurate.
The first patch is the most controversial. It disables
discard_zeroes_data for libata devices unless they explicitly have been
whitelisted. I had hoped to have a more comprehensive list of drives but
I didn't have much luck in procuring the identify strings that would
allow me to generate the whitelist matching patterns. I could use some
help here.
The second patch tweaks the SCSI disk driver to prefer WRITE SAME w/
UNMAP instead of the UNMAP command since the former has deterministic
behavior.
The lack of a hard discard_zeroes_data guarantees has also prevented us
from having a variant of blkdev_issue_zeroout() that discards if
possible. The last patch in this series will add such a call that the
filesystems and virt block drivers can use to clear and deprovision
block ranges.
--
Martin K. Petersen Oracle Linux Engineering
From: Martin K. Petersen <hidden> Date: 2014-11-07 05:08:13
The T10 SBC UNMAP command does not provide any hard guarantees that
blocks will return zeroes on a subsequent READ. This is due to the fact
that the device server is free to silently ignore all or parts of the
request.
The only way to ensure that a block consistently returns zeroes after
being unmapped is to use WRITE SAME with the UNMAP bit set. Should the
device be unable to unmap one or more blocks described by the command it
is required to manually write zeroes to them.
Until now we have preferred UNMAP over the WRITE SAME variants to
accommodate thinly provisioned devices that predated the final SBC-3
spec. This patch changes the heuristic so that we favor WRITE SAME(16)
or (10) over UNMAP if these commands are marked as supported in the
Logical Block Provisioning VPD page.
The patch also disables discard_zeroes_data for devices operating in
UNMAP mode.
Signed-off-by: Martin K. Petersen <redacted>
---
drivers/scsi/sd.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
@@ -2622,12 +2624,12 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)}else{/* LBP VPD page tells us what to use */-if(sdkp->lbpu&&sdkp->max_unmap_blocks)-sd_config_discard(sdkp,SD_LBP_UNMAP);-elseif(sdkp->lbpws)+if(sdkp->lbpws)sd_config_discard(sdkp,SD_LBP_WS16);elseif(sdkp->lbpws10)sd_config_discard(sdkp,SD_LBP_WS10);+elseif(sdkp->lbpu&&sdkp->max_unmap_blocks)+sd_config_discard(sdkp,SD_LBP_UNMAP);elsesd_config_discard(sdkp,SD_LBP_DISABLE);}
From: Martin K. Petersen <hidden> Date: 2014-11-07 05:08:14
blkdev_issue_discard() will zero a given block range on disk. This is
done by way of either WRITE SAME or regular WRITE. I.e. the blocks on
disk will be written and thus provisioned.
There are use cases where the desired behavior is to zero the blocks but
unprovision them if possible. The blocks must deterministically contain
zeroes when they are subsequently read back.
This patch introduces a blkdev_issue_zeroout_discard() call that
provides this functionality. If a block device guarantees
discard_zeroes_data the new function will use discard to clear the block
range. If the device does not support discard_zeroes_data or if the
discard request fails we will fall back to blkdev_issue_zeroout() to
ensure predictable results.
Signed-off-by: Martin K. Petersen <redacted>
---
block/blk-lib.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
include/linux/blkdev.h | 2 ++
2 files changed, 44 insertions(+), 2 deletions(-)
From: Martin K. Petersen <hidden> Date: 2014-11-07 05:08:33
As defined, the DRAT (Deterministic Read After Trim) and RZAT (Return
Zero After Trim) flags in the ATA Command Set are unreliable in the
sense that they only define what happens if the device successfully
executed the DSM TRIM command. TRIM is only advisory, however, and the
device is free to silently ignore all or parts of the request.
In practice this renders the DRAT and RZAT flags completely useless and
because the results are unpredictable we decided to disable discard in
MD for 3.18 to avoid the risk of data corruption.
Hardware vendors in the real world obviously need better guarantees than
what the standards bodies provide. Unfortuntely those guarantees are
encoded in product requirements documents rather than somewhere we can
key off of them programatically. So we are compelled to disabling
discard_zeroes_data for all devices unless we explicitly have data to
support whitelisting them.
This patch whitelists SSDs from a few of the main vendors. None of the
whitelists are based on written guarantees. They are purely based on
empirical evidence collected from internal and external users that have
tested or qualified these drives in RAID deployments.
The whitelist is only meant as a starting point and is by no means
comprehensive:
- All intel SSD models except for 510
- Micron M5*
- Samsung SSDs
- Seagate SSDs
Signed-off-by: Martin K. Petersen <redacted>
---
drivers/ata/libata-core.c | 18 ++++++++++++++----
drivers/ata/libata-scsi.c | 10 ++++++----
include/linux/libata.h | 1 +
3 files changed, 21 insertions(+), 8 deletions(-)
@@ -421,6 +421,7 @@ enum {ATA_HORKAGE_NO_NCQ_TRIM=(1<<19),/* don't use queued TRIM */ATA_HORKAGE_NOLPM=(1<<20),/* don't use LPM */ATA_HORKAGE_WD_BROKEN_LPM=(1<<21),/* some WDs have broken LPM */+ATA_HORKAGE_ZERO_AFTER_TRIM=(1<<22),/* guarantees zero after trim *//* DMA mask for user DMA control: User visible values; DO NOTrenumber*/
I think this should _info, not _warn.
Otherwise looks good to me,
Reviewed-by: Christoph Hellwig <hch@lst.de>
It would be nice if there was a way to trigger the flag from userspace,
so that we don't need to rebuild the kernel to add a whitelist entry.
From: Christoph Hellwig <hch@infradead.org> Date: 2014-11-07 08:26:10
On Fri, Nov 07, 2014 at 12:08:14AM -0500, Martin K. Petersen wrote:
blkdev_issue_discard() will zero a given block range on disk. This is
done by way of either WRITE SAME or regular WRITE. I.e. the blocks on
disk will be written and thus provisioned.
There are use cases where the desired behavior is to zero the blocks but
unprovision them if possible. The blocks must deterministically contain
zeroes when they are subsequently read back.
This patch introduces a blkdev_issue_zeroout_discard() call that
provides this functionality. If a block device guarantees
discard_zeroes_data the new function will use discard to clear the block
range. If the device does not support discard_zeroes_data or if the
discard request fails we will fall back to blkdev_issue_zeroout() to
ensure predictable results.
I'm not a fan of adding another function here and would prefer a flag,
but it looks correct, so:
Reviewed-by: Christoph Hellwig <hch@lst.de>
The second patch tweaks the SCSI disk driver to prefer WRITE SAME w/
UNMAP instead of the UNMAP command since the former has deterministic
behavior.
I have seen data corruption on an Intel SSD 510 after sending WRITE SAME
UNMAP. As far as I remember, these disks ignore writes after sending
that command. Unmap worked fine, though. So possibly there is another
blacklisting required.
Cheers,
Bernd
From: Christoph Hellwig <hch@infradead.org> Date: 2014-11-10 14:19:06
Looks like there is no real dependency between these patches, so we
might take on each through the libata, scsi and block trees.
Can I get another review for the sd patch, please?
From: Paolo Bonzini <pbonzini@redhat.com> Date: 2014-11-10 23:43:07
On 07/11/2014 06:08, Martin K. Petersen wrote:
quoted hunk
The T10 SBC UNMAP command does not provide any hard guarantees that
blocks will return zeroes on a subsequent READ. This is due to the fact
that the device server is free to silently ignore all or parts of the
request.
The only way to ensure that a block consistently returns zeroes after
being unmapped is to use WRITE SAME with the UNMAP bit set. Should the
device be unable to unmap one or more blocks described by the command it
is required to manually write zeroes to them.
Until now we have preferred UNMAP over the WRITE SAME variants to
accommodate thinly provisioned devices that predated the final SBC-3
spec. This patch changes the heuristic so that we favor WRITE SAME(16)
or (10) over UNMAP if these commands are marked as supported in the
Logical Block Provisioning VPD page.
The patch also disables discard_zeroes_data for devices operating in
UNMAP mode.
Signed-off-by: Martin K. Petersen <redacted>
---
drivers/scsi/sd.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
@@ -2622,12 +2624,12 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)}else{/* LBP VPD page tells us what to use */-if(sdkp->lbpu&&sdkp->max_unmap_blocks)-sd_config_discard(sdkp,SD_LBP_UNMAP);-elseif(sdkp->lbpws)+if(sdkp->lbpws)sd_config_discard(sdkp,SD_LBP_WS16);elseif(sdkp->lbpws10)sd_config_discard(sdkp,SD_LBP_WS10);+elseif(sdkp->lbpu&&sdkp->max_unmap_blocks)+sd_config_discard(sdkp,SD_LBP_UNMAP);elsesd_config_discard(sdkp,SD_LBP_DISABLE);}
From: Darrick J. Wong <hidden> Date: 2014-11-11 00:04:33
On Fri, Nov 07, 2014 at 12:08:14AM -0500, Martin K. Petersen wrote:
blkdev_issue_discard() will zero a given block range on disk. This is
done by way of either WRITE SAME or regular WRITE. I.e. the blocks on
disk will be written and thus provisioned.
There are use cases where the desired behavior is to zero the blocks but
unprovision them if possible. The blocks must deterministically contain
zeroes when they are subsequently read back.
This patch introduces a blkdev_issue_zeroout_discard() call that
provides this functionality. If a block device guarantees
discard_zeroes_data the new function will use discard to clear the block
range. If the device does not support discard_zeroes_data or if the
discard request fails we will fall back to blkdev_issue_zeroout() to
ensure predictable results.
Can this be plumbed into a BLK* ioctl too? I'll write a patch, if this is ok
with everyone:
struct blkzeroout_t {
__u64 start;
__u64 end;
__u32 flags;
};
#define BLKZEROOUT_DISCARD_OK 1
#define BLKZEROOUT_V2 _IOR(0x12, 127, sizeof(struct blkzeroout_t))
...and make it zap the page cache per earlier discussion. This seems to be a
good fit with what we've been discussing for mke2fs.
--D
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, 2014-11-10 at 06:19 -0800, Christoph Hellwig wrote:
Looks like there is no real dependency between these patches, so we
might take on each through the libata, scsi and block trees.
Can I get another review for the sd patch, please?
The changes in [PATCH 2/3] sd: Disable discard_zeroes_data for UNMAP
look fine to me. I was wondering, though, if the changes to add the
"devices_handle_discard_safely" module parameter to the MD raid drivers
are really needed if this is fixed. (It's great to be able to disable
the use of discard if desired, but how is an administrator actually
supposed to know if the devices they have *really* work properly?)
Maybe the default value of this parameter should be changed, or the
parameter should be changed to have an inverse sense, i.e. "disable
use of discard"...
-Ewan
From: Darrick J. Wong <hidden> Date: 2014-11-17 19:28:15
Create a new ioctl to expose the block layer's newfound ability to
issue either a zeroing discard, a WRITE SAME with a zero page, or a
regular write with the zero page. This BLKZEROOUT2 ioctl takes
{start, length, flags} as parameters. So far, the only flag available
is to enable the zeroing discard part -- without it, the call invokes
the old BLKZEROOUT behavior. start and length have the same meaning
as in BLKZEROOUT.
Furthermore, because BLKZEROOUT2 issues commands directly to the
storage device, we must invalidate the page cache (as a regular
O_DIRECT write would do) to avoid returning stale cache contents at a
later time.
This patch depends on mkp's earlier patch "block: Introduce
blkdev_issue_zeroout_discard() function".
Signed-off-by: Darrick J. Wong <redacted>
---
block/ioctl.c | 45 ++++++++++++++++++++++++++++++++++++++-------
include/uapi/linux/fs.h | 7 +++++++
2 files changed, 45 insertions(+), 7 deletions(-)
From: Paolo Bonzini <pbonzini@redhat.com> Date: 2014-12-05 16:45:04
On 07/11/2014 06:08, Martin K. Petersen wrote:
quoted hunk
The whitelist is only meant as a starting point and is by no means
comprehensive:
- All intel SSD models except for 510
- Micron M5*
- Samsung SSDs
- Seagate SSDs
Signed-off-by: Martin K. Petersen <redacted>
---
drivers/ata/libata-core.c | 18 ++++++++++++++----
drivers/ata/libata-scsi.c | 10 ++++++----
include/linux/libata.h | 1 +
3 files changed, 21 insertions(+), 8 deletions(-)
I have a Crucial_CT256MX1 (i.e. MX100) and it does reliably zero.
BTW. it's the same hardware as the M550, so probably the same set of
quirks should apply to both.
Paolo
quoted hunk
+
+ /*
+ * DRAT/RZAT are weak guarantees. Explicitly black/whitelist
+ * SSDs that provide reliable zero after TRIM.
+ */
+ { "INTEL*SSDSC2MH*", NULL, 0, }, /* Blacklist intel 510 */
+ { "INTEL*SSD*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
+ { "SSD*INTEL*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
+ { "Samsung*SSD*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
+ { "SAMSUNG*SSD*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
+ { "ST[1248][0248]0[FH]*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
/*
* Some WD SATA-I drives spin up and down erratically when the link
@@ -421,6 +421,7 @@ enum {ATA_HORKAGE_NO_NCQ_TRIM=(1<<19),/* don't use queued TRIM */ATA_HORKAGE_NOLPM=(1<<20),/* don't use LPM */ATA_HORKAGE_WD_BROKEN_LPM=(1<<21),/* some WDs have broken LPM */+ATA_HORKAGE_ZERO_AFTER_TRIM=(1<<22),/* guarantees zero after trim *//* DMA mask for user DMA control: User visible values; DO NOTrenumber*/
From: Elliott, Robert (Server Storage) <hidden> Date: 2014-12-05 22:59:47
-----Original Message-----
From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-
owner@vger.kernel.org] On Behalf Of Martin K. Petersen
Sent: Thursday, 06 November, 2014 11:08 PM
To: linux-scsi@vger.kernel.org; linux-ide@vger.kernel.org; linux-
fsdevel@vger.kernel.org; neilb@suse.de
Cc: Martin K. Petersen
Subject: [PATCH 1/3] libata: Whitelist SSDs that are known to properly return
zeroes after TRIM
As defined, the DRAT (Deterministic Read After Trim) and RZAT (Return
Zero After Trim) flags in the ATA Command Set are unreliable in the
sense that they only define what happens if the device successfully
executed the DSM TRIM command. TRIM is only advisory, however, and the
device is free to silently ignore all or parts of the request.
In practice this renders the DRAT and RZAT flags completely useless and
because the results are unpredictable we decided to disable discard in
MD for 3.18 to avoid the risk of data corruption.
Hardware vendors in the real world obviously need better guarantees than
what the standards bodies provide. Unfortuntely those guarantees are
encoded in product requirements documents rather than somewhere we can
key off of them programatically. So we are compelled to disabling
discard_zeroes_data for all devices unless we explicitly have data to
support whitelisting them.
This patch whitelists SSDs from a few of the main vendors. None of the
whitelists are based on written guarantees. They are purely based on
empirical evidence collected from internal and external users that have
tested or qualified these drives in RAID deployments.
The whitelist is only meant as a starting point and is by no means
comprehensive:
- All intel SSD models except for 510
- Micron M5*
- Samsung SSDs
- Seagate SSDs
That description and Paolo's reply:
From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-
owner@vger.kernel.org] On Behalf Of Paolo Bonzini
Sent: Friday, 05 December, 2014 10:45 AM
...
I have a Crucial_CT256MX1 (i.e. MX100) and it does reliably zero.
make me concerned about this whitelist approach.
I think you need a manufacturer assertion that this is indeed
the design intent; you cannot be certain based on observation
from outside.
Since the SCSI and ATA standards allow ignoring the hint, it
might be honored most of the time, but ignored in some rare
cases (e.g., drive firmware has a malloc() failure that only
happens when the drive is handling an overtemperature
condition and six other problems at the same time).
Maybe there should be two levels:
* vendor asserts the drive is designed to always honor the hint
* community observes the drive always seems to honor the hint
and a sysfs flag for users to select the level at which
they feel safe.
A user running 3 replicas of the data in different sites
might be more trusting than a user for which this is the
only copy of the data.
---
Rob Elliott HP Server Storage
On Fri, Dec 05, 2014 at 10:58:09PM +0000, Elliott, Robert (Server Storage) wrote:
quoted
I have a Crucial_CT256MX1 (i.e. MX100) and it does reliably zero.
make me concerned about this whitelist approach.
I think you need a manufacturer assertion that this is indeed
the design intent; you cannot be certain based on observation
from outside.
How is this different from a manufacturer assertion that they follow a
SCSI or ATA standard? There have been cases in the distant past
(fortunately) of disk manufacturers that ignored a CACHE FLUSH command
just to get higher Winbench scores. Does that mean we can't trust
them to do anything right?
What I'd suggest instead is that if a vendor states this on a spec
sheet --- more than just an e-mail assertion --- so they can be sued
if they knowingly misrepresent their product, that we take their word
at it. Of course, there will be bugs, which is why we have
blacklists, or why we can remove them from the list if it turns out
there are edge conditions where it appears the disk doesn't quite do
the right thing.
After all, we generally take the manufacturer's word that air bags
will work as claimed, even if potentially 11 million of them are
currently subject to recall. And do we think that "the community"
would necessarily be more suited than the vendors and the manufacturer
to figure out whether or not air bags or drives are working as
desired?
That being said, if someone wants to create a open source program
which stress tests SSD's to look for cases where it is dropping a
requested discard, that would certainly be a good thing to do...
Cheers,
- Ted
From: James Bottomley <James.Bottomley@HansenPartnership.com> Date: 2014-12-08 15:28:45
On Mon, 2014-12-08 at 10:15 -0500, Theodore Ts'o wrote:
On Fri, Dec 05, 2014 at 10:58:09PM +0000, Elliott, Robert (Server Storage) wrote:
quoted
quoted
I have a Crucial_CT256MX1 (i.e. MX100) and it does reliably zero.
make me concerned about this whitelist approach.
I think you need a manufacturer assertion that this is indeed
the design intent; you cannot be certain based on observation
from outside.
How is this different from a manufacturer assertion that they follow a
SCSI or ATA standard? There have been cases in the distant past
(fortunately) of disk manufacturers that ignored a CACHE FLUSH command
just to get higher Winbench scores. Does that mean we can't trust
them to do anything right?
That answer depends on device type manufacturer. USB devices, hell no.
ATA devices, maybe and SCSI devices usually.
The main problem is usually testing. Consumer devices like USB and
(s)ATA rarely get tested on anything but windows. USB devices tend to
supply their own driver, so they're on the "we fix it in the driver"
model which is why they bite us so badly. (S)ATA usually comply, but
they only test what windows exercises, so if windows doesn't do it,
chances are it never got tested. SCSI devices still tend to be tested
in legacy UNIX environments, which are as diverse as we are.
What I'd suggest instead is that if a vendor states this on a spec
sheet --- more than just an e-mail assertion --- so they can be sued
if they knowingly misrepresent their product, that we take their word
at it. Of course, there will be bugs, which is why we have
blacklists, or why we can remove them from the list if it turns out
there are edge conditions where it appears the disk doesn't quite do
the right thing.
After all, we generally take the manufacturer's word that air bags
will work as claimed, even if potentially 11 million of them are
currently subject to recall. And do we think that "the community"
would necessarily be more suited than the vendors and the manufacturer
to figure out whether or not air bags or drives are working as
desired?
That being said, if someone wants to create a open source program
which stress tests SSD's to look for cases where it is dropping a
requested discard, that would certainly be a good thing to do...
The purpose of DRAT and RZAT is to enable disk arrays deterministically
to use TRIM/Unmap so arrays know what happens to stripes on discard.
Arrays are being built of mostly SATA technology these days, so some
manufacturers have retargetted to arrays and consumer technology (and
are testing the array cases). However, windows doesn't use either
feature, so manufacturers not targetting arrays will never test this
feature. Hence, in this case, I think a whitelist does make sense.
James
From: One Thousand Gnomes <hidden> Date: 2014-12-08 22:59:15
On Mon, 8 Dec 2014 10:15:59 -0500
"Theodore Ts'o" [off-list ref] wrote:
On Fri, Dec 05, 2014 at 10:58:09PM +0000, Elliott, Robert (Server Storage) wrote:
quoted
quoted
I have a Crucial_CT256MX1 (i.e. MX100) and it does reliably zero.
make me concerned about this whitelist approach.
I think you need a manufacturer assertion that this is indeed
the design intent; you cannot be certain based on observation
from outside.
How is this different from a manufacturer assertion that they follow a
SCSI or ATA standard? There have been cases in the distant past
(fortunately) of disk manufacturers that ignored a CACHE FLUSH command
just to get higher Winbench scores. Does that mean we can't trust
them to do anything right?
At the time they never promised to honour cache flush. The reason it was
became mandatory in the specification was in part so that the vendors
could all force each other to play fair. If its "optional" then it's
tough..., if they say they meet the standard it's class action 8)
If this is a promise then it ought to be good
James: "USB devices tend to supply their own driver"
has not been true for some years now. Microsoft provide an in-box driver
and vendors have the choice of using that or certifying their own via
WHQL, which is a bit like choosing between free ice cream and banging
your head against a plank cover in nails.
Alan