public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [RFC] [PATCH 01/15] lib/tst_mkfs: Clear first 512k of the device
@ 2017-09-05 16:09 Cyril Hrubis
  2017-09-05 16:09 ` [LTP] [RFC] [PATCH 02/15] lib: Add interface to list supported filesystems Cyril Hrubis
                   ` (14 more replies)
  0 siblings, 15 replies; 21+ messages in thread
From: Cyril Hrubis @ 2017-09-05 16:09 UTC (permalink / raw)
  To: ltp

If we cal tst_mkfs() from a test more than once we end up with the very
same bug we already fixed by clearing the device in
tst_acquire_device(), i.e. some mkfs programs will not format it when
there is a valid FS signature there.

So this commit moves the code to clear up the first 512k of the device
from tst_acquire_device() to the tst_mkfs() where it rightfully belongs.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/tst_device.c | 9 +--------
 lib/tst_mkfs.c   | 6 ++++++
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/tst_device.c b/lib/tst_device.c
index 936bbfd03..c0d689dde 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -244,15 +244,8 @@ const char *tst_acquire_device__(unsigned int size)
 
 		ltp_dev_size = ltp_dev_size/1024/1024;
 
-		if (acq_dev_size <= ltp_dev_size) {
-			if (tst_fill_file(dev, 0, 1024, 512)) {
-				tst_resm(TWARN | TERRNO,
-					 "Failed to clear the first 512k of %s",
-					 dev);
-			}
-
+		if (acq_dev_size <= ltp_dev_size)
 			return dev;
-		}
 
 		tst_resm(TINFO, "Skipping $LTP_DEV size %"PRIu64"MB, requested size %uMB",
 				ltp_dev_size, acq_dev_size);
diff --git a/lib/tst_mkfs.c b/lib/tst_mkfs.c
index f2e40ecd6..a63ee5e68 100644
--- a/lib/tst_mkfs.c
+++ b/lib/tst_mkfs.c
@@ -75,6 +75,12 @@ void tst_mkfs_(const char *file, const int lineno, void (cleanup_fn)(void),
 
 	argv[pos] = NULL;
 
+	if (tst_fill_file(dev, 0, 1024, 512)) {
+		tst_brkm(TBROK, cleanup_fn,
+			 "Failed to clear 512k block on %s", dev);
+		return;
+	}
+
 	tst_resm(TINFO, "Formatting %s with %s opts='%s' extra opts='%s'",
 	         dev, fs_type, fs_opts_str, extra_opt ? extra_opt : "");
 	ret = tst_run_cmd(cleanup_fn, argv, "/dev/null", NULL, 1);
-- 
2.13.0


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

end of thread, other threads:[~2017-09-07  9:13 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-05 16:09 [LTP] [RFC] [PATCH 01/15] lib/tst_mkfs: Clear first 512k of the device Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 02/15] lib: Add interface to list supported filesystems Cyril Hrubis
2017-09-07  7:48   ` Jan Stancek
2017-09-07  8:25   ` Jan Stancek
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 03/15] SAFE_MOUNT: Handle FUSE mounts as well Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 04/15] lib/tst_test: Add .all_filesystems flag Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 05/15] lib/tst_fs: Add tst_fill_fs() Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 06/15] syscalls/fallocate05: New test Cyril Hrubis
2017-09-07  8:51   ` Jan Stancek
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 07/15] syscalls/msync04: Run test for all filesystems Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 08/15] syscalls/fallocate04: Convert to the new library Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 09/15] syscalls/fallocate04: Run test for all filesystems Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 10/15] syscalls/setxattr01: Convert to the new library Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 11/15] syscalls/setxattr01: Run test for all filesystems Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 12/15] syscallse/setxattr02: Convert to the new library Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 13/15] syscalls/fsync01: " Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 14/15] syscalls/fsync01: Run test for all filesystems Cyril Hrubis
2017-09-05 16:09 ` [LTP] [RFC] [PATCH 15/15] fs/fs_fill: Add a test to fill a FS in a few threads Cyril Hrubis
2017-09-07  9:13   ` Jan Stancek
2017-09-07  7:42 ` [LTP] [RFC] [PATCH 01/15] lib/tst_mkfs: Clear first 512k of the device Jan Stancek
2017-09-07  8:34   ` Cyril Hrubis

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