Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2018-08-08 13:52:36 +0200
committerJohannes Thumshirn <jthumshirn@suse.de>2018-08-08 13:52:36 +0200
commit4caf4e0c0a66e0dba03d962fcffa284b48d9c11d (patch)
treed280be0584821e95cc940e37ae50e84d7f1d4469
parent19be07da94f27d1f0ae955d6a5ebb2e32ddd61da (diff)
linvdimm, pmem: Preserve read-only setting for pmem devices
(git-fixes).
-rw-r--r--patches.fixes/linvdimm-pmem-Preserve-read-only-setting-for-pmem-de.patch77
-rw-r--r--series.conf1
2 files changed, 78 insertions, 0 deletions
diff --git a/patches.fixes/linvdimm-pmem-Preserve-read-only-setting-for-pmem-de.patch b/patches.fixes/linvdimm-pmem-Preserve-read-only-setting-for-pmem-de.patch
new file mode 100644
index 0000000000..0a86a1a0b6
--- /dev/null
+++ b/patches.fixes/linvdimm-pmem-Preserve-read-only-setting-for-pmem-de.patch
@@ -0,0 +1,77 @@
+From: Robert Elliott <elliott@hpe.com>
+Date: Thu, 31 May 2018 18:36:36 -0500
+Subject: linvdimm, pmem: Preserve read-only setting for pmem devices
+Patch-mainline: v4.18-rc1
+Git-commit: 254a4cd50b9fe2291a12b8902e08e56dcc4e9b10
+References: git-fixes
+
+The pmem driver does not honor a forced read-only setting for very long:
+ $ blockdev --setro /dev/pmem0
+ $ blockdev --getro /dev/pmem0
+ 1
+
+followed by various commands like these:
+ $ blockdev --rereadpt /dev/pmem0
+ or
+ $ mkfs.ext4 /dev/pmem0
+
+results in this in the kernel serial log:
+ nd_pmem namespace0.0: region0 read-write, marking pmem0 read-write
+
+with the read-only setting lost:
+ $ blockdev --getro /dev/pmem0
+ 0
+
+That's from bus.c nvdimm_revalidate_disk(), which always applies the
+setting from nd_region (which is initially based on the ACPI NFIT
+NVDIMM state flags not_armed bit).
+
+In contrast, commit 20bd1d026aac ("scsi: sd: Keep disk read-only when
+re-reading partition") fixed this issue for SCSI devices to preserve
+the previous setting if it was set to read-only.
+
+This patch modifies bus.c to preserve any previous read-only setting.
+It also eliminates the kernel serial log print except for cases where
+read-write is changed to read-only, so it doesn't print read-only to
+read-only non-changes.
+
+Cc: <stable@vger.kernel.org>
+Fixes: 581388209405 ("libnvdimm, nfit: handle unarmed dimms, mark namespaces read-only")
+Signed-off-by: Robert Elliott <elliott@hpe.com>
+Signed-off-by: Dan Williams <dan.j.williams@intel.com>
+Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
+---
+ drivers/nvdimm/bus.c | 14 +++++++++-----
+ 1 file changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
+index a64023690cad..b9e0d30e317a 100644
+--- a/drivers/nvdimm/bus.c
++++ b/drivers/nvdimm/bus.c
+@@ -566,14 +566,18 @@ int nvdimm_revalidate_disk(struct gendisk *disk)
+ {
+ struct device *dev = disk_to_dev(disk)->parent;
+ struct nd_region *nd_region = to_nd_region(dev->parent);
+- const char *pol = nd_region->ro ? "only" : "write";
++ int disk_ro = get_disk_ro(disk);
+
+- if (nd_region->ro == get_disk_ro(disk))
++ /*
++ * Upgrade to read-only if the region is read-only preserve as
++ * read-only if the disk is already read-only.
++ */
++ if (disk_ro || nd_region->ro == disk_ro)
+ return 0;
+
+- dev_info(dev, "%s read-%s, marking %s read-%s\n",
+- dev_name(&nd_region->dev), pol, disk->disk_name, pol);
+- set_disk_ro(disk, nd_region->ro);
++ dev_info(dev, "%s read-only, marking %s read-only\n",
++ dev_name(&nd_region->dev), disk->disk_name);
++ set_disk_ro(disk, 1);
+
+ return 0;
+
+--
+2.12.3
+
diff --git a/series.conf b/series.conf
index 277ca891ed..a12899fc12 100644
--- a/series.conf
+++ b/series.conf
@@ -15184,6 +15184,7 @@
patches.drivers/nvme-rdma-correctly-check-for-target-keyed-sgl-suppo.patch
patches.drivers/nvmet-filter-newlines-from-user-input.patch
patches.drivers/nvme-cleanup-double-shift-issue.patch
+ patches.fixes/linvdimm-pmem-Preserve-read-only-setting-for-pmem-de.patch
patches.drivers/libnvdimm-pmem-Unconditionally-deep-flush-on-sync.patch
patches.drivers/libnvdimm-pmem-Do-not-flush-power-fail-protected-CPU.patch
patches.drivers/staging-iio-ade7854-Fix-error-handling-on-read-write