]> git.baikalelectronics.ru Git - kernel.git/commit
linvdimm, pmem: Preserve read-only setting for pmem devices
authorRobert Elliott <elliott@hpe.com>
Thu, 31 May 2018 23:36:36 +0000 (18:36 -0500)
committerDan Williams <dan.j.williams@intel.com>
Fri, 1 Jun 2018 04:07:33 +0000 (21:07 -0700)
commit3e817569f5845dee469c5c8c7574d1ab6e69b4c8
treeddca38d2bb5c822e2c17aa2cd69fff983b5f2b74
parent74ec999c188d9bcec39cb777ff04ecb2a2d6318b
linvdimm, pmem: Preserve read-only setting for pmem devices

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 5e29f7683cfb ("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: c30f4938b87b ("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>
drivers/nvdimm/bus.c