linux-stable/drivers/nvdimm
Robert Elliott a98f1946ea linvdimm, pmem: Preserve read-only setting for pmem devices
commit 254a4cd50b upstream.

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 20bd1d026a ("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: 5813882094 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-03 11:24:58 +02:00
..
blk.c libnvdimm, {btt, blk}: do integrity setup before add_disk() 2018-03-28 18:24:41 +02:00
btt.c libnvdimm, {btt, blk}: do integrity setup before add_disk() 2018-03-28 18:24:41 +02:00
btt.h libnvdimm, btt: Fix an incompatibility in the log layout 2017-12-29 17:53:49 +01:00
btt_devs.c
bus.c linvdimm, pmem: Preserve read-only setting for pmem devices 2018-07-03 11:24:58 +02:00
claim.c
core.c
dax_devs.c
dimm.c libnvdimm, dimm: fix dpa reservation vs uninitialized label area 2018-04-24 09:36:32 +02:00
dimm_devs.c libnvdimm, dimm: clear 'locked' status on successful DIMM enable 2017-11-30 08:40:54 +00:00
e820.c
Kconfig
label.c libnvdimm, namespace: fix label initialization to use valid seq numbers 2017-11-30 08:40:54 +00:00
label.h
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
namespace_devs.c libnvdimm, namespace: use a safe lookup for dimm device name 2018-04-24 09:36:32 +02:00
nd-core.h
nd.h libnvdimm, dimm: clear 'locked' status on successful DIMM enable 2017-11-30 08:40:54 +00:00
pfn.h
pfn_devs.c libnvdimm, pfn: fix start_pad handling for aligned namespaces 2017-12-29 17:53:49 +01:00
pmem.c
pmem.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
region.c
region_devs.c libnvdimm, region : make 'resource' attribute only readable by root 2017-11-30 08:40:54 +00:00