All of lore.kernel.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: MTD list <linux-mtd@lists.infradead.org>
Cc: Adrian Hunter <adrian.hunter@nokia.com>
Subject: [PATCH 12/27] fs-tests: integck: move more variables to fsinfo
Date: Wed, 13 Apr 2011 18:18:52 +0300	[thread overview]
Message-ID: <1302707947-6143-13-git-send-email-dedekind1@gmail.com> (raw)
In-Reply-To: <1302707947-6143-1-git-send-email-dedekind1@gmail.com>

From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Aggregate all the information about the tested file-system in
the fsinf object for better readability and cleanness. Move
'can_mmap' and 'check_nospc_files' there as well.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 tests/fs-tests/integrity/integck.c |   45 ++++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index e7a3547..e29db49 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -56,13 +56,21 @@ static struct {
  *
  * max_name_len: maximum file name length
  * page_size: memory page size to use with 'mmap()'
+ * nospc_size_ok: file size is updated even if the write operation failed with
+ *                ENOSPC error
+ * can_mmap: file-system supports share writable 'mmap()' operation
  * fstype: file-system type (e.g., "ubifs")
  */
 static struct {
 	int max_name_len;
 	int page_size;
+	unsigned int nospc_size_ok:1;
+	unsigned int can_mmap:1;
 	const char *fstype;
-} fsinfo;
+} fsinfo = {
+	.nospc_size_ok = 1,
+	.can_mmap = 1,
+};
 
 /* Structures to store data written to the test file system,
    so that we can check whether the file system is correct. */
@@ -160,11 +168,6 @@ static uint64_t initial_free_space = 0; /* Free space on file system when
 					   test starts */
 static unsigned log10_initial_free_space = 0; /* log10 of initial_free_space */
 
-static int check_nospc_files = 1; /* Also check data in files that incurred a
-				     "no space" error */
-
-static int can_mmap = 1; /* Can write via mmap */
-
 static unsigned int check_run_no;
 
 /*
@@ -810,7 +813,7 @@ static int file_ftruncate(struct file_info *file, int fd, off_t new_length)
 		CHECK(errno = ENOSPC);
 		file->no_space_error = 1;
 		/* Delete errored files */
-		if (!check_nospc_files)
+		if (!fsinfo.nospc_size_ok)
 			file_delete(file);
 		return 0;
 	}
@@ -891,7 +894,8 @@ static void file_write(struct file_info *file, int fd)
 	unsigned seed;
 	int truncate = 0;
 
-	if (can_mmap && !full && !file->deleted && tests_random_no(100) == 1) {
+	if (fsinfo.can_mmap && !full && !file->deleted &&
+	    tests_random_no(100) == 1) {
 		file_mmap_write(file);
 		return;
 	}
@@ -910,7 +914,7 @@ static void file_write(struct file_info *file, int fd)
 		file_write_info(file, offset, actual, seed);
 
 	/* Delete errored files */
-	if (!check_nospc_files && file->no_space_error) {
+	if (!fsinfo.nospc_size_ok && file->no_space_error) {
 		file_delete(file);
 		return;
 	}
@@ -1173,7 +1177,7 @@ static void file_check(struct file_info *file, int fd)
 	struct stat st;
 
 	/* Do not check files that have errored */
-	if (!check_nospc_files && file->no_space_error)
+	if (!fsinfo.nospc_size_ok && file->no_space_error)
 		return;
 	/* Do not check the same file twice */
 	if (file->check_run_no == check_run_no)
@@ -1856,7 +1860,7 @@ static void operate_on_an_open_file(void)
 		}
 	}
 	/* Close any open files that have errored */
-	if (!check_nospc_files) {
+	if (!fsinfo.nospc_size_ok) {
 		ofi = open_files;
 		while (ofi) {
 			if (ofi->fdi->file->no_space_error) {
@@ -2052,6 +2056,16 @@ static void get_tested_fs_info(void)
 	/* Get memory page size for 'mmap()' */
 	fsinfo.page_size = sysconf(_SC_PAGE_SIZE);
 	CHECK(fsinfo.page_size > 0);
+
+	/*
+	 * JFFS2 does not support shared writable mmap and it may report
+	 * incorrect file size after "no space" errors.
+	 */
+	if (strcmp(fsinfo.fstype, "jffs2") == 0) {
+		fsinfo.nospc_size_ok = 0;
+		fsinfo.can_mmap = 0;
+	}
+
 }
 
 static const char doc[] = PROGRAM_NAME " version " PROGRAM_VERSION
@@ -2144,15 +2158,6 @@ int main(int argc, char *argv[])
 	tests_file_system_mount_dir = (void *)args.mount_point;
 	tests_file_system_type = (void *)fsinfo.fstype;
 
-	/*
-	 * JFFS2 does not support shared writable mmap and it may report
-	 * incorrect file size after "no space" errors.
-	 */
-	if (strcmp(tests_file_system_type, "jffs2") == 0) {
-		check_nospc_files = 0;
-		can_mmap = 0;
-	}
-
 	/* Do the actual test */
 	ret = integck();
 	if (ret)
-- 
1.7.2.3

  parent reply	other threads:[~2011-04-13 15:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-13 15:18 [PATCH 00/27] mtd-utils: make integck test independent Artem Bityutskiy
2011-04-13 15:16 ` Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 01/27] fs-tests: integck: shrink dir_entry_info structure size Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 02/27] fs-tests: integck: shrink file_info " Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 03/27] fs-tests: integck: srink file_info structure even more Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 04/27] fs-tests: integck: abuse random_offset field nicer Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 05/27] fs-tests: integck: shrink write_info even more Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 06/27] fs-tests: integck: change tests defaults Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 07/27] fs-tests: integck: implement own parameters parsing Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 08/27] fs-tests: integck: clean-up copy_string Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 09/27] fs-tests: integck: get rid of tests_check_test_file_system Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 10/27] fs-tests: integck: make integck function return error Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 11/27] fs-tests: integck: move mem_page_size to fsinfo Artem Bityutskiy
2011-04-13 15:18 ` Artem Bityutskiy [this message]
2011-04-13 15:18 ` [PATCH 13/27] fs-tests: integck: add own get_free_space function Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 14/27] fs-tests: integck: move log10_initial_free to fsinfo Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 15/27] fs-tests: integck: remove trailing backslashes from mount point Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 16/27] fs-tests: integck: do not use tests_cat_pid Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 17/27] fs-tests: integck: clean up test directory creation Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 18/27] fs-tests: integck: do not use tests_clear_dir Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 19/27] fs-tests: integck: do not use space after cast Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 20/27] fs-tests: integck: prefer to check for success Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 21/27] fs-tests: integck: do not use tests_fs_is_rootfs Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 22/27] fs-tests: integck: do not use tests_remount Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 23/27] fs-tests: integck: do not use tests_get_total_space Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 24/27] fs-tests: integck: do not use global common variables Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 25/27] fs-tests: integck: do not use tests_random_no Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 26/27] fs-tests: integck: implement own version of CHECK Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 27/27] fs-tests: integck: do not expect max name length to be 256 Artem Bityutskiy

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=1302707947-6143-13-git-send-email-dedekind1@gmail.com \
    --to=dedekind1@gmail.com \
    --cc=adrian.hunter@nokia.com \
    --cc=linux-mtd@lists.infradead.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.