* [ndctl PATCH] test/libndctl: Use ndctl_region_set_ro() to change disk read-only state
@ 2021-03-10 6:09 Dan Williams
0 siblings, 0 replies; only message in thread
From: Dan Williams @ 2021-03-10 6:09 UTC (permalink / raw)
To: linux-nvdimm; +Cc: kernel test robot
Kernel commit 52f019d43c22 ("block: add a hard-readonly flag to struct
gendisk") broke the read-only management test, by fixing the broken
behavior that BLKROSET could make a block device read-write even when the
disk is read-only. The fix (see Link:) propagates changes of the region
read-only state to the underlying disk. Add ndctl_region_set_ro() ahead of
BLKROSET so that BLKROSET does not conflict the block_device state with the
disk state.
Link: http://lore.kernel.org/r/161534060720.528671.2341213328968989192.stgit@dwillia2-desk3.amr.corp.intel.com
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
test/libndctl.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/test/libndctl.c b/test/libndctl.c
index faa308ade8fc..391b94086dae 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -1541,6 +1541,7 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
struct ndctl_pfn *pfn, struct ndctl_namespace *ndns,
struct namespace *namespace, void *buf)
{
+ struct ndctl_region *region = ndctl_namespace_get_region(ndns);
char bdevpath[50];
int fd, rc, ro;
@@ -1578,6 +1579,13 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
}
ro = 0;
+ rc = ndctl_region_set_ro(region, ro);
+ if (rc < 0) {
+ fprintf(stderr, "%s: ndctl_region_set_ro failed\n", devname);
+ rc = -errno;
+ goto out;
+ }
+
rc = ioctl(fd, BLKROSET, &ro);
if (rc < 0) {
fprintf(stderr, "%s: BLKROSET failed\n",
@@ -1605,8 +1613,16 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
rc = -ENXIO;
goto out;
}
+
+ rc = ndctl_region_set_ro(region, namespace->ro);
+ if (rc < 0) {
+ fprintf(stderr, "%s: ndctl_region_set_ro reset failed\n", devname);
+ rc = -errno;
+ goto out;
+ }
+
rc = 0;
- out:
+out:
close(fd);
return rc;
}
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-10 6:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 6:09 [ndctl PATCH] test/libndctl: Use ndctl_region_set_ro() to change disk read-only state Dan Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).