All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH 8/8] test, device-dax: check mappings invalidated on namespace reconfiguration
Date: Tue, 16 Aug 2016 10:22:09 -0700	[thread overview]
Message-ID: <147136812987.27902.7097669727543459420.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <147136808681.27902.14029119240021638000.stgit@dwillia2-desk3.amr.corp.intel.com>

Validate that the kernel does not leak mappings past the end of life of
the namespace device.  I.e. ndctl_dax_delete() == "mappings return
SIGBUS".

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/device-dax.c |   31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/test/device-dax.c b/test/device-dax.c
index 7b624ea5bc8f..1a67a27ab134 100644
--- a/test/device-dax.c
+++ b/test/device-dax.c
@@ -5,6 +5,8 @@
 #include <stdlib.h>
 #include <syslog.h>
 #include <string.h>
+#include <signal.h>
+#include <setjmp.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/types.h>
@@ -17,6 +19,8 @@
 #include <ndctl/builtin.h>
 #include <test.h>
 
+static sigjmp_buf sj_env;
+
 static int create_namespace(int argc, const char **argv, struct ndctl_ctx *ctx)
 {
 	builtin_xaction_namespace_reset();
@@ -47,16 +51,31 @@ static int setup_device_dax(struct ndctl_namespace *ndns)
 	return create_namespace(argc, argv, ctx);
 }
 
+static void sigbus(int sig, siginfo_t *siginfo, void *d)
+{
+	siglongjmp(sj_env, 1);
+}
+
 static int test_device_dax(int loglevel, struct ndctl_test *test,
 		struct ndctl_ctx *ctx)
 {
 	int fd, rc, *p;
 	char *buf, path[100];
+	struct sigaction act;
 	struct ndctl_dax *dax;
 	struct daxctl_dev *dev;
 	struct ndctl_namespace *ndns;
 	struct daxctl_region *dax_region;
 
+	memset (&act, 0, sizeof(act));
+	act.sa_sigaction = sigbus;
+	act.sa_flags = SA_SIGINFO;
+
+	if (sigaction(SIGBUS, &act, 0)) {
+		perror("sigaction");
+		return 1;
+	}
+
 	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 7, 0)))
 		return 77;
 
@@ -105,8 +124,18 @@ static int test_device_dax(int loglevel, struct ndctl_test *test,
 		return rc;
 	}
 
+	/* test fault after device-dax instance disabled */
+	if (sigsetjmp(sj_env, 1)) {
+		/* got sigbus, success */
+		close(fd);
+		return 0;
+	}
+
+	*p = 0xff;
+	fprintf(stderr, "%s: failed to unmap after reset\n",
+			daxctl_dev_get_devname(dev));
 	close(fd);
-	return 0;
+	return EXIT_FAILURE;
 }
 
 int __attribute__((weak)) main(int argc, char *argv[])

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

      parent reply	other threads:[~2016-08-16 17:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16 17:21 [ndctl PATCH 0/8] ndctl: device-dax tests Dan Williams
2016-08-16 17:21 ` [ndctl PATCH 1/8] ndctl: centralize libndctl context init across commands Dan Williams
2016-08-16 17:21 ` [ndctl PATCH 2/8] libdaxctl: add daxctl_region_get_available_size() Dan Williams
2016-08-16 17:21 ` [ndctl PATCH 3/8] libdaxctl: add daxctl_region_get_seed() Dan Williams
2016-08-16 17:21 ` [ndctl PATCH 4/8] test: teach test/libndctl about device-dax seeds Dan Williams
2016-08-16 17:21 ` [ndctl PATCH 5/8] test: refactor / export ndctl_get_test_dev() Dan Williams
2016-08-16 17:21 ` [ndctl PATCH 6/8] test, create-namespace: reset global data Dan Williams
2016-08-16 17:22 ` [ndctl PATCH 7/8] test: convert device-dax test from shell to C Dan Williams
2016-08-16 17:22 ` Dan Williams [this message]

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=147136812987.27902.7097669727543459420.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.