Blame SOURCES/0013-test-libndctl-Use-ndctl_region_set_ro-to-change-disk.patch

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