Skip to contentSkip to conversation

tst_mkfs: add new parameter extra_opt to tst_mkfs function

PATCH Superseded Zorro Lang 2 participants 3 messages Mar 15, 2016 – Mar 16, 2016 Library code

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH v4 1/1 tst_mkfs: add new parameter extra_opt to tst_mkfs function

mmap16 always hit ETIMEDOUT error, if the test device is too large. mkfs on the device will take lots of time. So I want to make ext4 with an appointed size. But the [fs_size] need after the device name for ext4, e.g. "mkfs -t ext4 dev [fs_size]".

Due to above reason, add a new parameter extra_opt to tst_mkfs. extra_opt store the option need after the device name of mkfs. Then mmap16 can make ext4 with an appointed (small) size. And this change can make tst_mkfs() cover one more mkfs usage.

Due to I only find one option maybe need after the device name, so I use extra_opt. If there're more, the extra_opt should be changed to extra_opts[].

Because of tst_mkfs be changed, all testcases which use tst_mkfs add NULL parameter for extra_opt.

---
 doc/test-writing-guidelines.txt                    |  9 ++++++--
 include/test.h                                     |  6 +++--
 lib/tests/tst_device.c                             |  2 +-
 lib/tst_mkfs.c                                     | 27 +++++++++++++++++++---
 testcases/kernel/io/direct_io/dma_thread_diotest.c |  2 +-
 testcases/kernel/syscalls/access/access06.c        |  2 +-
 testcases/kernel/syscalls/acct/acct01.c            |  2 +-
 testcases/kernel/syscalls/chmod/chmod06.c          |  2 +-
 testcases/kernel/syscalls/chown/chown04.c          |  2 +-
 testcases/kernel/syscalls/creat/creat06.c          |  2 +-
 testcases/kernel/syscalls/fchmod/fchmod06.c        |  2 +-
 testcases/kernel/syscalls/fchown/fchown04.c        |  2 +-
 testcases/kernel/syscalls/ftruncate/ftruncate04.c  |  2 +-
 testcases/kernel/syscalls/inotify/inotify03.c      |  2 +-
 testcases/kernel/syscalls/lchown/lchown03.c        |  2 +-
 testcases/kernel/syscalls/link/link08.c            |  2 +-
 testcases/kernel/syscalls/linkat/linkat02.c        |  2 +-
 testcases/kernel/syscalls/mkdir/mkdir03.c          |  2 +-
 testcases/kernel/syscalls/mkdirat/mkdirat02.c      |  2 +-
 testcases/kernel/syscalls/mknod/mknod07.c          |  2 +-
 testcases/kernel/syscalls/mknodat/mknodat02.c      |  2 +-
 testcases/kernel/syscalls/mmap/mmap16.c            |  2 +-
 testcases/kernel/syscalls/mount/mount01.c          |  2 +-
 testcases/kernel/syscalls/mount/mount02.c          |  2 +-
 testcases/kernel/syscalls/mount/mount03.c          |  2 +-
 testcases/kernel/syscalls/mount/mount04.c          |  2 +-
 testcases/kernel/syscalls/mount/mount05.c          |  2 +-
 testcases/kernel/syscalls/mount/mount06.c          |  2 +-
 testcases/kernel/syscalls/open/open12.c            |  2 +-
 testcases/kernel/syscalls/quotactl/quotactl02.c    |  2 +-
 testcases/kernel/syscalls/rename/rename11.c        |  2 +-
 testcases/kernel/syscalls/renameat/renameat01.c    |  2 +-
 testcases/kernel/syscalls/rmdir/rmdir02.c          |  2 +-
 testcases/kernel/syscalls/umount/umount01.c        |  2 +-
 testcases/kernel/syscalls/umount/umount02.c        |  2 +-
 testcases/kernel/syscalls/umount/umount03.c        |  2 +-
 testcases/kernel/syscalls/umount2/umount2_01.c     |  2 +-
 testcases/kernel/syscalls/umount2/umount2_02.c     |  2 +-
 testcases/kernel/syscalls/umount2/umount2_03.c     |  2 +-
 testcases/kernel/syscalls/utime/utime06.c          |  2 +-
 testcases/kernel/syscalls/utimes/utimes01.c        |  2 +-
 41 files changed, 73 insertions(+), 45 deletions(-)
doc/test-writing-guidelines.txt +7 -2
index 1f260cb..fd57c6d 100644
@@ -906,15 +906,20 @@ NOTE: The default filesytem is hardcoded to 'ext2' in the sources and can be
 #include "test.h"
 
 void tst_mkfs(void (cleanup_fn)(void), const char *dev,
-              const char *fs_type, const char *const fs_opts[]);
+              const char *fs_type, const char *const fs_opts[]
+              const char *extra_opt);
 -------------------------------------------------------------------------------
 
 This function takes a path to a device, filesystem type and an array of extra
 options passed to mkfs.
 
-The extra options 'fs_opts' should either be 'NULL' if there are none, or a
+The fs options 'fs_opts' should either be 'NULL' if there are none, or a
 'NULL' terminated array of strings such as '{"-b", "1024", NULL}'.
 
+The extra option 'extra_opt' should either be 'NULL' if there are none, or
+a string such as "102400". 'extra_opt' will be passed after device name. e.g:
+mkfs -t ext4 -b 1024 /dev/sda1 102400
+
 2.2.16 Verifying a filesystem's free space
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
include/test.h +4 -2
index 5c78b1d..3f568d0 100644
@@ -316,10 +316,12 @@ int tst_system(const char *command);
  *
  * @dev: path to a device
  * @fs_type: filesystem type
- * @fs_opts: NULL or NULL terminated array of extra mkfs options
+ * @fs_opts: NULL or NULL terminated array of mkfs options
+ * @extra_opt: extra mkfs option which is passed after the device name
  */
 void tst_mkfs(void (cleanup_fn)(void), const char *dev,
-	      const char *fs_type, const char *const fs_opts[]);
+              const char *fs_type, const char *const fs_opts[],
+              const char *extra_opt);
 
 /*
  * Returns filesystem type to be used for the testing. Unless your test is
lib/tests/tst_device.c +1 -1
index 6a7925e..525bdc0 100644
@@ -46,7 +46,7 @@ int main(void)
 
 	printf("Test device='%s'\n", dev);
 
-	tst_mkfs(cleanup, dev, "ext2", NULL);
+	tst_mkfs(cleanup, dev, "ext2", NULL, NULL);
 
 	cleanup();
 	tst_exit();
lib/tst_mkfs.c +24 -3
index 5f959a4..685e6e2 100644
@@ -21,8 +21,19 @@
 
 #define OPTS_MAX 32
 
+/*
+ * tst_mkfs: mkfs.$fs_type on $dev with options $fs_opts and $extra_opt
+ *     cleanup_fn - run it when exit with error.
+ *     dev        - device path name
+ *     fs_opts    - store the options for mkfs (except -t fs_type). Set
+ *                  NULL if don't need options.
+ *     extra_opt  - extra mkfs option for mkfs, this option is passed
+ *                  after the device name, e.g. [fs_size] for ext4.
+ *                  Set NULL, if don't need option after device name.
+ */
 void tst_mkfs(void (cleanup_fn)(void), const char *dev,
-	      const char *fs_type, const char *const fs_opts[])
+              const char *fs_type, const char *const fs_opts[],
+              const char *extra_opt)
 {
 	int i, pos = 3;
 	const char *argv[OPTS_MAX] = {"mkfs", "-t", fs_type};
@@ -68,10 +79,20 @@ void tst_mkfs(void (cleanup_fn)(void), const char *dev,
 	}
 
 	argv[pos++] = dev;
+
+	if (extra_opt) {
+		argv[pos++] = extra_opt;
+
+		if (pos + 1 > OPTS_MAX) {
+			tst_brkm(TBROK, cleanup_fn,
+			         "Too much mkfs options");
+		}
+	}
+
 	argv[pos] = NULL;
 
-	tst_resm(TINFO, "Formatting %s with %s extra opts='%s'",
-		 dev, fs_type, fs_opts_str);
+	tst_resm(TINFO, "Formatting %s with %s opts='%s' extra opts='%s'",
+	         dev, fs_type, fs_opts_str, extra_opt ? extra_opt : "");
 	tst_run_cmd(cleanup_fn, argv, "/dev/null", NULL, 0);
 }
 
testcases/kernel/io/direct_io/dma_thread_diotest.c +1 -1
index 50b2222..80fbed4 100644
@@ -397,7 +397,7 @@ static void setup(void)
 			tst_brkm(TCONF, NULL,
 				 "you must specify a big blockdevice(>1.3G)");
 		} else {
-			tst_mkfs(NULL, device, "ext3", NULL);
+			tst_mkfs(NULL, device, "ext3", NULL, NULL);
 		}
 
 		if (mount(device, MNT_POINT, "ext3", 0, NULL) < 0) {
testcases/kernel/syscalls/access/access06.c +1 -1
index 59273bb..82044fe 100644
@@ -93,7 +93,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
 
 	TEST_PAUSE;
testcases/kernel/syscalls/acct/acct01.c +1 -1
index d405a3e..9fce925 100644
@@ -150,7 +150,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
 	if (mount(device, "mntpoint", fs_type, 0, NULL) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/chmod/chmod06.c +1 -1
index 3857bf5..66db797 100644
@@ -192,7 +192,7 @@ void setup(void)
 	SAFE_CHMOD(cleanup, DIR_TEMP, FILE_MODE);
 	SAFE_TOUCH(cleanup, "t_file", MODE_RWX, NULL);
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
 
testcases/kernel/syscalls/chown/chown04.c +1 -1
index 311889b..e959ae4 100644
@@ -149,7 +149,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	TEST_PAUSE;
 
testcases/kernel/syscalls/creat/creat06.c +1 -1
index 11b4c61..8100d92 100644
@@ -179,7 +179,7 @@ static void setup(void)
 	SAFE_SYMLINK(cleanup, TEST7_FILE, "test_file_eloop2");
 	SAFE_SYMLINK(cleanup, "test_file_eloop2", TEST7_FILE);
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, "mntpoint", 0777);
 	if (mount(device, "mntpoint", fs_type, MS_RDONLY, NULL) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/fchmod/fchmod06.c +1 -1
index a2a93ce..a08d43f 100644
@@ -127,7 +127,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, "mntpoint", 0755);
 
testcases/kernel/syscalls/fchown/fchown04.c +1 -1
index 0619375..0f0194f 100644
@@ -113,7 +113,7 @@ static void setup(void)
 
 	fd1 = SAFE_OPEN(cleanup, "tfile_1", O_RDWR | O_CREAT, 0666);
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
 	if (mount(device, "mntpoint", fs_type, 0, NULL) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/ftruncate/ftruncate04.c +1 -1
index 2136227..1cf8846 100644
@@ -240,7 +240,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MOUNT(NULL, device, MOUNT_DIR, fs_type, MS_MANDLOCK, NULL);
 	mount_flag = 1;
testcases/kernel/syscalls/inotify/inotify03.c +1 -1
index 36803d8..f73a891 100644
@@ -178,7 +178,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	if (mkdir(mntpoint, DIR_MODE) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup, "mkdir(%s, %#o) failed",
testcases/kernel/syscalls/lchown/lchown03.c +1 -1
index ab5aced..08612cf 100644
@@ -107,7 +107,7 @@ static void setup(void)
 	for (i = 0; i < 43; i++)
 		strcat(test_eloop, "/test_eloop");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, TEST_EROFS, DIR_MODE);
 	if (mount(device, TEST_EROFS, fs_type, MS_RDONLY, NULL) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/link/link08.c +1 -1
index b06919e..f763c46 100644
@@ -143,7 +143,7 @@ static void setup(void)
 	for (i = 0; i < 43; i++)
 		strcat(test_file4, "/test_eloop");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
 	if (mount(device, MNT_POINT, fs_type, 0, NULL) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/linkat/linkat02.c +1 -1
index e9a752a..4c31dd9 100644
@@ -171,7 +171,7 @@ static void setup(void)
 	SAFE_MKDIR(cleanup, "./tmp", DIR_MODE);
 	SAFE_TOUCH(cleanup, TEST_EACCES, 0666, NULL);
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
 
 	if (mount(device, "mntpoint", fs_type, 0, NULL) < 0) {
testcases/kernel/syscalls/mkdir/mkdir03.c +1 -1
index ed6693f..0b6114f 100644
@@ -122,7 +122,7 @@ static void setup(void)
 	for (i = 0; i < 43; i++)
 		strcat(loop_dir, "/test_eloop");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
 	if (mount(device, MNT_POINT, fs_type, MS_RDONLY, NULL) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/mkdirat/mkdirat02.c +1 -1
index c929043..f9d9240 100644
@@ -116,7 +116,7 @@ static void setup(void)
 	for (i = 0; i < 43; i++)
 		strcat(test_file2, "/test_eloop");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, "test_dir/mntpoint", DIR_MODE);
 	if (mount(device, "test_dir/mntpoint", fs_type, MS_RDONLY, NULL) < 0) {
testcases/kernel/syscalls/mknod/mknod07.c +1 -1
index bc9a07a..2ea50c0 100644
@@ -123,7 +123,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to acquire device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	TEST_PAUSE;
 
testcases/kernel/syscalls/mknodat/mknodat02.c +1 -1
index f6368fa..7cbde72 100644
@@ -124,7 +124,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to acquire device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	TEST_PAUSE;
 
testcases/kernel/syscalls/mmap/mmap16.c +1 -1
index c5828ea..494cd93 100644
@@ -158,7 +158,7 @@ static void setup(void)
 	device = tst_acquire_device(cleanup);
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
-	tst_mkfs(cleanup, device, fs_type, fs_opts);
+	tst_mkfs(cleanup, device, fs_type, fs_opts, "10240");
 
 	SAFE_MKDIR(cleanup, MNTPOINT, 0755);
 	/*
testcases/kernel/syscalls/mount/mount01.c +1 -1
index 53cf57f..0850aa0 100644
@@ -83,7 +83,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
 
testcases/kernel/syscalls/mount/mount02.c +1 -1
index 916c35e..3d98028 100644
@@ -186,7 +186,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, mntpoint, DIR_MODE);
 
testcases/kernel/syscalls/mount/mount03.c +1 -1
index 1db2383..b46753a 100644
@@ -355,7 +355,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, mntpoint, DIR_MODE);
 
testcases/kernel/syscalls/mount/mount04.c +1 -1
index 6dde3fc..f348973 100644
@@ -98,7 +98,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	ltpuser = SAFE_GETPWNAM(cleanup, nobody_uid);
 	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
testcases/kernel/syscalls/mount/mount05.c +1 -1
index 5c9e09e..bd664fd 100644
@@ -104,7 +104,7 @@ void setup(void)
 	SAFE_MKDIR(cleanup, mntpoint_des, DIR_MODE);
 
 	if (dflag) {
-		tst_mkfs(NULL, device, fstype, NULL);
+		tst_mkfs(NULL, device, fstype, NULL, NULL);
 
 		if (mount(device, mntpoint_src, fstype, 0, NULL) == -1)
 			tst_brkm(TBROK | TERRNO, cleanup, "mount failed");
testcases/kernel/syscalls/mount/mount06.c +1 -1
index 9350574..343e33a 100644
@@ -129,7 +129,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	if (getcwd(path_name, sizeof(path_name)) == NULL)
 		tst_brkm(TBROK, cleanup, "getcwd failed");
testcases/kernel/syscalls/open/open12.c +1 -1
index 5bbf9ee..c34ae45 100644
@@ -107,7 +107,7 @@ static void setup(void)
 			goto end;
 		}
 
-		tst_mkfs(cleanup, device, fs_type, NULL);
+		tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 		SAFE_MOUNT(cleanup, device, MNTPOINT, fs_type, MS_STRICTATIME, NULL);
 		mount_flag = 1;
testcases/kernel/syscalls/quotactl/quotactl02.c +1 -1
index 9ca77d1..af44f78 100644
@@ -207,7 +207,7 @@ static void setup(void)
 	if (!block_dev)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, block_dev, "xfs", NULL);
+	tst_mkfs(cleanup, block_dev, "xfs", NULL, NULL);
 
 	if (mount(block_dev, mntpoint, "xfs", 0, "uquota") < 0)
 		tst_brkm(TFAIL | TERRNO, NULL, "mount(2) fail");
testcases/kernel/syscalls/rename/rename11.c +1 -1
index 12c97fb..8aebb31 100644
@@ -104,7 +104,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, MNTPOINT, 0755);
 	if (mount(device, MNTPOINT, fs_type, 0, NULL) < 0) {
testcases/kernel/syscalls/renameat/renameat01.c +1 -1
index f4cd51b..918df48 100644
@@ -183,7 +183,7 @@ static void setup(void)
 	for (i = 0; i < 43; i++)
 		strcat(looppathname, TESTDIR2);
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, MNTPOINT, DIRMODE);
 	if (mount(device, MNTPOINT, fs_type, 0, NULL) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/rmdir/rmdir02.c +1 -1
index 0492666..8fafaf2 100644
@@ -137,7 +137,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to acquire device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
 	if (mount(device, MNTPOINT, fs_type, 0, NULL) == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/umount/umount01.c +1 -1
index 13b1567..52a55c9 100644
@@ -93,7 +93,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	if (mkdir(mntpoint, DIR_MODE) < 0) {
 		tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) failed; "
testcases/kernel/syscalls/umount/umount02.c +1 -1
index fbd5399..28a7252 100644
@@ -117,7 +117,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	memset(long_path, 'a', PATH_MAX + 1);
 
testcases/kernel/syscalls/umount/umount03.c +1 -1
index add6691..e0b36e5 100644
@@ -99,7 +99,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
 
testcases/kernel/syscalls/umount2/umount2_01.c +1 -1
index 86ea4a4..7376037 100644
@@ -78,7 +78,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
 
testcases/kernel/syscalls/umount2/umount2_02.c +1 -1
index 9ee2f02..f6782a1 100644
@@ -115,7 +115,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
 
testcases/kernel/syscalls/umount2/umount2_03.c +1 -1
index 217c5d1..571f389 100644
@@ -96,7 +96,7 @@ static void setup(void)
 	if (!device)
 		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
 
testcases/kernel/syscalls/utime/utime06.c +1 -1
index 66ba3d8..0e67d2e 100644
@@ -119,7 +119,7 @@ static void setup(void)
 	if (!dev)
 		tst_brkm(TCONF, cleanup, "Failed to acquire test device");
 
-	tst_mkfs(cleanup, dev, fs_type, NULL);
+	tst_mkfs(cleanup, dev, fs_type, NULL, NULL);
 
 	SAFE_MKDIR(cleanup, MNT_POINT, 0644);
 	if (mount(dev, MNT_POINT, fs_type, MS_RDONLY, NULL) < 0) {
testcases/kernel/syscalls/utimes/utimes01.c +1 -1
index e66f69e..3a9bd96 100644
@@ -139,7 +139,7 @@ static void setup(void)
 	SAFE_CHOWN(cleanup, TESTFILE2, ltpuser->pw_uid,
 		ltpuser->pw_gid);
 
-	tst_mkfs(cleanup, device, fs_type, NULL);
+	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
 	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
 	if (mount(device, MNTPOINT, fs_type, 0, NULL) == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup,
Signature · 1 line
2.5.0
#1 lore raw

PATCH v4 1/1 tst_mkfs: add new parameter extra_opt to tst_mkfs function

Hi!

Quoted 10 lines

mmap16 always hit ETIMEDOUT error, if the test device is too large. mkfs on the device will take lots of time. So I want to make ext4 with an appointed size. But the [fs_size] need after the device name for ext4, e.g. "mkfs -t ext4 dev [fs_size]".

Due to above reason, add a new parameter extra_opt to tst_mkfs. extra_opt store the option need after the device name of mkfs. Then mmap16 can make ext4 with an appointed (small) size. And this change can make tst_mkfs() cover one more mkfs usage.

Quoted 6 lines

Due to I only find one option maybe need after the device name, so I use extra_opt. If there're more, the extra_opt should be changed to extra_opts[].

Because of tst_mkfs be changed, all testcases which use tst_mkfs add NULL parameter for extra_opt.

I've changed wording here a bit.

Quoted 5 lines
lib/tst_mkfs.c +5 -0
+/*
+ * tst_mkfs: mkfs.$fs_type on $dev with options $fs_opts and $extra_opt
+ *     cleanup_fn - run it when exit with error.
+ *     dev        - device path name
+ *     fs_opts    - store the options for mkfs (except -t fs_type). Set

lib/tst_mkfs.c line 37

Quoted 10 lines
lib/tst_mkfs.c +7 -1
+ *                  NULL if don't need options.
+ *     extra_opt  - extra mkfs option for mkfs, this option is passed
+ *                  after the device name, e.g. [fs_size] for ext4.
+ *                  Set NULL, if don't need option after device name.
+ */
 void tst_mkfs(void (cleanup_fn)(void), const char *dev,
-	      const char *fs_type, const char *const fs_opts[])
+              const char *fs_type, const char *const fs_opts[],
+              const char *extra_opt)
 {

And removed this comment from the C source file since we have documentaion and comment in the header file which is more than enough. (Since we have to keep the implementaion and documentation in sync
having it just in two places is better than three...).

And pushed, thanks.

BTW, whith this patch the mmap test runs in 3 seconds instead of 10 when
the default 100MB device is used which is nice iprovement.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#2 lore raw

PATCH v4 1/1 tst_mkfs: add new parameter extra_opt to tst_mkfs function

Quoted 32 lines · Cyril Hrubis

Hi!

Quoted 10 lines

mmap16 always hit ETIMEDOUT error, if the test device is too large. mkfs on the device will take lots of time. So I want to make ext4 with an appointed size. But the [fs_size] need after the device name for ext4, e.g. "mkfs -t ext4 dev [fs_size]".

Due to above reason, add a new parameter extra_opt to tst_mkfs. extra_opt store the option need after the device name of mkfs. Then mmap16 can make ext4 with an appointed (small) size. And this change can make tst_mkfs() cover one more mkfs usage.

Quoted 6 lines

Due to I only find one option maybe need after the device name, so I use extra_opt. If there're more, the extra_opt should be changed to extra_opts[].

Because of tst_mkfs be changed, all testcases which use tst_mkfs add NULL parameter for extra_opt.

I've changed wording here a bit.

Quoted 12 lines
lib/tst_mkfs.c +10 -1
+/*
+ * tst_mkfs: mkfs.$fs_type on $dev with options $fs_opts and $extra_opt
+ *     cleanup_fn - run it when exit with error.
+ *     dev        - device path name
+ *     fs_opts    - store the options for mkfs (except -t fs_type). Set
+ *                  NULL if don't need options.
+ *     extra_opt  - extra mkfs option for mkfs, this option is passed
+ *                  after the device name, e.g. [fs_size] for ext4.
+ *                  Set NULL, if don't need option after device name.
+ */
 void tst_mkfs(void (cleanup_fn)(void), const char *dev,
-	      const char *fs_type, const char *const fs_opts[])
Quoted 8 lines

lib/tst_mkfs.c line 37

Quoted 3 lines
lib/tst_mkfs.c +2 -0
+              const char *fs_type, const char *const fs_opts[],
+              const char *extra_opt)
 {

And removed this comment from the C source file since we have documentaion and comment in the header file which is more than enough. (Since we have to keep the implementaion and documentation in sync
having it just in two places is better than three...).

Yes, you're right. I wrote too many comments to describe one thing:-P

Quoted 5 lines

And pushed, thanks.

BTW, whith this patch the mmap test runs in 3 seconds instead of 10 when
the default 100MB device is used which is nice iprovement.

That's my pleasure to see this improvement. I think if all testcases think about limit the fs size when they need to full the whole fs, that will be a good habit:-)

Thanks for your review too.

Zorro

Quoted 1 line