Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2019-02-14 17:41:20 +0100
committerJean Delvare <jdelvare@suse.de>2019-02-14 17:41:20 +0100
commit96370bd87299c7a6883b3e2bf13818f60c8ba611 (patch)
tree6c5fb1499d98fc6b8193a87d64d0dd629124afa7
parent5fdcc9222f58490e8e5a46fb1c56807e90a8cc6f (diff)
sd: disable logical block provisioning if 'lbpme' is not set
(bsc#1086095 bsc#1078355).
-rw-r--r--patches.fixes/sd-disable-logical-block-provisioning-if-lbpme-is-no.patch45
-rw-r--r--series.conf3
2 files changed, 48 insertions, 0 deletions
diff --git a/patches.fixes/sd-disable-logical-block-provisioning-if-lbpme-is-no.patch b/patches.fixes/sd-disable-logical-block-provisioning-if-lbpme-is-no.patch
new file mode 100644
index 0000000000..10802746e0
--- /dev/null
+++ b/patches.fixes/sd-disable-logical-block-provisioning-if-lbpme-is-no.patch
@@ -0,0 +1,45 @@
+From: Hannes Reinecke <hare@suse.de>
+Date: Fri, 20 Apr 2018 15:44:40 +0200
+Subject: [PATCH] sd: disable logical block provisioning if 'lbpme' is not set
+Patch-Mainline: submitted linux-scsi 2018/10/03
+References: bsc#1086095 bsc#1078355
+
+When evaluating the 'block limits' VPD page we need to check if
+the 'lbpme' (logical block provisioning managment 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.
+
+Signed-off-by: Hannes Reinecke <hare@suse.com>
+---
+ drivers/scsi/sd.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+--- a/drivers/scsi/sd.c
++++ b/drivers/scsi/sd.c
+@@ -415,6 +415,13 @@ provisioning_mode_store(struct device *d
+ if (sdp->type != TYPE_DISK)
+ return -EINVAL;
+
++ /*
++ * If logical block provisioning isn't enabled we can only
++ * select 'disable' here.
++ */
++ if (!sdkp->lbpme && strncmp(buf, lbp_mode[SD_LBP_DISABLE], 20))
++ return -EINVAL;
++
+ if (!strncmp(buf, lbp_mode[SD_LBP_UNMAP], 20))
+ sd_config_discard(sdkp, SD_LBP_UNMAP);
+ else if (!strncmp(buf, lbp_mode[SD_LBP_WS16], 20))
+@@ -2789,8 +2796,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]);
diff --git a/series.conf b/series.conf
index a0c0383a88..3cdc2345bc 100644
--- a/series.conf
+++ b/series.conf
@@ -25112,6 +25112,9 @@
# Generic badblock management
patches.drivers/0006-badblocks-fix-wrong-return-value-when-badblocks-are-disabled.patch
+ patches.fixes/sd-disable-logical-block-provisioning-if-lbpme-is-no.patch
+
+
##########################################################
# crypto acceleration
##########################################################