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

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