public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH] tst_checkpoint_destroy
@ 2015-05-25  8:09 Stanislav Kholmanskikh
  2015-05-25  8:51 ` Cyril Hrubis
  0 siblings, 1 reply; 8+ messages in thread
From: Stanislav Kholmanskikh @ 2015-05-25  8:09 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Hi.

As of now, if we run test cases which use the tst_checkpoint framework on NFS,
they will fail with errors like:

creat07     0  TWARN  :  tst_tmpdir.c:206: tst_rmdir: rmobj(/tmpdir/ltp-0IVQPP0NK6/creigi0kV) failed: remove(/tmpdir/ltp-0IVQPP0NK6/creigi0kV) failed; errno=66: Directory not empty

This happens because we keep the futex page mapped while tst_rmdir() is running.

So on we need to unmap the page before tst_rmdir().

What do you think about the proposed solution?

Thanks.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 include/tst_checkpoint.h                  |    9 +++++++++
 lib/tst_checkpoint.c                      |   19 ++++++++++++++++++-
 testcases/kernel/syscalls/creat/creat07.c |    2 ++
 3 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/include/tst_checkpoint.h b/include/tst_checkpoint.h
index e6b8100..95a82b4 100644
--- a/include/tst_checkpoint.h
+++ b/include/tst_checkpoint.h
@@ -48,7 +48,16 @@
 void tst_checkpoint_init(const char *file, const int lineno,
 			 void (*cleanup_fn)(void));
 
+/*
+ * Destroy the checkpoint.
+ *
+ * Call it once you are done with the syncronization.
+ */
+#define TST_CHECKPOINT_DESTROY(cleanup_fn) \
+	tst_checkpoint_destroy(__FILE__, __LINE__, cleanup_fn)
 
+void tst_checkpoint_destroy(const char *file, const int lineno,
+			    void (*cleanup_fn)(void));
 
 /*
  * Waits for wakeup.
diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c
index 79e49ac..2957f33 100644
--- a/lib/tst_checkpoint.c
+++ b/lib/tst_checkpoint.c
@@ -31,6 +31,7 @@
 #include "safe_macros.h"
 
 #define DEFAULT_MSEC_TIMEOUT 10000
+#define CHECKPOINT_BASE_FILE "checkpoint_futex_base_file"
 
 typedef volatile uint32_t futex_t;
 
@@ -67,7 +68,7 @@ void tst_checkpoint_init(const char *file, const int lineno,
 
 	page_size = getpagesize();
 
-	fd = SAFE_OPEN(cleanup_fn, "checkpoint_futex_base_file",
+	fd = SAFE_OPEN(cleanup_fn, CHECKPOINT_BASE_FILE,
 	               O_RDWR | O_CREAT, 0666);
 
 	SAFE_FTRUNCATE(cleanup_fn, fd, page_size);
@@ -78,6 +79,22 @@ void tst_checkpoint_init(const char *file, const int lineno,
 	SAFE_CLOSE(cleanup_fn, fd);
 }
 
+void tst_checkpoint_destroy(const char *file, const int lineno,
+			    void (*cleanup_fn)(void))
+{
+	if (!futexes || !page_size) {
+		tst_brkm(TBROK, cleanup_fn,
+			 "%s: %d checkpoints are not initialized",
+			 file, lineno);
+	}
+
+	SAFE_MUNMAP(cleanup_fn, (void *)futexes, page_size);
+
+	futexes = NULL;
+
+	SAFE_UNLINK(cleanup_fn, CHECKPOINT_BASE_FILE);
+}
+
 int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout)
 {
 	struct timespec timeout;
diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c
index c3cbd37..7b67d73 100644
--- a/testcases/kernel/syscalls/creat/creat07.c
+++ b/testcases/kernel/syscalls/creat/creat07.c
@@ -106,5 +106,7 @@ static void setup(void)
 
 static void cleanup(void)
 {
+	TST_CHECKPOINT_DESTROY(NULL);
+
 	tst_rmdir();
 }
-- 
1.7.1


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-05-27 14:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-25  8:09 [LTP] [RFC PATCH] tst_checkpoint_destroy Stanislav Kholmanskikh
2015-05-25  8:51 ` Cyril Hrubis
     [not found]   ` <55642D9D.6050707@oracle.com>
2015-05-26  8:40     ` Cyril Hrubis
2015-05-26  9:16       ` [LTP] [PATCH 1/2] Move futex_t into a common header Stanislav Kholmanskikh
2015-05-26  9:16         ` [LTP] [PATCH 2/2] Unmap the futexes backend file in tst_rmdir Stanislav Kholmanskikh
2015-05-26  9:58           ` Cyril Hrubis
2015-05-26 10:21             ` [LTP] [PATCH V2 " Stanislav Kholmanskikh
2015-05-27 14:04               ` Stanislav Kholmanskikh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox