android_kernel_oneplus_msm8998/drivers/nvdimm
Robert Elliott 37e875042f linvdimm, pmem: Preserve read-only setting for pmem devices
commit 254a4cd50b9fe2291a12b8902e08e56dcc4e9b10 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 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: 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:21:31 +02:00
..
blk.c block: change ->make_request_fn() and users to return a queue cookie 2015-11-07 10:40:46 -07:00
btt.c libnvdimm, btt: fix btt_rw_page not returning errors 2017-08-06 19:19:42 -07:00
btt.h libnvdimm, btt: consolidate arena validation 2015-08-14 13:43:04 -04:00
btt_devs.c libnvdimm: btt_devs: Fix locking in namespace_store 2015-09-17 11:37:16 -04:00
bus.c linvdimm, pmem: Preserve read-only setting for pmem devices 2018-07-03 11:21:31 +02:00
claim.c libnvdimm, pfn: 'struct page' provider infrastructure 2015-08-28 23:39:36 -04:00
core.c block, libnvdimm, nvme: provide a built-in blk_integrity nop profile 2015-10-21 14:43:45 -06:00
dimm.c libnvdimm: pmem label sets and namespace instantiation. 2015-06-24 21:24:10 -04:00
dimm_devs.c nvdimm: change to use generic kvfree() 2015-08-27 19:35:48 -04:00
e820.c libnvdimm, e820: fix numa node for e820-type-12 pmem ranges 2015-11-12 09:21:18 -08:00
Kconfig libnvdimm, pmem: 'struct page' for pmem 2015-08-28 23:40:04 -04:00
label.c libnvdimm, namespace: fix label initialization to use valid seq numbers 2017-11-30 08:37:23 +00:00
label.h libnvdimm: write blk label set 2015-06-24 21:24:10 -04:00
Makefile libnvdimm, pfn: 'struct page' provider infrastructure 2015-08-28 23:39:36 -04:00
namespace_devs.c libnvdimm, namespace: make 'resource' attribute only readable by root 2017-11-30 08:37:23 +00:00
nd-core.h libnvdimm, pfn: 'struct page' provider infrastructure 2015-08-28 23:39:36 -04:00
nd.h nfit, libnvdimm: fix interleave set cookie calculation 2017-03-18 19:09:58 +08:00
pfn.h libnvdimm, pfn: 'struct page' provider infrastructure 2015-08-28 23:39:36 -04:00
pfn_devs.c libnvdimm, pfn: fix uuid validation 2016-04-20 15:41:54 +09:00
pmem.c libnvdimm, pmem: fix size trim in pmem_direct_access() 2015-11-12 09:55:23 -08:00
region.c libnvdimm, pfn: 'struct page' provider infrastructure 2015-08-28 23:39:36 -04:00
region_devs.c nfit, libnvdimm: fix interleave set cookie calculation 2017-03-18 19:09:58 +08:00