Linux-NVDIMM Archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Cc: kernel test robot <lkp@intel.com>
Subject: [ndctl PATCH] test/libndctl: Use ndctl_region_set_ro() to change disk read-only state
Date: Tue, 09 Mar 2021 22:09:49 -0800	[thread overview]
Message-ID: <161535658913.530219.12194565167385663385.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)

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

                 reply	other threads:[~2021-03-10  6:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=161535658913.530219.12194565167385663385.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=lkp@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).