|
|
e0018b |
From 43e48c0d2f271cba4237f6eefc3e4912a74c102b Mon Sep 17 00:00:00 2001
|
|
|
e0018b |
From: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Date: Tue, 9 Mar 2021 22:09:49 -0800
|
|
|
e0018b |
Subject: [PATCH 013/217] test/libndctl: Use ndctl_region_set_ro() to change
|
|
|
e0018b |
disk read-only state
|
|
|
e0018b |
|
|
|
e0018b |
Kernel commit 52f019d43c22 ("block: add a hard-readonly flag to struct
|
|
|
e0018b |
gendisk") broke the read-only management test, by fixing the broken
|
|
|
e0018b |
behavior that BLKROSET could make a block device read-write even when the
|
|
|
e0018b |
disk is read-only. The fix [1] propagates changes of the region
|
|
|
e0018b |
read-only state to the underlying disk. Add ndctl_region_set_ro() ahead of
|
|
|
e0018b |
BLKROSET so that BLKROSET does not conflict the block_device state with the
|
|
|
e0018b |
disk state.
|
|
|
e0018b |
|
|
|
e0018b |
[1]: http://lore.kernel.org/r/161534060720.528671.2341213328968989192.stgit@dwillia2-desk3.amr.corp.intel.com
|
|
|
e0018b |
|
|
|
e0018b |
Reported-by: kernel test robot <lkp@intel.com>
|
|
|
e0018b |
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
Link: https://lore.kernel.org/r/161535658913.530219.12194565167385663385.stgit@dwillia2-desk3.amr.corp.intel.com
|
|
|
e0018b |
---
|
|
|
e0018b |
test/libndctl.c | 18 +++++++++++++++++-
|
|
|
e0018b |
1 file changed, 17 insertions(+), 1 deletion(-)
|
|
|
e0018b |
|
|
|
e0018b |
diff --git a/test/libndctl.c b/test/libndctl.c
|
|
|
e0018b |
index fc65149..c42f785 100644
|
|
|
e0018b |
--- a/test/libndctl.c
|
|
|
e0018b |
+++ b/test/libndctl.c
|
|
|
e0018b |
@@ -1541,6 +1541,7 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
|
|
|
e0018b |
struct ndctl_pfn *pfn, struct ndctl_namespace *ndns,
|
|
|
e0018b |
struct namespace *namespace, void *buf)
|
|
|
e0018b |
{
|
|
|
e0018b |
+ struct ndctl_region *region = ndctl_namespace_get_region(ndns);
|
|
|
e0018b |
char bdevpath[50];
|
|
|
e0018b |
int fd, rc, ro;
|
|
|
e0018b |
|
|
|
e0018b |
@@ -1578,6 +1579,13 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
ro = 0;
|
|
|
e0018b |
+ rc = ndctl_region_set_ro(region, ro);
|
|
|
e0018b |
+ if (rc < 0) {
|
|
|
e0018b |
+ fprintf(stderr, "%s: ndctl_region_set_ro failed\n", devname);
|
|
|
e0018b |
+ rc = -errno;
|
|
|
e0018b |
+ goto out;
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
rc = ioctl(fd, BLKROSET, &ro);
|
|
|
e0018b |
if (rc < 0) {
|
|
|
e0018b |
fprintf(stderr, "%s: BLKROSET failed\n",
|
|
|
e0018b |
@@ -1605,8 +1613,16 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
|
|
|
e0018b |
rc = -ENXIO;
|
|
|
e0018b |
goto out;
|
|
|
e0018b |
}
|
|
|
e0018b |
+
|
|
|
e0018b |
+ rc = ndctl_region_set_ro(region, namespace->ro);
|
|
|
e0018b |
+ if (rc < 0) {
|
|
|
e0018b |
+ fprintf(stderr, "%s: ndctl_region_set_ro reset failed\n", devname);
|
|
|
e0018b |
+ rc = -errno;
|
|
|
e0018b |
+ goto out;
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
rc = 0;
|
|
|
e0018b |
- out:
|
|
|
e0018b |
+out:
|
|
|
e0018b |
close(fd);
|
|
|
e0018b |
return rc;
|
|
|
e0018b |
}
|
|
|
e0018b |
--
|
|
|
e0018b |
2.27.0
|
|
|
e0018b |
|