All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/35] fs-tests: integck: handle write errors
@ 2011-04-20 10:18 Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 01/35] fs-tests: integck: introduce power cut testing arguments Artem Bityutskiy
                   ` (34 more replies)
  0 siblings, 35 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

Hi,

this is the continuation of my effort to improve integck. This series
of patches teaches integck to not die immediately when a write error
happens.

Currently integck exits if any unexpected error occurs. However, I am
going to make it usable for power-cut emulation testing, so when UBI
decides to emulate a power-cut and all write operation will return with
EROFS error, the test will also exit. So this patch-set teaches all
functions which do FS modifications to return an error up to the caller
if the operation fails. Then the error propagated to the main() function,
which currently just exits. But the plan is:

1. Make 'main()' unmount UBIFS, detach UBI, attach UBI back, mount UBIFS back.
2. Go through all files which were synchronized before the emulated power
   cut and check that the contents of these file is correct.
3. Restart the test.

And then the plan is to implement unstable bits emulation in UBI and run
this test, and catch bugs, and fix this.

So, this is just a preparation. The integck code is a bit dirty and was
written using "quick programming" approach. This patch-set tries to also
clean up the code a little bit.

Additionally, this patch-set fixes the huge amount of memory leaks the
test has had, and also lessens the memory consumption.

And finally, I tried to split the patches nicely, but I do not have much
time so the split is far far not ideal. I think it is good enough, though,
taking into account that there are only 2 users of this test I know.

Artem.

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

* [PATCH 01/35] fs-tests: integck: introduce power cut testing arguments
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 02/35] fs-tests: integck: check deletion errors in rm_minus_rf_dir Artem Bityutskiy
                   ` (33 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Introduce new command line arguments for power cut testing:
-p to enable the power cut testing mode and -v to be verbose
about the errors. The real functionality is not implemented
so far.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 61fb12c..73b6622 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -65,6 +65,8 @@
 /* The variables below are set by command line arguments */
 static struct {
 	long repeat_cnt;
+	int power_cut_mode;
+	int verbose;
 	const char *mount_point;
 } args = {
 	.repeat_cnt = 1,
@@ -2339,18 +2341,29 @@ static const char doc[] = PROGRAM_NAME " version " PROGRAM_VERSION
 "and hardlinks, randomly writes and truncate files, sometimes makes holes in\n"
 "files, sometimes fsync()'s them. Then it un-mounts and re-mounts the test file\n"
 "system and checks the contents - everything (files, dirs, etc) should be there\n"
-"and the contents of the files should be correct.\n"
-"This is repeated a number of times (set with -n, default 1).";
+"and the contents of the files should be correct. This is repeated a number of\n"
+"times (set with -n, default 1).\n\n"
+"This test is also able to perform powe cut testing. The underlying file-system\n"
+"or the device driver should be able to emulate power-cuts, e.g., but switching\n"
+"to R/O mode at random points of time. And the file-system should return EROFS\n"
+"(read-only file-system error) for all operations which modify it. In this case\n"
+"this test program re-mounts the file-system and checks that all files and\n"
+"directories which have been successfully synchronized before the power cut are\n"
+"there and contains correct data. Then the test continues.\n";
 
 static const char optionsstr[] =
 "-n, --repeat=<count> repeat count, default is 1; zero value - repeat forever\n"
+"-p, --power-cut      power cut testing mode\n"
+"-v, --verbose        be verbose about failure during power cut testing\n"
 "-h, -?, --help       print help message\n"
 "-V, --version        print program version\n";
 
 static const struct option long_options[] = {
-	{ .name = "repeat",  .has_arg = 1, .flag = NULL, .val = 'n' },
-	{ .name = "help",    .has_arg = 0, .flag = NULL, .val = 'h' },
-	{ .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
+	{ .name = "repeat",    .has_arg = 1, .flag = NULL, .val = 'n' },
+	{ .name = "power-cut", .has_arg = 0, .flag = NULL, .val = 'p' },
+	{ .name = "verbose",   .has_arg = 0, .flag = NULL, .val = 'v' },
+	{ .name = "help",      .has_arg = 0, .flag = NULL, .val = 'h' },
+	{ .name = "version",   .has_arg = 0, .flag = NULL, .val = 'V' },
 	{ NULL, 0, NULL, 0},
 };
 
@@ -2365,7 +2378,7 @@ static int parse_opts(int argc, char * const argv[])
 	while (1) {
 		int key, error = 0;
 
-		key = getopt_long(argc, argv, "n:Vh?", long_options, NULL);
+		key = getopt_long(argc, argv, "n:pvVh?", long_options, NULL);
 		if (key == -1)
 			break;
 
@@ -2375,6 +2388,12 @@ static int parse_opts(int argc, char * const argv[])
 			if (error || args.repeat_cnt < 0)
 				return errmsg("bad repeat count: \"%s\"", optarg);
 			break;
+		case 'p':
+			args.power_cut_mode = 1;
+			break;
+		case 'v':
+			args.verbose = 1;
+			break;
 		case 'V':
 			fprintf(stderr, "%s\n", PROGRAM_VERSION);
 			exit(EXIT_SUCCESS);
-- 
1.7.2.3

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

* [PATCH 02/35] fs-tests: integck: check deletion errors in rm_minus_rf_dir
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 01/35] fs-tests: integck: introduce power cut testing arguments Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 03/35] fs-tests: integck: handle write failures in dir_new Artem Bityutskiy
                   ` (32 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Modify the 'rm_minus_rf_dir()' function to return -1 in case of any
errors during deletions. Make 'integck()' handle the errors. Also
introduce a 'pcv()' function to print error message if -v command
line option was specified.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 73b6622..dd1ba1c 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -62,6 +62,15 @@
 	}                                                        \
 } while(0)
 
+#define pcv(fmt, ...) do {                                        \
+	if (args.power_cut_mode) {                                \
+		int _err = errno;                                 \
+		errmsg(fmt, ##__VA_ARGS__);                       \
+		errmsg("error %d (%s) at %s:%d\n",                \
+		       _err, strerror(_err), __FILE__, __LINE__); \
+	}                                                         \
+} while(0)
+
 /* The variables below are set by command line arguments */
 static struct {
 	long repeat_cnt;
@@ -1989,10 +1998,11 @@ static void create_test_data(void)
 /*
  * Recursively remove a directory, just like "rm -rf" shell command.
  */
-void rm_minus_rf_dir(const char *dir_name)
+static int rm_minus_rf_dir(const char *dir_name)
 {
+	int ret;
 	DIR *dir;
-	struct dirent *entry;
+	struct dirent *dent;
 	char buf[PATH_MAX];
 
 	dir = opendir(dir_name);
@@ -2002,24 +2012,34 @@ void rm_minus_rf_dir(const char *dir_name)
 
 	for (;;) {
 		errno = 0;
-		entry = readdir(dir);
-		if (!entry) {
+		dent = readdir(dir);
+		if (!dent) {
 			CHECK(errno == 0);
 			break;
 		}
 
-		if (strcmp(entry->d_name, ".") &&
-		    strcmp(entry->d_name, "..")) {
-			if (entry->d_type == DT_DIR)
-				rm_minus_rf_dir(entry->d_name);
-			else
-				CHECK(unlink(entry->d_name) == 0);
+		if (strcmp(dent->d_name, ".") &&
+		    strcmp(dent->d_name, "..")) {
+			if (dent->d_type == DT_DIR)
+				rm_minus_rf_dir(dent->d_name);
+			else {
+				ret = unlink(dent->d_name);
+				if (ret) {
+					pcv("cannot unlink %s", dent->d_name);
+					return -1;
+				}
+			}
 		}
 	}
 
 	CHECK(chdir(buf) == 0);
 	CHECK(closedir(dir) == 0);
-	CHECK(rmdir(dir_name) == 0);
+	ret = rmdir(dir_name);
+	if (ret) {
+		pcv("cannot remove directory %s", dir_name);
+		return -1;
+	}
+	return 0;
 }
 
 static void update_test_data(void)
@@ -2146,13 +2166,18 @@ void remount_tested_fs(void)
  */
 static int integck(void)
 {
+	int ret;
 	int64_t rpt;
 
+	CHECK(chdir(fsinfo.mount_point) == 0);
+
 	/* Create our top directory */
 	if (chdir(fsinfo.test_dir) == 0) {
 		/* Remove it if it is already there */
 		CHECK(chdir("..") == 0);
-		rm_minus_rf_dir(fsinfo.test_dir);
+		ret = rm_minus_rf_dir(fsinfo.test_dir);
+		if (ret)
+			return -1;
 	}
 
 	top_dir = dir_new(NULL, fsinfo.test_dir);
@@ -2187,7 +2212,9 @@ static int integck(void)
 
 	/* Tidy up by removing everything */
 	close_open_files();
-	rm_minus_rf_dir(fsinfo.test_dir);
+	ret = rm_minus_rf_dir(fsinfo.test_dir);
+	if (ret)
+		return -1;
 
 	return 0;
 }
@@ -2403,7 +2430,6 @@ static int parse_opts(int argc, char * const argv[])
 			fprintf(stderr, "%s\n\n", doc);
 			fprintf(stderr, "%s\n", optionsstr);
 			exit(EXIT_SUCCESS);
-
 		case ':':
 			return errmsg("parameter is missing");
 
-- 
1.7.2.3

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

* [PATCH 03/35] fs-tests: integck: handle write failures in dir_new
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 01/35] fs-tests: integck: introduce power cut testing arguments Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 02/35] fs-tests: integck: check deletion errors in rm_minus_rf_dir Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 04/35] fs-tests: integck: handle errors in remount_tested_fs Artem Bityutskiy
                   ` (31 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Do not die in 'dir_new()' if it cannot create a new directory and
this is not because of ENOSPC. Return NULL for all errors.

Note, not all callers are ready to properly handle all errors so far.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index dd1ba1c..d138a7d 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -284,19 +284,12 @@ static char *cat_strings(const char *a, const char *b)
 static char *cat_paths(const char *a, const char *b)
 {
 	char *str;
-	size_t sz;
-	int as, bs;
-	size_t na, nb;
+	size_t sz, na, nb;
+	int as = 0, bs = 0;
 
-	if (a && !b)
-		return dup_string(a);
-	if (b && !a)
-		return dup_string(b);
-	if (!a && !b)
-		return NULL;
+	assert(a != NULL);
+	assert(b != NULL);
 
-	as = 0;
-	bs = 0;
 	na = strlen(a);
 	nb = strlen(b);
 	if (na && a[na - 1] == '/')
@@ -333,8 +326,7 @@ static void get_fs_space(uint64_t *total, uint64_t *free)
 
 static char *dir_path(struct dir_info *parent, const char *name)
 {
-	char *parent_path;
-	char *path;
+	char *parent_path, *path;
 
 	if (!parent)
 		return cat_paths(fsinfo.mount_point, name);
@@ -454,6 +446,12 @@ static void remove_dir_entry(struct dir_entry_info *entry)
 	free(entry);
 }
 
+/*
+ * Create a new directory "name" in the parent directory described by "parent"
+ * and add it to the in-memory list of directories. In case of success, returns
+ * a pointer to the new 'struct dir_info' object. Returns 'NULL' in case of
+ * failure.
+ */
 static struct dir_info *dir_new(struct dir_info *parent, const char *name)
 {
 	struct dir_info *dir;
@@ -461,8 +459,10 @@ static struct dir_info *dir_new(struct dir_info *parent, const char *name)
 
 	path = dir_path(parent, name);
 	if (mkdir(path, 0777) != 0) {
-		CHECK(errno == ENOSPC);
-		full = 1;
+		if (errno == ENOSPC)
+			full = 1;
+		else
+			pcv("cannot create directory %s", path);
 		free(path);
 		return NULL;
 	}
@@ -2167,7 +2167,7 @@ void remount_tested_fs(void)
 static int integck(void)
 {
 	int ret;
-	int64_t rpt;
+	long rpt;
 
 	CHECK(chdir(fsinfo.mount_point) == 0);
 
-- 
1.7.2.3

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

* [PATCH 04/35] fs-tests: integck: handle errors in remount_tested_fs
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (2 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 03/35] fs-tests: integck: handle write failures in dir_new Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 05/35] fs-tests: integck: handle errors when creating test data Artem Bityutskiy
                   ` (30 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'remount_tested_fs()' return error code when it fails
to mount the file-system.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index d138a7d..5b1adc1 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -2076,7 +2076,7 @@ static void update_test_data(void)
  * Re-mount the test file-system. This function randomly select how to
  * re-mount.
  */
-void remount_tested_fs(void)
+static int remount_tested_fs(void)
 {
 	char *wd_save;
 	int ret;
@@ -2105,13 +2105,15 @@ void remount_tested_fs(void)
 		flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT;
 		ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype,
 			    flags, fsinfo.mount_opts);
-		CHECK(ret == 0);
+		if (ret)
+			return -1;
 
 		flags = fsinfo.mount_flags | MS_REMOUNT;
 		flags &= ~((unsigned long)MS_RDONLY);
 		ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype,
 			    flags, fsinfo.mount_opts);
-		CHECK(ret == 0);
+		if (ret)
+			return -1;
 	}
 
 	if (um) {
@@ -2119,7 +2121,8 @@ void remount_tested_fs(void)
 			flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT;
 			ret = mount(fsinfo.fsdev, fsinfo.mount_point,
 				    fsinfo.fstype, flags, fsinfo.mount_opts);
-			CHECK(ret == 0);
+			if (ret)
+				return -1;
 		}
 
 		CHECK(umount(fsinfo.mount_point) != -1);
@@ -2128,18 +2131,21 @@ void remount_tested_fs(void)
 			ret = mount(fsinfo.fsdev, fsinfo.mount_point,
 				    fsinfo.fstype, fsinfo.mount_flags,
 				    fsinfo.mount_opts);
-			CHECK(ret == 0);
+			if (ret)
+				return -1;
 		} else {
 			ret = mount(fsinfo.fsdev, fsinfo.mount_point,
 				    fsinfo.fstype, fsinfo.mount_flags | MS_RDONLY,
 				    fsinfo.mount_opts);
-			CHECK(ret == 0);
+			if (ret)
+				return -1;
 
 			flags = fsinfo.mount_flags | MS_REMOUNT;
 			flags &= ~((unsigned long)MS_RDONLY);
 			ret = mount(fsinfo.fsdev, fsinfo.mount_point,
 				    fsinfo.fstype, flags, fsinfo.mount_opts);
-			CHECK(ret == 0);
+			if (ret)
+				return -1;
 		}
 	}
 
@@ -2147,18 +2153,21 @@ void remount_tested_fs(void)
 		flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT;
 		ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype,
 			    flags, fsinfo.mount_opts);
-		CHECK(ret == 0);
+		if (ret)
+			return -1;
 
 		flags = fsinfo.mount_flags | MS_REMOUNT;
 		flags &= ~((unsigned long)MS_RDONLY);
 		ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype,
 			    flags, fsinfo.mount_opts);
-		CHECK(ret == 0);
+		if (ret)
+			return -1;
 	}
 
 	/* Restore the previous working directory */
 	CHECK(chdir(wd_save) == 0);
 	free(wd_save);
+	return 0;
 }
 
 /*
@@ -2188,7 +2197,9 @@ static int integck(void)
 
 	if (fsinfo.is_rootfs) {
 		close_open_files();
-		remount_tested_fs();
+		ret = remount_tested_fs();
+		if (ret)
+			return -1;
 	}
 
 	/* Check everything */
@@ -2201,7 +2212,9 @@ static int integck(void)
 
 		if (!fsinfo.is_rootfs) {
 			close_open_files();
-			remount_tested_fs();
+			ret = remount_tested_fs();
+			if (ret)
+				return -1;
 		}
 
 		/* Check everything */
-- 
1.7.2.3

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

* [PATCH 05/35] fs-tests: integck: handle errors when creating test data
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (3 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 04/35] fs-tests: integck: handle errors in remount_tested_fs Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 06/35] fs-tests: integck: make more functions propogate error up Artem Bityutskiy
                   ` (29 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Make 'update_test_data()' and 'update_test_data()' check for errors
and return error in case of failure.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 5b1adc1..1703364 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1953,16 +1953,21 @@ static void operate_on_an_open_file(void)
 		}
 }
 
-static void do_an_operation(void)
+static int do_an_operation(void)
 {
 	/* Half the time operate on already open files */
 	if (random_no(100) < 50)
 		operate_on_dir(top_dir);
 	else
 		operate_on_an_open_file();
+
+	return 0;
 }
 
-static void create_test_data(void)
+/*
+ * Fill the tested file-system with random stuff.
+ */
+static int create_test_data(void)
 {
 	uint64_t i, n;
 
@@ -1971,28 +1976,77 @@ static void create_test_data(void)
 	full = 0;
 	operation_count = 0;
 	while (!full) {
-		do_an_operation();
-		++operation_count;
+		if (do_an_operation())
+			return -1;
+		operation_count += 1;
 	}
+
+	/* Drop to less than 90% full */
 	grow = 0;
 	shrink = 1;
-	/* Drop to less than 90% full */
 	n = operation_count / 40;
 	while (n--) {
-		uint64_t free;
-		uint64_t total;
-		for (i = 0; i < 10; ++i)
-			do_an_operation();
+		uint64_t free, total;
+
+		for (i = 0; i < 10; i++)
+			if (do_an_operation())
+				return -1;
+
 		get_fs_space(&total, &free);
 		if ((free * 100) / total >= 10)
 			break;
 	}
+
+	grow = 0;
+	shrink = 0;
+	full = 0;
+	n = operation_count * 2;
+	for (i = 0; i < n; i++)
+		if (do_an_operation())
+			return -1;
+
+	return 0;
+}
+
+/*
+ * Do more random operation on the tested file-system.
+ */
+static int update_test_data(void)
+{
+	uint64_t i, n;
+
+	grow = 1;
+	shrink = 0;
+	full = 0;
+	while (!full)
+		if (do_an_operation())
+			return -1;
+
+	/* Drop to less than 50% full */
+	grow = 0;
+	shrink = 1;
+	n = operation_count / 10;
+	while (n--) {
+		uint64_t free, total;
+
+		for (i = 0; i < 10; i++)
+			if (do_an_operation())
+				return -1;
+
+		get_fs_space(&total, &free);
+		if ((free * 100) / total >= 50)
+			break;
+	}
+
 	grow = 0;
 	shrink = 0;
 	full = 0;
 	n = operation_count * 2;
-	for (i = 0; i < n; ++i)
-		do_an_operation();
+	for (i = 0; i < n; i++)
+		if (do_an_operation())
+			return -1;
+
+	return 0;
 }
 
 /*
@@ -2042,36 +2096,6 @@ static int rm_minus_rf_dir(const char *dir_name)
 	return 0;
 }
 
-static void update_test_data(void)
-{
-	uint64_t i, n;
-
-	grow = 1;
-	shrink = 0;
-	full = 0;
-	while (!full)
-		do_an_operation();
-	grow = 0;
-	shrink = 1;
-	/* Drop to less than 50% full */
-	n = operation_count / 10;
-	while (n--) {
-		uint64_t free;
-		uint64_t total;
-		for (i = 0; i < 10; ++i)
-			do_an_operation();
-		get_fs_space(&total, &free);
-		if ((free * 100) / total >= 50)
-			break;
-	}
-	grow = 0;
-	shrink = 0;
-	full = 0;
-	n = operation_count * 2;
-	for (i = 0; i < n; ++i)
-		do_an_operation();
-}
-
 /**
  * Re-mount the test file-system. This function randomly select how to
  * re-mount.
@@ -2193,7 +2217,9 @@ static int integck(void)
 	if (!top_dir)
 		return -1;
 
-	create_test_data();
+	ret = create_test_data();
+	if (ret)
+		return -1;
 
 	if (fsinfo.is_rootfs) {
 		close_open_files();
@@ -2208,7 +2234,9 @@ static int integck(void)
 	check_deleted_files();
 
 	for (rpt = 0; args.repeat_cnt == 0 || rpt < args.repeat_cnt; ++rpt) {
-		update_test_data();
+		ret = update_test_data();
+		if (ret)
+			return -1;
 
 		if (!fsinfo.is_rootfs) {
 			close_open_files();
-- 
1.7.2.3

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

* [PATCH 06/35] fs-tests: integck: make more functions propogate error up
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (4 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 05/35] fs-tests: integck: handle errors when creating test data Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 07/35] fs-tests: integck: teach file_truncate return error code Artem Bityutskiy
                   ` (28 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'operate_on_open_file()', 'operate_on_an_open_file()', and
'do_an_operation()' propogate errors up.

Also move whole 'operate_on_file()' to a more logical place.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 1703364..4f39ce3 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1776,8 +1776,47 @@ static void symlink_remove(struct symlink_info *symlink)
 	free(path);
 }
 
-static void operate_on_dir(struct dir_info *dir);
-static void operate_on_file(struct file_info *file);
+static int operate_on_dir(struct dir_info *dir);
+
+/* Randomly select something to do with a file */
+static void operate_on_file(struct file_info *file)
+{
+	/* Try to keep at least 10 files open */
+	if (open_files_count < 10) {
+		file_open(file);
+		return;
+	}
+	/* Try to keep about 20 files open */
+	if (open_files_count < 20 && random_no(2) == 0) {
+		file_open(file);
+		return;
+	}
+	/* Try to keep up to 40 files open */
+	if (open_files_count < 40 && random_no(20) == 0) {
+		file_open(file);
+		return;
+	}
+	/* Occasionly truncate */
+	if (shrink && random_no(100) == 0) {
+		file_truncate_file(file);
+		return;
+	}
+	/* Mostly just write */
+	file_write_file(file);
+	/* Once in a while check it too */
+	if (random_no(100) == 1) {
+		int fd = -2;
+
+		if (file->links)
+			fd = -1;
+		else if (file->fds)
+			fd = file->fds->fd;
+		if (fd != -2) {
+			check_run_no += 1;
+			file_check(file, fd);
+		}
+	}
+}
 
 /* Randomly select something to do with a directory entry */
 static void operate_on_entry(struct dir_entry_info *entry)
@@ -1818,8 +1857,10 @@ static void operate_on_entry(struct dir_entry_info *entry)
 	}
 }
 
-/* Randomly select something to do with a directory */
-static void operate_on_dir(struct dir_info *dir)
+/*
+ * Randomly select something to do with a directory.
+ */
+static int operate_on_dir(struct dir_info *dir)
 {
 	struct dir_entry_info *entry;
 	struct file_info *file;
@@ -1849,54 +1890,17 @@ static void operate_on_dir(struct dir_info *dir)
 		if (entry)
 			operate_on_entry(entry);
 	}
-}
 
-/* Randomly select something to do with a file */
-static void operate_on_file(struct file_info *file)
-{
-	/* Try to keep at least 10 files open */
-	if (open_files_count < 10) {
-		file_open(file);
-		return;
-	}
-	/* Try to keep about 20 files open */
-	if (open_files_count < 20 && random_no(2) == 0) {
-		file_open(file);
-		return;
-	}
-	/* Try to keep up to 40 files open */
-	if (open_files_count < 40 && random_no(20) == 0) {
-		file_open(file);
-		return;
-	}
-	/* Occasionly truncate */
-	if (shrink && random_no(100) == 0) {
-		file_truncate_file(file);
-		return;
-	}
-	/* Mostly just write */
-	file_write_file(file);
-	/* Once in a while check it too */
-	if (random_no(100) == 1) {
-		int fd = -2;
-
-		if (file->links)
-			fd = -1;
-		else if (file->fds)
-			fd = file->fds->fd;
-		if (fd != -2) {
-			check_run_no += 1;
-			file_check(file, fd);
-		}
-	}
+	return 0;
 }
 
-/* Randomly select something to do with an open file */
-static void operate_on_open_file(struct fd_info *fdi)
+/*
+ * Randomly select something to do with an open file.
+ */
+static int operate_on_open_file(struct fd_info *fdi)
 {
-	unsigned int r;
+	unsigned int r = random_no(1000);
 
-	r = random_no(1000);
 	if (shrink && r < 5)
 		file_truncate(fdi->file, fdi->fd);
 	else if (r < 21)
@@ -1912,10 +1916,14 @@ static void operate_on_open_file(struct fd_info *fdi)
 				CHECK(fdatasync(fdi->fd) == 0);
 		}
 	}
+
+	return 0;
 }
 
-/* Select an open file at random */
-static void operate_on_an_open_file(void)
+/*
+ * Randomly select an open file and do a random operation on it.
+ */
+static int operate_on_an_open_file(void)
 {
 	unsigned int r;
 	struct open_file_info *ofi;
@@ -1928,9 +1936,10 @@ static void operate_on_an_open_file(void)
 		x &= 127;
 		if (x == 0) {
 			close_open_files();
-			return;
+			return 0;
 		}
 	}
+
 	/* Close any open files that have errored */
 	if (!fsinfo.nospc_size_ok) {
 		ofi = open_files;
@@ -1945,23 +1954,26 @@ static void operate_on_an_open_file(void)
 				ofi = ofi->next;
 		}
 	}
+
 	r = random_no(open_files_count);
-	for (ofi = open_files; ofi; ofi = ofi->next, --r)
+	for (ofi = open_files; ofi; ofi = ofi->next, r--)
 		if (!r) {
-			operate_on_open_file(ofi->fdi);
-			return;
+			return operate_on_open_file(ofi->fdi);
 		}
+
+	return 0;
 }
 
+/*
+ * Do a random file-system operation.
+ */
 static int do_an_operation(void)
 {
 	/* Half the time operate on already open files */
 	if (random_no(100) < 50)
-		operate_on_dir(top_dir);
+		return operate_on_dir(top_dir);
 	else
-		operate_on_an_open_file();
-
-	return 0;
+		return operate_on_an_open_file();
 }
 
 /*
-- 
1.7.2.3

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

* [PATCH 07/35] fs-tests: integck: teach file_truncate return error code
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (5 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 06/35] fs-tests: integck: make more functions propogate error up Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 08/35] fs-tests: integck: handle errors in file_delete Artem Bityutskiy
                   ` (27 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'file_truncate()' return an error code in case of failure.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 4f39ce3..06e33b5 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -880,17 +880,27 @@ static void get_offset_and_size(struct file_info *file,
 
 static void file_truncate_info(struct file_info *file, size_t new_length);
 
+/*
+ * Truncate a file to length 'new_length'. If there is no enough space to
+ * peform the operation, this function returns 1. Returns 0 on success and -1
+ * on failure.
+ */
 static int file_ftruncate(struct file_info *file, int fd, off_t new_length)
 {
 	if (ftruncate(fd, new_length) != 0) {
-		CHECK(errno = ENOSPC);
-		file->no_space_error = 1;
-		/* Delete errored files */
-		if (!fsinfo.nospc_size_ok)
-			file_delete(file);
-		return 0;
+		if (errno == ENOSPC) {
+			file->no_space_error = 1;
+			/* Delete errored files */
+			if (!fsinfo.nospc_size_ok)
+				file_delete(file);
+			return 1;
+		} else
+			pcv("cannot truncate file %s to %llu",
+			    file->name, (unsigned long long)new_length);
+		return -1;
 	}
-	return 1;
+
+	return 0;
 }
 
 static void file_mmap_write(struct file_info *file)
@@ -994,7 +1004,8 @@ static void file_write(struct file_info *file, int fd)
 
 	if (truncate) {
 		size_t new_length = offset + actual;
-		if (file_ftruncate(file, fd, new_length))
+
+		if (!file_ftruncate(file, fd, new_length))
 			file_truncate_info(file, new_length);
 	}
 }
@@ -1044,14 +1055,21 @@ static void file_truncate_info(struct file_info *file, size_t new_length)
 	file->length = new_length;
 }
 
-static void file_truncate(struct file_info *file, int fd)
+/*
+ * Truncate an open file randomly.
+ */
+static int file_truncate(struct file_info *file, int fd)
 {
-	size_t new_length;
+	int ret;
+	size_t new_length = random_no(file->length);
 
-	new_length = random_no(file->length);
 
-	if (file_ftruncate(file, fd, new_length))
+	ret = file_ftruncate(file, fd, new_length);
+	if (ret == -1)
+		return -1;
+	if (!ret)
 		file_truncate_info(file, new_length);
+	return 0;
 }
 
 static void file_truncate_file(struct file_info *file)
@@ -1902,7 +1920,7 @@ static int operate_on_open_file(struct fd_info *fdi)
 	unsigned int r = random_no(1000);
 
 	if (shrink && r < 5)
-		file_truncate(fdi->file, fdi->fd);
+		return file_truncate(fdi->file, fdi->fd);
 	else if (r < 21)
 		file_close(fdi);
 	else if (shrink && r < 121 && !fdi->file->deleted)
-- 
1.7.2.3

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

* [PATCH 08/35] fs-tests: integck: handle errors in file_delete
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (6 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 07/35] fs-tests: integck: teach file_truncate return error code Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 09/35] fs-tests: integck: handle all failures in operate_on_open_file Artem Bityutskiy
                   ` (26 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'file_delete()' and several other functions it calls
(like 'file_unlink()) to handle write errors and propagate the
up to the caller.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 06e33b5..7ccbcb1 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -476,8 +476,8 @@ static struct dir_info *dir_new(struct dir_info *parent, const char *name)
 	return dir;
 }
 
-static void file_delete(struct file_info *file);
-static void file_unlink(struct dir_entry_info *entry);
+static int file_delete(struct file_info *file);
+static int file_unlink(struct dir_entry_info *entry);
 static void symlink_remove(struct symlink_info *symlink);
 
 static void dir_remove(struct dir_info *dir)
@@ -576,20 +576,28 @@ static void file_close_all(struct file_info *file)
 	}
 }
 
-static void file_unlink(struct dir_entry_info *entry)
+/*
+ * Unlink a directory entry for a file.
+ */
+static int file_unlink(struct dir_entry_info *entry)
 {
 	struct file_info *file = entry->file;
 	char *path;
+	int ret;
 
 	path = dir_path(entry->parent, entry->name);
+	/* Unlink the file */
+	ret = unlink(path);
+	if (ret) {
+		pcv("cannot unlink file %s", path);
+		free(path);
+		return -1;
+	}
+	free(path);
 
 	/* Remove file entry from parent directory */
 	remove_dir_entry(entry);
 
-	/* Unlink the file */
-	CHECK(unlink(path) == 0);
-	free(path);
-
 	/* Free struct file_info if file is not open and not linked */
 	if (!file->fds && !file->links) {
 		struct write_info *w, *next;
@@ -604,6 +612,8 @@ static void file_unlink(struct dir_entry_info *entry)
 		free(file);
 	} else if (!file->links)
 		file->deleted = 1;
+
+	return 0;
 }
 
 static struct dir_entry_info *pick_entry(struct file_info *file)
@@ -630,7 +640,11 @@ static void file_unlink_file(struct file_info *file)
 	file_unlink(entry);
 }
 
-static void file_delete(struct file_info *file)
+/*
+ * Close all open descriptors for a file described by 'file' and delete it by
+ * unlinking all its hardlinks.
+ */
+static int file_delete(struct file_info *file)
 {
 	struct dir_entry_info *entry = file->links;
 
@@ -638,9 +652,12 @@ static void file_delete(struct file_info *file)
 	while (entry) {
 		struct dir_entry_info *next = entry->next_link;
 
-		file_unlink(entry);
+		if (file_unlink(entry))
+			return -1;
 		entry = next;
 	}
+
+	return 0;
 }
 
 static void file_info_display(struct file_info *file)
@@ -892,7 +909,8 @@ static int file_ftruncate(struct file_info *file, int fd, off_t new_length)
 			file->no_space_error = 1;
 			/* Delete errored files */
 			if (!fsinfo.nospc_size_ok)
-				file_delete(file);
+				if (file_delete(file))
+					return -1;
 			return 1;
 		} else
 			pcv("cannot truncate file %s to %llu",
@@ -970,17 +988,21 @@ static void file_mmap_write(struct file_info *file)
 	file_write_info(file, offset, size, seed);
 }
 
-static void file_write(struct file_info *file, int fd)
+/*
+ * Write random amount of data to a random offset in an open file or randomly
+ * choose to truncate it.
+ */
+static int file_write(struct file_info *file, int fd)
 {
 	off_t offset;
 	size_t size, actual;
 	unsigned seed;
-	int truncate = 0;
+	int ret, truncate = 0;
 
 	if (fsinfo.can_mmap && !full && !file->deleted &&
 	    random_no(100) == 1) {
 		file_mmap_write(file);
-		return;
+		return 0;
 	}
 
 	get_offset_and_size(file, &offset, &size);
@@ -997,30 +1019,38 @@ static void file_write(struct file_info *file, int fd)
 		file_write_info(file, offset, actual, seed);
 
 	/* Delete errored files */
-	if (!fsinfo.nospc_size_ok && file->no_space_error) {
-		file_delete(file);
-		return;
-	}
+	if (!fsinfo.nospc_size_ok && file->no_space_error)
+		return file_delete(file);
 
 	if (truncate) {
 		size_t new_length = offset + actual;
 
-		if (!file_ftruncate(file, fd, new_length))
+		ret = file_ftruncate(file, fd, new_length);
+		if (ret == -1)
+			return -1;
+		if (!ret)
 			file_truncate_info(file, new_length);
 	}
+
+	return 0;
 }
 
-static void file_write_file(struct file_info *file)
+/*
+ * Write random amount of data to a random offset in a file or randomly
+ * choose to truncate it.
+ */
+static int file_write_file(struct file_info *file)
 {
-	int fd;
+	int fd, ret;
 	char *path;
 
 	path = dir_path(file->links->parent, file->links->name);
 	fd = open(path, O_WRONLY);
 	CHECK(fd != -1);
-	file_write(file, fd);
+	ret = file_write(file, fd);
 	CHECK(close(fd) == 0);
 	free(path);
+	return ret;
 }
 
 static void file_truncate_info(struct file_info *file, size_t new_length)
@@ -1924,9 +1954,10 @@ static int operate_on_open_file(struct fd_info *fdi)
 	else if (r < 21)
 		file_close(fdi);
 	else if (shrink && r < 121 && !fdi->file->deleted)
-		file_delete(fdi->file);
+		return file_delete(fdi->file);
 	else {
-		file_write(fdi->file, fdi->fd);
+		if (file_write(fdi->file, fdi->fd))
+			return -1;
 		if (r >= 999) {
 			if (random_no(100) >= 50)
 				CHECK(fsync(fdi->fd) == 0);
-- 
1.7.2.3

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

* [PATCH 09/35] fs-tests: integck: handle all failures in operate_on_open_file
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (7 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 08/35] fs-tests: integck: handle errors in file_delete Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 10/35] fs-tests: integck: handle errors in file_mmap_write Artem Bityutskiy
                   ` (25 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Make 'operate_on_open_file()' to handle possible 'fsync()' and 'fdatasync()'
errors by returning -1 up to the caller.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 7ccbcb1..7348e14 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1947,26 +1947,33 @@ static int operate_on_dir(struct dir_info *dir)
  */
 static int operate_on_open_file(struct fd_info *fdi)
 {
+	int ret = 0;
 	unsigned int r = random_no(1000);
 
 	if (shrink && r < 5)
-		return file_truncate(fdi->file, fdi->fd);
+		ret = file_truncate(fdi->file, fdi->fd);
 	else if (r < 21)
 		file_close(fdi);
 	else if (shrink && r < 121 && !fdi->file->deleted)
-		return file_delete(fdi->file);
+		ret = file_delete(fdi->file);
 	else {
-		if (file_write(fdi->file, fdi->fd))
-			return -1;
-		if (r >= 999) {
-			if (random_no(100) >= 50)
-				CHECK(fsync(fdi->fd) == 0);
-			else
-				CHECK(fdatasync(fdi->fd) == 0);
+		ret = file_write(fdi->file, fdi->fd);
+		if (!ret && r >= 999) {
+			if (random_no(100) >= 50) {
+				ret = fsync(fdi->fd);
+				if (ret)
+					pcv("fsync failed for %s",
+					    fdi->file->name);
+			} else {
+				ret = fdatasync(fdi->fd);
+				if (ret)
+					pcv("fdatasync failed for %s",
+					    fdi->file->name);
+			}
 		}
 	}
 
-	return 0;
+	return ret;
 }
 
 /*
-- 
1.7.2.3

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

* [PATCH 10/35] fs-tests: integck: handle errors in file_mmap_write
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (8 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 09/35] fs-tests: integck: handle all failures in operate_on_open_file Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 11/35] fs-tests: integck: teach file_write_data return an error Artem Bityutskiy
                   ` (24 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'file_mmap_write()' to propagate failures up to the caller.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 7348e14..778e35c 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -921,26 +921,28 @@ static int file_ftruncate(struct file_info *file, int fd, off_t new_length)
 	return 0;
 }
 
-static void file_mmap_write(struct file_info *file)
+/*
+ * 'mmap()' a file and randomly select where to write data.
+ */
+static int file_mmap_write(struct file_info *file)
 {
 	size_t write_cnt = 0, r, i, len, size;
 	struct write_info *w = file->writes;
 	void *addr;
-	char *waddr;
+	char *waddr, *path;
 	off_t offs, offset;
-	unsigned seed;
+	unsigned int seed;
 	uint64_t free_space;
 	int fd;
-	char *path;
 
 	if (!file->links)
-		return;
+		return 0;
 	get_fs_space(NULL, &free_space);
 	if (!free_space)
-		return;
+		return 0;
 	/* Randomly pick a written area of the file */
 	if (!w)
-		return;
+		return 0;
 	while (w) {
 		write_cnt += 1;
 		w = w->next;
@@ -959,12 +961,15 @@ static void file_mmap_write(struct file_info *file)
 	path = dir_path(file->links->parent, file->links->name);
 	fd = open(path, O_RDWR);
 	CHECK(fd != -1);
-	free(path);
 
 	/* mmap it */
 	addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offs);
 	CHECK(close(fd) == 0);
-	CHECK(addr != MAP_FAILED);
+	if (addr == MAP_FAILED) {
+		pcv("cannot mmap file %s", path);
+		free(path);
+		return -1;
+	}
 
 	/* Randomly select a part of the mmapped area to write */
 	size = random_no(w->size);
@@ -982,10 +987,16 @@ static void file_mmap_write(struct file_info *file)
 		waddr[i] = rand();
 
 	/* Unmap it */
-	CHECK(munmap(addr, len) == 0);
+	if (munmap(addr, len)) {
+		pcv("cannot unmap file %s", path);
+		free(path);
+		return -1;
+	}
 
 	/* Record what was written */
 	file_write_info(file, offset, size, seed);
+	free(path);
+	return 0;
 }
 
 /*
@@ -1000,10 +1011,8 @@ static int file_write(struct file_info *file, int fd)
 	int ret, truncate = 0;
 
 	if (fsinfo.can_mmap && !full && !file->deleted &&
-	    random_no(100) == 1) {
-		file_mmap_write(file);
-		return 0;
-	}
+	    random_no(100) == 1)
+		return file_mmap_write(file);
 
 	get_offset_and_size(file, &offset, &size);
 	seed = random_no(MAX_RANDOM_SEED);
-- 
1.7.2.3

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

* [PATCH 11/35] fs-tests: integck: teach file_write_data return an error
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (9 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 10/35] fs-tests: integck: handle errors in file_mmap_write Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 12/35] fs-tests: integck: rename BUFFER_SIZE Artem Bityutskiy
                   ` (23 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Make 'file_write_data()' return an error in case of failure.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 778e35c..67085ec 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -729,11 +729,13 @@ static struct fd_info *file_open(struct file_info *file)
 
 #define BUFFER_SIZE 32768
 
-static size_t file_write_data(	struct file_info *file,
-				int fd,
-				off_t offset,
-				size_t size,
-				unsigned seed)
+/*
+ * Write random 'size' bytes of random data to offset 'offset'. Seed the random
+ * gererator with 'seed'. Return amount of written data on success and -1 on
+ * failure.
+ */
+static ssize_t file_write_data(struct file_info *file, int fd,
+			       off_t offset, size_t size, unsigned seed)
 {
 	size_t remains, actual, block;
 	ssize_t written;
@@ -760,10 +762,15 @@ static size_t file_write_data(	struct file_info *file,
 			block = remains;
 		written = write(fd, buf, block);
 		if (written < 0) {
-			CHECK(errno == ENOSPC); /* File system full */
-			full = 1;
-			file->no_space_error = 1;
-			break;
+			if (errno == ENOSPC) {
+				full = 1;
+				file->no_space_error = 1;
+				break;
+			}
+			pcv("failed to write %zu bytes to offset %llu of file %s",
+			    block, (unsigned long long)(offset + actual),
+			    file->name);
+			return -1;
 		}
 		remains -= written;
 		actual += written;
@@ -1006,7 +1013,8 @@ static int file_mmap_write(struct file_info *file)
 static int file_write(struct file_info *file, int fd)
 {
 	off_t offset;
-	size_t size, actual;
+	size_t size;
+	ssize_t actual;
 	unsigned seed;
 	int ret, truncate = 0;
 
@@ -1017,10 +1025,11 @@ static int file_write(struct file_info *file, int fd)
 	get_offset_and_size(file, &offset, &size);
 	seed = random_no(MAX_RANDOM_SEED);
 	actual = file_write_data(file, fd, offset, size, seed);
+	if (actual < 0)
+		return -1;
 
 	if (offset + actual <= file->length && shrink)
-		/* 1 time in 100, when shrinking
-		   truncate after the write */
+		/* 1 time in 100, when shrinking truncate after the write */
 		if (random_no(100) == 0)
 			truncate = 1;
 
-- 
1.7.2.3

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

* [PATCH 12/35] fs-tests: integck: rename BUFFER_SIZE
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (10 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 11/35] fs-tests: integck: teach file_write_data return an error Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 13/35] fs-tests: integck: use unsigned int everywhere Artem Bityutskiy
                   ` (22 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Rename 'BUFFER_SIZE' constant into 'IO_BUFFER_SIZE' to reflect what
is the buffer this constant is about.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 67085ec..9eddc0b 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -46,6 +46,9 @@
 /* The pattern for the top directory where we run the test */
 #define TEST_DIR_PATTERN "integck_test_dir_%u"
 
+/* Maximum buffer size for a single read/write operation */
+#define IO_BUFFER_SIZE 32768
+
 /*
  * Check if a condition is true and die if not.
  */
@@ -727,8 +730,6 @@ static struct fd_info *file_open(struct file_info *file)
 	return add_fd(file, fd);
 }
 
-#define BUFFER_SIZE 32768
-
 /*
  * Write random 'size' bytes of random data to offset 'offset'. Seed the random
  * gererator with 'seed'. Return amount of written data on success and -1 on
@@ -739,25 +740,25 @@ static ssize_t file_write_data(struct file_info *file, int fd,
 {
 	size_t remains, actual, block;
 	ssize_t written;
-	char buf[BUFFER_SIZE];
+	char buf[IO_BUFFER_SIZE];
 
 	srand(seed);
 	CHECK(lseek(fd, offset, SEEK_SET) != (off_t)-1);
 	remains = size;
 	actual = 0;
-	written = BUFFER_SIZE;
+	written = IO_BUFFER_SIZE;
 	while (remains) {
 		/* Fill up buffer with random data */
-		if (written < BUFFER_SIZE) {
-			memmove(buf, buf + written, BUFFER_SIZE - written);
-			written = BUFFER_SIZE - written;
+		if (written < IO_BUFFER_SIZE) {
+			memmove(buf, buf + written, IO_BUFFER_SIZE - written);
+			written = IO_BUFFER_SIZE - written;
 		} else
 			written = 0;
-		for (; written < BUFFER_SIZE; ++written)
+		for (; written < IO_BUFFER_SIZE; ++written)
 			buf[written] = rand();
 		/* Write a block of data */
-		if (remains > BUFFER_SIZE)
-			block = BUFFER_SIZE;
+		if (remains > IO_BUFFER_SIZE)
+			block = IO_BUFFER_SIZE;
 		else
 			block = remains;
 		written = write(fd, buf, block);
@@ -1180,18 +1181,18 @@ static void file_rewrite_data(int fd, struct write_info *w, char *buf)
 		rand();
 	CHECK(lseek(fd, w->offset, SEEK_SET) != (off_t)-1);
 	remains = w->size;
-	written = BUFFER_SIZE;
+	written = IO_BUFFER_SIZE;
 	while (remains) {
 		/* Fill up buffer with random data */
-		if (written < BUFFER_SIZE)
-			memmove(buf, buf + written, BUFFER_SIZE - written);
+		if (written < IO_BUFFER_SIZE)
+			memmove(buf, buf + written, IO_BUFFER_SIZE - written);
 		else
 			written = 0;
-		for (; written < BUFFER_SIZE; ++written)
+		for (; written < IO_BUFFER_SIZE; ++written)
 			buf[written] = rand();
 		/* Write a block of data */
-		if (remains > BUFFER_SIZE)
-			block = BUFFER_SIZE;
+		if (remains > IO_BUFFER_SIZE)
+			block = IO_BUFFER_SIZE;
 		else
 			block = remains;
 		written = write(fd, buf, block);
@@ -1204,7 +1205,7 @@ static void save_file(int fd, struct file_info *file)
 {
 	int w_fd;
 	struct write_info *w;
-	char buf[BUFFER_SIZE];
+	char buf[IO_BUFFER_SIZE];
 	char name[256];
 
 	/* Open file to save contents to */
@@ -1219,7 +1220,7 @@ static void save_file(int fd, struct file_info *file)
 	CHECK(lseek(fd, 0, SEEK_SET) != (off_t)-1);
 
 	for (;;) {
-		ssize_t r = read(fd, buf, BUFFER_SIZE);
+		ssize_t r = read(fd, buf, IO_BUFFER_SIZE);
 		CHECK(r != -1);
 		if (!r)
 			break;
@@ -1241,18 +1242,17 @@ static void save_file(int fd, struct file_info *file)
 	CHECK(close(w_fd) == 0);
 }
 
-static void file_check_hole(	struct file_info *file,
-				int fd, off_t offset,
-				size_t size)
+static void file_check_hole(struct file_info *file, int fd, off_t offset,
+			    size_t size)
 {
 	size_t remains, block, i;
-	char buf[BUFFER_SIZE];
+	char buf[IO_BUFFER_SIZE];
 
 	CHECK(lseek(fd, offset, SEEK_SET) != (off_t)-1);
 	remains = size;
 	while (remains) {
-		if (remains > BUFFER_SIZE)
-			block = BUFFER_SIZE;
+		if (remains > IO_BUFFER_SIZE)
+			block = IO_BUFFER_SIZE;
 		else
 			block = remains;
 		CHECK(read(fd, buf, block) == block);
@@ -1271,13 +1271,12 @@ static void file_check_hole(	struct file_info *file,
 	}
 }
 
-static void file_check_data(	struct file_info *file,
-				int fd,
-				struct write_info *w)
+static void file_check_data(struct file_info *file, int fd,
+			    struct write_info *w)
 {
 	size_t remains, block, i;
 	off_t r;
-	char buf[BUFFER_SIZE];
+	char buf[IO_BUFFER_SIZE];
 
 	srand(w->random_seed);
 	for (r = 0; r < w->random_offset; ++r)
@@ -1285,8 +1284,8 @@ static void file_check_data(	struct file_info *file,
 	CHECK(lseek(fd, w->offset, SEEK_SET) != (off_t)-1);
 	remains = w->size;
 	while (remains) {
-		if (remains > BUFFER_SIZE)
-			block = BUFFER_SIZE;
+		if (remains > IO_BUFFER_SIZE)
+			block = IO_BUFFER_SIZE;
 		else
 			block = remains;
 		CHECK(read(fd, buf, block) == block);
-- 
1.7.2.3

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

* [PATCH 13/35] fs-tests: integck: use unsigned int everywhere
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (11 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 12/35] fs-tests: integck: rename BUFFER_SIZE Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 14/35] fs-tests: integck: fix placeholders when printing Artem Bityutskiy
                   ` (21 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

The test sometimes uses "unsigned" and sometimes "unsigned int". This
patch makes the code more consistent by making it use "unsigned int"
everywhere.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 9eddc0b..3b28e99 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -167,7 +167,7 @@ struct dir_info /* Each directory has one of these */
 	char *name;
 	struct dir_info *parent; /* Parent directory or null
 					for our top directory */
-	unsigned number_of_entries;
+	unsigned int number_of_entries;
 	struct dir_entry_info *first;
 	struct dir_entry_info *entry; /* Dir entry of this dir */
 };
@@ -667,7 +667,7 @@ static void file_info_display(struct file_info *file)
 {
 	struct dir_entry_info *entry;
 	struct write_info *w;
-	unsigned wcnt;
+	unsigned int wcnt;
 
 	normsg("File Info:");
 	normsg("    Original name: %s", file->name);
@@ -679,7 +679,7 @@ static void file_info_display(struct file_info *file)
 		normsg("      Directory: %s", entry->parent->name);
 		entry = entry->next_link;
 	}
-	normsg("    Length: %u", (unsigned)file->length);
+	normsg("    Length: %u", (unsigned int)file->length);
 	normsg("    File was open: %s",
 	       (file->fds == NULL) ? "false" : "true");
 	normsg("    File was deleted: %s",
@@ -691,8 +691,9 @@ static void file_info_display(struct file_info *file)
 	w = file->writes;
 	while (w) {
 		normsg("        Offset: %u  Size: %u  Seed: %u  R.Off: %u",
-		       (unsigned)w->offset, (unsigned)w->size,
-		       (unsigned)w->random_seed, (unsigned)w->random_offset);
+		       (unsigned int)w->offset, (unsigned int)w->size,
+		       (unsigned int)w->random_seed,
+		       (unsigned int)w->random_offset);
 		wcnt += 1;
 		w = w->next;
 	}
@@ -704,11 +705,11 @@ static void file_info_display(struct file_info *file)
 	while (w) {
 		if (is_truncation(w))
 			normsg("        Trunc from %u to %u",
-			       (unsigned)w->offset, (unsigned)w->new_length);
+			       (unsigned int)w->offset, (unsigned int)w->new_length);
 		else
 			normsg("        Offset: %u  Size: %u  Seed: %u  R.Off: %u",
-			       (unsigned)w->offset, (unsigned)w->size,
-			       (unsigned)w->random_seed, (unsigned)w->random_offset);
+			       (unsigned int)w->offset, (unsigned int)w->size,
+			       (unsigned int)w->random_seed, (unsigned int)w->random_offset);
 		wcnt += 1;
 		w = w->next;
 	}
@@ -735,8 +736,8 @@ static struct fd_info *file_open(struct file_info *file)
  * gererator with 'seed'. Return amount of written data on success and -1 on
  * failure.
  */
-static ssize_t file_write_data(struct file_info *file, int fd,
-			       off_t offset, size_t size, unsigned seed)
+static ssize_t file_write_data(struct file_info *file, int fd, off_t offset,
+			       size_t size, unsigned int seed)
 {
 	size_t remains, actual, block;
 	ssize_t written;
@@ -779,10 +780,8 @@ static ssize_t file_write_data(struct file_info *file, int fd,
 	return actual;
 }
 
-static void file_write_info(struct file_info *file,
-			off_t offset,
-			size_t size,
-			unsigned seed)
+static void file_write_info(struct file_info *file, off_t offset, size_t size,
+			    unsigned int seed)
 {
 	struct write_info *new_write, *w, **prev, *tmp;
 	int inserted;
@@ -1016,7 +1015,7 @@ static int file_write(struct file_info *file, int fd)
 	off_t offset;
 	size_t size;
 	ssize_t actual;
-	unsigned seed;
+	unsigned int seed;
 	int ret, truncate = 0;
 
 	if (fsinfo.can_mmap && !full && !file->deleted &&
@@ -1260,8 +1259,8 @@ static void file_check_hole(struct file_info *file, int fd, off_t offset,
 			if (buf[i] != 0) {
 				errmsg("file_check_hole failed at %u checking "
 				       "hole at %u size %u",
-				       (unsigned)(size - remains + i),
-				       (unsigned)offset, (unsigned)size);
+				       (unsigned int)(size - remains + i),
+				       (unsigned int)offset, (unsigned int)size);
 				file_info_display(file);
 				save_file(fd, file);
 			}
@@ -1294,8 +1293,8 @@ static void file_check_data(struct file_info *file, int fd,
 			if (buf[i] != c) {
 				errmsg("file_check_data failed at %u checking "
 				       "data at %u size %u",
-					(unsigned)(w->size - remains + i),
-					(unsigned)w->offset, (unsigned)w->size);
+					(unsigned int)(w->size - remains + i),
+					(unsigned int)w->offset, (unsigned int)w->size);
 				file_info_display(file);
 				save_file(fd, file);
 			}
@@ -1333,7 +1332,7 @@ static void file_check(struct file_info *file, int fd)
 	pos = lseek(fd, 0, SEEK_END);
 	if (pos != file->length) {
 		errmsg("file_check failed checking length expected %u actual %u\n",
-		       (unsigned)file->length, (unsigned)pos);
+		       (unsigned int)file->length, (unsigned int)pos);
 		file_info_display(file);
 		save_file(fd, file);
 	}
@@ -1443,12 +1442,11 @@ static int sort_comp(const void *pa, const void *pb)
 
 static void dir_check(struct dir_info *dir)
 {
-	struct dir_entry_info **entry_array, **p;
+	struct dir_entry_info *entry, **entry_array, **p;
 	size_t sz, n;
-	struct dir_entry_info *entry;
 	DIR *d;
 	struct dirent *ent;
-	unsigned checked = 0;
+	unsigned int checked = 0;
 	char *path;
 	int link_count = 2; /* Parent and dot */
 	struct stat st;
-- 
1.7.2.3

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

* [PATCH 14/35] fs-tests: integck: fix placeholders when printing
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (12 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 13/35] fs-tests: integck: use unsigned int everywhere Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 15/35] fs-tests: integck: make file_new return error on create failure Artem Bityutskiy
                   ` (20 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

There is a lot of code where %u is used for printing off_t variables,
which may be actually 64-bit wide. Fix this by using %llu.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 3b28e99..f2223d4 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -679,7 +679,7 @@ static void file_info_display(struct file_info *file)
 		normsg("      Directory: %s", entry->parent->name);
 		entry = entry->next_link;
 	}
-	normsg("    Length: %u", (unsigned int)file->length);
+	normsg("    Length: %llu", (unsigned long long)file->length);
 	normsg("    File was open: %s",
 	       (file->fds == NULL) ? "false" : "true");
 	normsg("    File was deleted: %s",
@@ -690,10 +690,10 @@ static void file_info_display(struct file_info *file)
 	wcnt = 0;
 	w = file->writes;
 	while (w) {
-		normsg("        Offset: %u  Size: %u  Seed: %u  R.Off: %u",
-		       (unsigned int)w->offset, (unsigned int)w->size,
-		       (unsigned int)w->random_seed,
-		       (unsigned int)w->random_offset);
+		normsg("        Offset: %llu  Size: %zu  Seed: %llu  R.Off: %llu",
+		       (unsigned long long)w->offset, w->size,
+		       (unsigned long long)w->random_seed,
+		       (unsigned long long)w->random_offset);
 		wcnt += 1;
 		w = w->next;
 	}
@@ -704,12 +704,14 @@ static void file_info_display(struct file_info *file)
 	w = file->raw_writes;
 	while (w) {
 		if (is_truncation(w))
-			normsg("        Trunc from %u to %u",
-			       (unsigned int)w->offset, (unsigned int)w->new_length);
+			normsg("        Trunc from %llu to %llu",
+			       (unsigned long long)w->offset,
+			       (unsigned long long)w->new_length);
 		else
-			normsg("        Offset: %u  Size: %u  Seed: %u  R.Off: %u",
-			       (unsigned int)w->offset, (unsigned int)w->size,
-			       (unsigned int)w->random_seed, (unsigned int)w->random_offset);
+			normsg("        Offset: %llu  Size: %zu  Seed: %llu  R.Off: %llu",
+			       (unsigned long long)w->offset, w->size,
+			       (unsigned long long)w->random_seed,
+			       (unsigned long long)w->random_offset);
 		wcnt += 1;
 		w = w->next;
 	}
@@ -1257,10 +1259,9 @@ static void file_check_hole(struct file_info *file, int fd, off_t offset,
 		CHECK(read(fd, buf, block) == block);
 		for (i = 0; i < block; ++i) {
 			if (buf[i] != 0) {
-				errmsg("file_check_hole failed at %u checking "
-				       "hole at %u size %u",
-				       (unsigned int)(size - remains + i),
-				       (unsigned int)offset, (unsigned int)size);
+				errmsg("file_check_hole failed at %zu checking "
+				       "hole at %llu size %zu", size - remains + i,
+				       (unsigned long long)offset, size);
 				file_info_display(file);
 				save_file(fd, file);
 			}
@@ -1291,10 +1292,9 @@ static void file_check_data(struct file_info *file, int fd,
 		for (i = 0; i < block; ++i) {
 			char c = (char)rand();
 			if (buf[i] != c) {
-				errmsg("file_check_data failed at %u checking "
-				       "data at %u size %u",
-					(unsigned int)(w->size - remains + i),
-					(unsigned int)w->offset, (unsigned int)w->size);
+				errmsg("file_check_data failed at %zu checking "
+				       "data at %llu size %zu", w->size - remains + i,
+					(unsigned long long)w->offset, w->size);
 				file_info_display(file);
 				save_file(fd, file);
 			}
@@ -1331,8 +1331,8 @@ static void file_check(struct file_info *file, int fd)
 	/* Check length */
 	pos = lseek(fd, 0, SEEK_END);
 	if (pos != file->length) {
-		errmsg("file_check failed checking length expected %u actual %u\n",
-		       (unsigned int)file->length, (unsigned int)pos);
+		errmsg("file_check failed checking length expected %llu actual %llu\n",
+		       (unsigned long long)file->length, (unsigned long long)pos);
 		file_info_display(file);
 		save_file(fd, file);
 	}
-- 
1.7.2.3

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

* [PATCH 15/35] fs-tests: integck: make file_new return error on create failure
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (13 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 14/35] fs-tests: integck: fix placeholders when printing Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 16/35] fs-tests: integck: teach dir_new return error on creation failure Artem Bityutskiy
                   ` (19 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'file_new()' to return -1 if it fails to create a file.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index f2223d4..471fcf4 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -509,23 +509,27 @@ static void dir_remove(struct dir_info *dir)
 	free(dir);
 }
 
-static struct file_info *file_new(struct dir_info *parent, const char *name)
+static int file_new(struct dir_info *parent, const char *name)
 {
-	struct file_info *file = NULL;
+	struct file_info *file;
 	char *path;
 	mode_t mode;
 	int fd;
 
-	CHECK(parent != NULL);
+	assert(parent != NULL);
 
 	path = dir_path(parent, name);
 	mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
 	fd = open(path, O_CREAT | O_EXCL | O_RDWR, mode);
 	if (fd == -1) {
-		CHECK(errno == ENOSPC);
+		if (errno == ENOSPC) {
+			full = 1;
+			free(path);
+			return 0;
+		}
+		pcv("cannot create file %s", path);
 		free(path);
-		full = 1;
-		return NULL;
+		return -1;
 	}
 	free(path);
 
@@ -533,10 +537,8 @@ static struct file_info *file_new(struct dir_info *parent, const char *name)
 	file->name = dup_string(name);
 
 	add_dir_entry(parent, 'f', name, file);
-
 	add_fd(file, fd);
-
-	return file;
+	return 0;
 }
 
 static void link_new(struct dir_info *parent, const char *name,
@@ -1932,7 +1934,7 @@ static int operate_on_dir(struct dir_info *dir)
 	r = random_no(14);
 	if (r == 0 && grow)
 		/* When growing, 1 time in 14 create a file */
-		file_new(dir, make_name(dir));
+		return file_new(dir, make_name(dir));
 	else if (r == 1 && grow)
 		/* When growing, 1 time in 14 create a directory */
 		dir_new(dir, make_name(dir));
-- 
1.7.2.3

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

* [PATCH 16/35] fs-tests: integck: teach dir_new return error on creation failure
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (14 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 15/35] fs-tests: integck: make file_new return error on create failure Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 17/35] fs-tests: integck: teach symlink_new to " Artem Bityutskiy
                   ` (18 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 471fcf4..e69d4c4 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -451,23 +451,24 @@ static void remove_dir_entry(struct dir_entry_info *entry)
 
 /*
  * Create a new directory "name" in the parent directory described by "parent"
- * and add it to the in-memory list of directories. In case of success, returns
- * a pointer to the new 'struct dir_info' object. Returns 'NULL' in case of
- * failure.
+ * and add it to the in-memory list of directories. Returns zero in case of
+ * success and -1 in case of failure.
  */
-static struct dir_info *dir_new(struct dir_info *parent, const char *name)
+static int dir_new(struct dir_info *parent, const char *name)
 {
 	struct dir_info *dir;
 	char *path;
 
 	path = dir_path(parent, name);
 	if (mkdir(path, 0777) != 0) {
-		if (errno == ENOSPC)
+		if (errno == ENOSPC) {
 			full = 1;
-		else
-			pcv("cannot create directory %s", path);
+			free(path);
+			return 0;
+		}
+		pcv("cannot create directory %s", path);
 		free(path);
-		return NULL;
+		return -1;
 	}
 	free(path);
 
@@ -476,7 +477,7 @@ static struct dir_info *dir_new(struct dir_info *parent, const char *name)
 	dir->parent = parent;
 	if (parent)
 		add_dir_entry(parent, 'd', name, dir);
-	return dir;
+	return 0;
 }
 
 static int file_delete(struct file_info *file);
@@ -1937,7 +1938,7 @@ static int operate_on_dir(struct dir_info *dir)
 		return file_new(dir, make_name(dir));
 	else if (r == 1 && grow)
 		/* When growing, 1 time in 14 create a directory */
-		dir_new(dir, make_name(dir));
+		return dir_new(dir, make_name(dir));
 	else if (r == 2 && grow && (file = pick_file()) != NULL)
 		/* When growing, 1 time in 14 create a hard link */
 		link_new(dir, make_name(dir), file);
@@ -2298,9 +2299,14 @@ static int integck(void)
 			return -1;
 	}
 
-	top_dir = dir_new(NULL, fsinfo.test_dir);
-	if (!top_dir)
+	ret = mkdir(fsinfo.test_dir, 0777);
+	if (ret) {
+		pcv("cannot create top test directory %s", fsinfo.test_dir);
 		return -1;
+	}
+
+	top_dir = zalloc(sizeof(struct dir_info));
+	top_dir->name = dup_string(fsinfo.test_dir);
 
 	ret = create_test_data();
 	if (ret)
-- 
1.7.2.3

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

* [PATCH 17/35] fs-tests: integck: teach symlink_new to return error on creation failure
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (15 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 16/35] fs-tests: integck: teach dir_new return error on creation failure Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 18/35] fs-tests: integck: teach link_new " Artem Bityutskiy
                   ` (17 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index e69d4c4..fbf24fb 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1806,21 +1806,31 @@ static char *pick_symlink_target(const char *symlink_path)
 	return rel_path;
 }
 
-static void symlink_new(struct dir_info *dir, const char *name_)
+static int symlink_new(struct dir_info *dir, const char *nm)
 {
 	struct symlink_info *s;
-	char *path, *target, *name = dup_string(name_);
+	char *path, *target, *name = dup_string(nm);
 
+	/*
+	 * Note, we need to duplicate the input 'name' string because of the
+	 * shared random_name_buf.
+	 */
 	path = dir_path(dir, name);
 	target = pick_symlink_target(path);
 	if (symlink(target, path) != 0) {
-		CHECK(errno == ENOSPC || errno == ENAMETOOLONG);
+		int ret = 0;
+
 		if (errno == ENOSPC)
 			full = 1;
+		else if (errno != ENAMETOOLONG) {
+			pcv("cannot create symlink %s in directory %s to file %s",
+			    path, dir->name, target);
+			ret = -1;
+		}
 		free(target);
-		free(path);
 		free(name);
-		return;
+		free(path);
+		return ret;
 	}
 	free(path);
 
@@ -1828,6 +1838,7 @@ static void symlink_new(struct dir_info *dir, const char *name_)
 	add_dir_entry(dir, 's', name, s);
 	s->target_pathname = target;
 	free(name);
+	return 0;
 }
 
 static void symlink_remove(struct symlink_info *symlink)
@@ -1944,7 +1955,7 @@ static int operate_on_dir(struct dir_info *dir)
 		link_new(dir, make_name(dir), file);
 	else if (r == 3 && grow && random_no(5) == 0)
 		/* When growing, 1 time in 70 create a symbolic link */
-		symlink_new(dir, make_name(dir));
+		return symlink_new(dir, make_name(dir));
 	else {
 		/* Otherwise randomly select an entry to operate on */
 		r = random_no(dir->number_of_entries);
-- 
1.7.2.3

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

* [PATCH 18/35] fs-tests: integck: teach link_new to return error on creation failure
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (16 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 17/35] fs-tests: integck: teach symlink_new to " Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 19/35] fs-tests: integck: make operate_on_dir propagate errors up Artem Bityutskiy
                   ` (16 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index fbf24fb..14d112f 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -542,8 +542,8 @@ static int file_new(struct dir_info *parent, const char *name)
 	return 0;
 }
 
-static void link_new(struct dir_info *parent, const char *name,
-		     struct file_info *file)
+static int link_new(struct dir_info *parent, const char *name,
+		    struct file_info *file)
 {
 	struct dir_entry_info *entry;
 	char *path, *target;
@@ -551,21 +551,26 @@ static void link_new(struct dir_info *parent, const char *name,
 
 	entry = file->links;
 	if (!entry)
-		return;
+		return 0;
+
 	path = dir_path(parent, name);
 	target = dir_path(entry->parent, entry->name);
 	ret = link(target, path);
 	if (ret != 0) {
-		CHECK(errno == ENOSPC);
+		if (errno == ENOSPC) {
+			ret = 0;
+			full = 1;
+		} else
+			pcv("cannot create hardlink %s in directory %s to file %s",
+			    path, parent->name, target);
 		free(target);
 		free(path);
-		full = 1;
-		return;
+		return ret;
 	}
 	free(target);
 	free(path);
-
 	add_dir_entry(parent, 'f', name, file);
+	return 0;
 }
 
 static void file_close(struct fd_info *fdi);
@@ -1952,7 +1957,7 @@ static int operate_on_dir(struct dir_info *dir)
 		return dir_new(dir, make_name(dir));
 	else if (r == 2 && grow && (file = pick_file()) != NULL)
 		/* When growing, 1 time in 14 create a hard link */
-		link_new(dir, make_name(dir), file);
+		return link_new(dir, make_name(dir), file);
 	else if (r == 3 && grow && random_no(5) == 0)
 		/* When growing, 1 time in 70 create a symbolic link */
 		return symlink_new(dir, make_name(dir));
-- 
1.7.2.3

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

* [PATCH 19/35] fs-tests: integck: make operate_on_dir propagate errors up
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (17 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 18/35] fs-tests: integck: teach link_new " Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 20/35] fs-tests: integck: make rename_entry return error on failure Artem Bityutskiy
                   ` (15 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Make 'operate_on_dir()' functions propogate errors up if any of
the functions it calls failed. This patch also makes 'operate_on_entry()'
return an error code, but without actual implementation.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 14d112f..09b4a7d 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1901,25 +1901,25 @@ static void operate_on_file(struct file_info *file)
 }
 
 /* Randomly select something to do with a directory entry */
-static void operate_on_entry(struct dir_entry_info *entry)
+static int operate_on_entry(struct dir_entry_info *entry)
 {
 	/* 1 time in 1000 rename */
 	if (random_no(1000) == 0) {
 		rename_entry(entry);
-		return;
+		return 0;
 	}
 	if (entry->type == 's') {
 		symlink_check(entry->symlink);
 		/* If shrinking, 1 time in 50, remove a symlink */
 		if (shrink && random_no(50) == 0)
 			symlink_remove(entry->symlink);
-		return;
+		return 0;
 	}
 	if (entry->type == 'd') {
 		/* If shrinking, 1 time in 50, remove a directory */
 		if (shrink && random_no(50) == 0) {
 			dir_remove(entry->dir);
-			return;
+			return 0;
 		}
 		operate_on_dir(entry->dir);
 	}
@@ -1927,16 +1927,17 @@ static void operate_on_entry(struct dir_entry_info *entry)
 		/* If shrinking, 1 time in 10, remove a file */
 		if (shrink && random_no(10) == 0) {
 			file_delete(entry->file);
-			return;
+			return 0;
 		}
 		/* If not growing, 1 time in 10, unlink a file with links > 1 */
 		if (!grow && entry->file->link_count > 1 &&
 		    random_no(10) == 0) {
 			file_unlink_file(entry->file);
-			return;
+			return 0;
 		}
 		operate_on_file(entry->file);
 	}
+	return 0;
 }
 
 /*
@@ -1947,20 +1948,21 @@ static int operate_on_dir(struct dir_info *dir)
 	struct dir_entry_info *entry;
 	struct file_info *file;
 	unsigned int r;
+	int ret = 0;
 
 	r = random_no(14);
 	if (r == 0 && grow)
 		/* When growing, 1 time in 14 create a file */
-		return file_new(dir, make_name(dir));
+		ret = file_new(dir, make_name(dir));
 	else if (r == 1 && grow)
 		/* When growing, 1 time in 14 create a directory */
-		return dir_new(dir, make_name(dir));
+		ret = dir_new(dir, make_name(dir));
 	else if (r == 2 && grow && (file = pick_file()) != NULL)
 		/* When growing, 1 time in 14 create a hard link */
-		return link_new(dir, make_name(dir), file);
+		ret = link_new(dir, make_name(dir), file);
 	else if (r == 3 && grow && random_no(5) == 0)
 		/* When growing, 1 time in 70 create a symbolic link */
-		return symlink_new(dir, make_name(dir));
+		ret = symlink_new(dir, make_name(dir));
 	else {
 		/* Otherwise randomly select an entry to operate on */
 		r = random_no(dir->number_of_entries);
@@ -1970,10 +1972,10 @@ static int operate_on_dir(struct dir_info *dir)
 			--r;
 		}
 		if (entry)
-			operate_on_entry(entry);
+			ret = operate_on_entry(entry);
 	}
 
-	return 0;
+	return ret;
 }
 
 /*
-- 
1.7.2.3

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

* [PATCH 20/35] fs-tests: integck: make rename_entry return error on failure
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (18 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 19/35] fs-tests: integck: make operate_on_dir propagate errors up Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 21/35] fs-tests: integck: teach symlink_remove return error on removal failure Artem Bityutskiy
                   ` (14 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Make 'rename_entry()' return an error to the caller when it fails
to rename a directory entry.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 09b4a7d..f56ff66 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1664,7 +1664,7 @@ static char *pick_rename_name(struct dir_info **parent,
 	return dup_string(entry->name);
 }
 
-static void rename_entry(struct dir_entry_info *entry)
+static int rename_entry(struct dir_entry_info *entry)
 {
 	struct dir_entry_info *rename_entry = NULL;
 	struct dir_info *parent;
@@ -1672,7 +1672,7 @@ static void rename_entry(struct dir_entry_info *entry)
 	int ret, isdir, retry;
 
 	if (!entry->parent)
-		return;
+		return 0;
 
 	for (retry = 0; retry < 3; retry++) {
 		path = dir_path(entry->parent, entry->name);
@@ -1701,17 +1701,21 @@ static void rename_entry(struct dir_entry_info *entry)
 	}
 
 	if (!path)
-		return;
+		return 0;
 
 	ret = rename(path, to);
 	if (ret != 0) {
+		ret = 0;
 		if (errno == ENOSPC)
 			full = 1;
-		CHECK(errno == ENOSPC || errno == EBUSY);
+		else if (errno !=  EBUSY) {
+			pcv("failed to rename %s to %s", path, to);
+			ret = -1;
+		}
 		free(path);
 		free(name);
 		free(to);
-		return;
+		return ret;
 	}
 
 	free(path);
@@ -1720,7 +1724,7 @@ static void rename_entry(struct dir_entry_info *entry)
 	if (rename_entry && rename_entry->type == entry->type &&
 	    rename_entry->target == entry->target) {
 		free(name);
-		return;
+		return 0;
 	}
 
 	add_dir_entry(parent, entry->type, name, entry->target);
@@ -1728,6 +1732,7 @@ static void rename_entry(struct dir_entry_info *entry)
 		remove_dir_entry(rename_entry);
 	remove_dir_entry(entry);
 	free(name);
+	return 0;
 }
 
 static size_t str_count(const char *s, char c)
@@ -1904,10 +1909,8 @@ static void operate_on_file(struct file_info *file)
 static int operate_on_entry(struct dir_entry_info *entry)
 {
 	/* 1 time in 1000 rename */
-	if (random_no(1000) == 0) {
-		rename_entry(entry);
-		return 0;
-	}
+	if (random_no(1000) == 0)
+		return rename_entry(entry);
 	if (entry->type == 's') {
 		symlink_check(entry->symlink);
 		/* If shrinking, 1 time in 50, remove a symlink */
-- 
1.7.2.3

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

* [PATCH 21/35] fs-tests: integck: teach symlink_remove return error on removal failure
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (19 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 20/35] fs-tests: integck: make rename_entry return error on failure Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 22/35] fs-tests: integck: teach dir_remove return error and fix a memory leak Artem Bityutskiy
                   ` (13 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

When 'symlink_remove()' fails to unling a symlink - return an error to
the calling function.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index f56ff66..a486229 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -482,7 +482,7 @@ static int dir_new(struct dir_info *parent, const char *name)
 
 static int file_delete(struct file_info *file);
 static int file_unlink(struct dir_entry_info *entry);
-static void symlink_remove(struct symlink_info *symlink);
+static int symlink_remove(struct symlink_info *symlink);
 
 static void dir_remove(struct dir_info *dir)
 {
@@ -1851,16 +1851,20 @@ static int symlink_new(struct dir_info *dir, const char *nm)
 	return 0;
 }
 
-static void symlink_remove(struct symlink_info *symlink)
+static int symlink_remove(struct symlink_info *symlink)
 {
 	char *path;
 
 	path = dir_path(symlink->entry->parent, symlink->entry->name);
+	if (unlink(path) != 0) {
+		pcv("cannot unlink symlink %s", path);
+		free(path);
+		return -1;
+	}
 
 	remove_dir_entry(symlink->entry);
-
-	CHECK(unlink(path) == 0);
 	free(path);
+	return 0;
 }
 
 static int operate_on_dir(struct dir_info *dir);
@@ -1915,7 +1919,7 @@ static int operate_on_entry(struct dir_entry_info *entry)
 		symlink_check(entry->symlink);
 		/* If shrinking, 1 time in 50, remove a symlink */
 		if (shrink && random_no(50) == 0)
-			symlink_remove(entry->symlink);
+			return symlink_remove(entry->symlink);
 		return 0;
 	}
 	if (entry->type == 'd') {
-- 
1.7.2.3

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

* [PATCH 22/35] fs-tests: integck: teach dir_remove return error and fix a memory leak
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (20 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 21/35] fs-tests: integck: teach symlink_remove return error on removal failure Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 23/35] fs-tests: integck: teach file_unlink_file return an error Artem Bityutskiy
                   ` (12 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'dir_remove()' to return an error to the caller if it fails to
remove the directory. Also, there was a memory leak - the 'path'
string was not freed - fix it as well.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index a486229..9ab417d 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -484,30 +484,41 @@ static int file_delete(struct file_info *file);
 static int file_unlink(struct dir_entry_info *entry);
 static int symlink_remove(struct symlink_info *symlink);
 
-static void dir_remove(struct dir_info *dir)
+static int dir_remove(struct dir_info *dir)
 {
 	char *path;
 
 	/* Remove directory contents */
 	while (dir->first) {
 		struct dir_entry_info *entry;
+		int ret = 0;
 
 		entry = dir->first;
 		if (entry->type == 'd')
-			dir_remove(entry->dir);
+			ret = dir_remove(entry->dir);
 		else if (entry->type == 'f')
-			file_unlink(entry);
+			ret = file_unlink(entry);
 		else if (entry->type == 's')
-			symlink_remove(entry->symlink);
+			ret = symlink_remove(entry->symlink);
 		else
 			CHECK(0); /* Invalid struct dir_entry_info */
+		if (ret)
+			return -1;
+	}
+
+	/* Remove directory form the file-system */
+	path = dir_path(dir->parent, dir->name);
+	if (rmdir(path) != 0) {
+		pcv("cannot remove directory entry %s", path);
+		free(path);
+		return -1;
 	}
+
 	/* Remove entry from parent directory */
 	remove_dir_entry(dir->entry);
-	/* Remove directory itself */
-	path = dir_path(dir->parent, dir->name);
-	CHECK(rmdir(path) == 0);
+	free(path);
 	free(dir);
+	return 0;
 }
 
 static int file_new(struct dir_info *parent, const char *name)
@@ -1924,11 +1935,9 @@ static int operate_on_entry(struct dir_entry_info *entry)
 	}
 	if (entry->type == 'd') {
 		/* If shrinking, 1 time in 50, remove a directory */
-		if (shrink && random_no(50) == 0) {
-			dir_remove(entry->dir);
-			return 0;
-		}
-		operate_on_dir(entry->dir);
+		if (shrink && random_no(50) == 0)
+			return dir_remove(entry->dir);
+		return operate_on_dir(entry->dir);
 	}
 	if (entry->type == 'f') {
 		/* If shrinking, 1 time in 10, remove a file */
-- 
1.7.2.3

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

* [PATCH 23/35] fs-tests: integck: teach file_unlink_file return an error
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (21 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 22/35] fs-tests: integck: teach dir_remove return error and fix a memory leak Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 24/35] fs-tests: integck: make operate_on_entry handle all errors Artem Bityutskiy
                   ` (11 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'file_unlink_file()' return an error to the caller if the
file cannot be unlinked.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 9ab417d..f99caae 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -652,14 +652,14 @@ static struct dir_entry_info *pick_entry(struct file_info *file)
 	return entry;
 }
 
-static void file_unlink_file(struct file_info *file)
+static int file_unlink_file(struct file_info *file)
 {
 	struct dir_entry_info *entry;
 
 	entry = pick_entry(file);
 	if (!entry)
-		return;
-	file_unlink(entry);
+		return 0;
+	return file_unlink(entry);
 }
 
 /*
@@ -1941,16 +1941,12 @@ static int operate_on_entry(struct dir_entry_info *entry)
 	}
 	if (entry->type == 'f') {
 		/* If shrinking, 1 time in 10, remove a file */
-		if (shrink && random_no(10) == 0) {
-			file_delete(entry->file);
-			return 0;
-		}
+		if (shrink && random_no(10) == 0)
+			return file_delete(entry->file);
 		/* If not growing, 1 time in 10, unlink a file with links > 1 */
 		if (!grow && entry->file->link_count > 1 &&
-		    random_no(10) == 0) {
-			file_unlink_file(entry->file);
-			return 0;
-		}
+		    random_no(10) == 0)
+			return file_unlink_file(entry->file);
 		operate_on_file(entry->file);
 	}
 	return 0;
-- 
1.7.2.3

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

* [PATCH 24/35] fs-tests: integck: make operate_on_entry handle all errors
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (22 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 23/35] fs-tests: integck: teach file_unlink_file return an error Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 25/35] fs-tests: integck: make file_open return error on failure Artem Bityutskiy
                   ` (10 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Make 'operate_on_entry()' handle handle errors from all functions
it calls and return the error code to the caller.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index f99caae..c3c3813 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1881,27 +1881,27 @@ static int symlink_remove(struct symlink_info *symlink)
 static int operate_on_dir(struct dir_info *dir);
 
 /* Randomly select something to do with a file */
-static void operate_on_file(struct file_info *file)
+static int operate_on_file(struct file_info *file)
 {
 	/* Try to keep at least 10 files open */
 	if (open_files_count < 10) {
 		file_open(file);
-		return;
+		return 0;
 	}
 	/* Try to keep about 20 files open */
 	if (open_files_count < 20 && random_no(2) == 0) {
 		file_open(file);
-		return;
+		return 0;
 	}
 	/* Try to keep up to 40 files open */
 	if (open_files_count < 40 && random_no(20) == 0) {
 		file_open(file);
-		return;
+		return 0;
 	}
 	/* Occasionly truncate */
 	if (shrink && random_no(100) == 0) {
 		file_truncate_file(file);
-		return;
+		return 0;
 	}
 	/* Mostly just write */
 	file_write_file(file);
@@ -1918,38 +1918,40 @@ static void operate_on_file(struct file_info *file)
 			file_check(file, fd);
 		}
 	}
+	return 0;
 }
 
 /* Randomly select something to do with a directory entry */
 static int operate_on_entry(struct dir_entry_info *entry)
 {
+	int ret = 0;
+
 	/* 1 time in 1000 rename */
 	if (random_no(1000) == 0)
-		return rename_entry(entry);
-	if (entry->type == 's') {
+		ret = rename_entry(entry);
+	else if (entry->type == 's') {
 		symlink_check(entry->symlink);
 		/* If shrinking, 1 time in 50, remove a symlink */
 		if (shrink && random_no(50) == 0)
-			return symlink_remove(entry->symlink);
-		return 0;
-	}
-	if (entry->type == 'd') {
+			ret = symlink_remove(entry->symlink);
+	} else if (entry->type == 'd') {
 		/* If shrinking, 1 time in 50, remove a directory */
 		if (shrink && random_no(50) == 0)
-			return dir_remove(entry->dir);
-		return operate_on_dir(entry->dir);
-	}
-	if (entry->type == 'f') {
+			ret = dir_remove(entry->dir);
+		else
+			ret = operate_on_dir(entry->dir);
+	} else if (entry->type == 'f') {
 		/* If shrinking, 1 time in 10, remove a file */
 		if (shrink && random_no(10) == 0)
-			return file_delete(entry->file);
+			ret = file_delete(entry->file);
 		/* If not growing, 1 time in 10, unlink a file with links > 1 */
-		if (!grow && entry->file->link_count > 1 &&
-		    random_no(10) == 0)
-			return file_unlink_file(entry->file);
-		operate_on_file(entry->file);
+		else if (!grow && entry->file->link_count > 1 &&
+			 random_no(10) == 0)
+			ret = file_unlink_file(entry->file);
+		else
+			ret = operate_on_file(entry->file);
 	}
-	return 0;
+	return ret;
 }
 
 /*
-- 
1.7.2.3

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

* [PATCH 25/35] fs-tests: integck: make file_open return error on failure
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (23 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 24/35] fs-tests: integck: make operate_on_entry handle all errors Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:18 ` [PATCH 26/35] fs-tests: integck: make file_truncate_file return error Artem Bityutskiy
                   ` (9 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Make 'file_open()' return an error to the caller if it fails to open
the file.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index c3c3813..3498c76 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -738,7 +738,7 @@ static void file_info_display(struct file_info *file)
 	normsg("    ============================================");
 }
 
-static struct fd_info *file_open(struct file_info *file)
+static int file_open(struct file_info *file)
 {
 	int fd, flags = O_RDWR;
 	char *path;
@@ -747,9 +747,14 @@ static struct fd_info *file_open(struct file_info *file)
 	if (random_no(100) == 1)
 		flags |= O_SYNC;
 	fd = open(path, flags);
-	CHECK(fd != -1);
+	if (fd == -1) {
+		pcv("cannot open file %s", path);
+		free(path);
+		return -1;
+	}
 	free(path);
-	return add_fd(file, fd);
+	add_fd(file, fd);
+	return 0;
 }
 
 /*
@@ -1884,20 +1889,15 @@ static int operate_on_dir(struct dir_info *dir);
 static int operate_on_file(struct file_info *file)
 {
 	/* Try to keep at least 10 files open */
-	if (open_files_count < 10) {
-		file_open(file);
-		return 0;
-	}
+	if (open_files_count < 10)
+		return file_open(file);
 	/* Try to keep about 20 files open */
-	if (open_files_count < 20 && random_no(2) == 0) {
-		file_open(file);
-		return 0;
-	}
+	if (open_files_count < 20 && random_no(2) == 0)
+		return file_open(file);
 	/* Try to keep up to 40 files open */
-	if (open_files_count < 40 && random_no(20) == 0) {
-		file_open(file);
-		return 0;
-	}
+	if (open_files_count < 40 && random_no(20) == 0)
+		return file_open(file);
+
 	/* Occasionly truncate */
 	if (shrink && random_no(100) == 0) {
 		file_truncate_file(file);
-- 
1.7.2.3

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

* [PATCH 26/35] fs-tests: integck: make file_truncate_file return error
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (24 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 25/35] fs-tests: integck: make file_open return error on failure Artem Bityutskiy
@ 2011-04-20 10:18 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 27/35] fs-tests: integck: fix memory lead in dir_remove Artem Bityutskiy
                   ` (8 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:18 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Teach 'file_truncate_file()' return an error to the caller if it fails
to open the file or to truncate it.

Additionally, check the error code from 'open()' in other places.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 3498c76..79c1020 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -993,7 +993,11 @@ static int file_mmap_write(struct file_info *file)
 	/* Open it */
 	path = dir_path(file->links->parent, file->links->name);
 	fd = open(path, O_RDWR);
-	CHECK(fd != -1);
+	if (fd == -1) {
+		pcv("cannot open file %s to do mmap", path);
+		free(path);
+		return -1;
+	}
 
 	/* mmap it */
 	addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offs);
@@ -1090,7 +1094,11 @@ static int file_write_file(struct file_info *file)
 
 	path = dir_path(file->links->parent, file->links->name);
 	fd = open(path, O_WRONLY);
-	CHECK(fd != -1);
+	if (fd == -1) {
+		pcv("cannot open file %s for writing", path);
+		free(path);
+		return -1;
+	}
 	ret = file_write(file, fd);
 	CHECK(close(fd) == 0);
 	free(path);
@@ -1146,17 +1154,23 @@ static int file_truncate(struct file_info *file, int fd)
 	return 0;
 }
 
-static void file_truncate_file(struct file_info *file)
+static int file_truncate_file(struct file_info *file)
 {
 	int fd;
 	char *path;
+	int ret;
 
 	path = dir_path(file->links->parent, file->links->name);
 	fd = open(path, O_WRONLY);
-	CHECK(fd != -1);
-	file_truncate(file, fd);
-	CHECK(close(fd) == 0);
+	if (fd == -1) {
+		pcv("cannot open file %s to truncate", path);
+		free(path);
+		return -1;
+	}
 	free(path);
+	ret = file_truncate(file, fd);
+	CHECK(close(fd) == 0);
+	return ret;
 }
 
 static void file_close(struct fd_info *fdi)
@@ -1899,12 +1913,11 @@ static int operate_on_file(struct file_info *file)
 		return file_open(file);
 
 	/* Occasionly truncate */
-	if (shrink && random_no(100) == 0) {
-		file_truncate_file(file);
-		return 0;
-	}
+	if (shrink && random_no(100) == 0)
+		return file_truncate_file(file);
 	/* Mostly just write */
-	file_write_file(file);
+	if (file_write_file(file) != 0)
+		return -1;
 	/* Once in a while check it too */
 	if (random_no(100) == 1) {
 		int fd = -2;
-- 
1.7.2.3

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

* [PATCH 27/35] fs-tests: integck: fix memory lead in dir_remove
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (25 preceding siblings ...)
  2011-04-20 10:18 ` [PATCH 26/35] fs-tests: integck: make file_truncate_file return error Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 28/35] fs-tests: integck: fix memory leak in dir_new Artem Bityutskiy
                   ` (7 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

When removing a directory and freeing corresponding 'dir_info' object -
do not forget to free directory name as well.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 79c1020..d2db320 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -517,6 +517,7 @@ static int dir_remove(struct dir_info *dir)
 	/* Remove entry from parent directory */
 	remove_dir_entry(dir->entry);
 	free(path);
+	free(dir->name);
 	free(dir);
 	return 0;
 }
-- 
1.7.2.3

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

* [PATCH 28/35] fs-tests: integck: fix memory leak in dir_new
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (26 preceding siblings ...)
  2011-04-20 10:19 ` [PATCH 27/35] fs-tests: integck: fix memory lead in dir_remove Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 29/35] fs-tests: integck: introduce free_writes_info helper Artem Bityutskiy
                   ` (6 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Do not initialize dir->name because add_dir_entry already does
this for us, so we leak the memory.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index d2db320..666bc70 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -473,7 +473,6 @@ static int dir_new(struct dir_info *parent, const char *name)
 	free(path);
 
 	dir = zalloc(sizeof(struct dir_info));
-	dir->name = dup_string(name);
 	dir->parent = parent;
 	if (parent)
 		add_dir_entry(parent, 'd', name, dir);
-- 
1.7.2.3

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

* [PATCH 29/35] fs-tests: integck: introduce free_writes_info helper
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (27 preceding siblings ...)
  2011-04-20 10:19 ` [PATCH 28/35] fs-tests: integck: fix memory leak in dir_new Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 30/35] fs-tests: integck: free raw write information Artem Bityutskiy
                   ` (5 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

We have duplicated code for freeing write informatio - put it into
a helper function.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 666bc70..50b414f 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -152,7 +152,6 @@ struct file_info /* Each file has one of these */
 	off_t length;
 	int link_count;
 	unsigned int check_run_no; /* Run number used when checking */
-	unsigned int deleted:1; /* File has been deleted but is still open */
 	unsigned int no_space_error:1; /* File has incurred a ENOSPC error */
 };
 
@@ -442,7 +441,7 @@ static void remove_dir_entry(struct dir_entry_info *entry)
 			file->links = entry->next_link;
 		file->link_count -= 1;
 		if (file->link_count == 0)
-			file->deleted = 1;
+			assert(file->links == NULL);
 	}
 
 	free(entry->name);
@@ -599,6 +598,21 @@ static void file_close_all(struct file_info *file)
 }
 
 /*
+ * Free all the information about writes to a file.
+ */
+static void free_writes_info(struct file_info *file)
+{
+	struct write_info *w, *next;
+
+	w = file->writes;
+	while (w) {
+		next = w->next;
+		free(w);
+		w = next;
+	}
+}
+
+/*
  * Unlink a directory entry for a file.
  */
 static int file_unlink(struct dir_entry_info *entry)
@@ -622,18 +636,10 @@ static int file_unlink(struct dir_entry_info *entry)
 
 	/* Free struct file_info if file is not open and not linked */
 	if (!file->fds && !file->links) {
-		struct write_info *w, *next;
-
+		free_writes_info(file);
 		free(file->name);
-		w = file->writes;
-		while (w) {
-			next = w->next;
-			free(w);
-			w = next;
-		}
 		free(file);
-	} else if (!file->links)
-		file->deleted = 1;
+	}
 
 	return 0;
 }
@@ -702,7 +708,7 @@ static void file_info_display(struct file_info *file)
 	normsg("    File was open: %s",
 	       (file->fds == NULL) ? "false" : "true");
 	normsg("    File was deleted: %s",
-	       (file->deleted == 0) ? "false" : "true");
+	       (file->link_count == 0) ? "true" : "false");
 	normsg("    File was out of space: %s",
 	       (file->no_space_error == 0) ? "false" : "true");
 	normsg("    File Data:");
@@ -1048,7 +1054,7 @@ static int file_write(struct file_info *file, int fd)
 	unsigned int seed;
 	int ret, truncate = 0;
 
-	if (fsinfo.can_mmap && !full && !file->deleted &&
+	if (fsinfo.can_mmap && !full && file->link_count &&
 	    random_no(100) == 1)
 		return file_mmap_write(file);
 
@@ -1189,16 +1195,8 @@ static void file_close(struct fd_info *fdi)
 		if (fdp == fdi) {
 			*prev = fdi->next;
 			free(fdi);
-			if (file->deleted && !file->fds) {
-				/* Closing deleted file */
-				struct write_info *w, *next;
-
-				w = file->writes;
-				while (w) {
-					next = w->next;
-					free(w);
-					w = next;
-				}
+			if (!file->link_count && !file->fds) {
+				free_writes_info(file);
 				free(file->name);
 				free(file);
 			}
@@ -1554,7 +1552,7 @@ static void check_deleted_files(void)
 	struct open_file_info *ofi;
 
 	for (ofi = open_files; ofi; ofi = ofi->next)
-		if (ofi->fdi->file->deleted)
+		if (!ofi->fdi->file->link_count)
 			file_check(ofi->fdi->file, ofi->fdi->fd);
 }
 
@@ -2017,7 +2015,7 @@ static int operate_on_open_file(struct fd_info *fdi)
 		ret = file_truncate(fdi->file, fdi->fd);
 	else if (r < 21)
 		file_close(fdi);
-	else if (shrink && r < 121 && !fdi->file->deleted)
+	else if (shrink && r < 121 && fdi->file->link_count)
 		ret = file_delete(fdi->file);
 	else {
 		ret = file_write(fdi->file, fdi->fd);
-- 
1.7.2.3

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

* [PATCH 30/35] fs-tests: integck: free raw write information
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (28 preceding siblings ...)
  2011-04-20 10:19 ` [PATCH 29/35] fs-tests: integck: introduce free_writes_info helper Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 31/35] fs-tests: integck: remove symlinks memory leaks Artem Bityutskiy
                   ` (4 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

The test leaks memory like hell because it does not free the raw writes
information. This patch fixes the leaks.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 50b414f..96937ff 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -610,6 +610,13 @@ static void free_writes_info(struct file_info *file)
 		free(w);
 		w = next;
 	}
+
+	w = file->raw_writes;
+	while (w) {
+		next = w->next;
+		free(w);
+		w = next;
+	}
 }
 
 /*
-- 
1.7.2.3

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

* [PATCH 31/35] fs-tests: integck: remove symlinks memory leaks
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (29 preceding siblings ...)
  2011-04-20 10:19 ` [PATCH 30/35] fs-tests: integck: free raw write information Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 32/35] fs-tests: integck: clean up add_dir_entry usage Artem Bityutskiy
                   ` (3 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

When we create a symlink we also allocate a symlink_info structure
and the target path name. But when we remove a symlink - we do not
delete that memory. This patch fixes the issue.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 96937ff..94ffeb8 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1898,6 +1898,8 @@ static int symlink_remove(struct symlink_info *symlink)
 	}
 
 	remove_dir_entry(symlink->entry);
+	free(symlink->target_pathname);
+	free(symlink);
 	free(path);
 	return 0;
 }
-- 
1.7.2.3

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

* [PATCH 32/35] fs-tests: integck: clean up add_dir_entry usage
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (30 preceding siblings ...)
  2011-04-20 10:19 ` [PATCH 31/35] fs-tests: integck: remove symlinks memory leaks Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 33/35] fs-tests: integck: lessen memory consumption Artem Bityutskiy
                   ` (2 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

Make 'add_dir_entry()' consistent and allocate name for all types,
not only for 'd' and 's'. Also, since 'add_dir_entry()' sets the
parent - do not do this in the calling functions.

This is a clean-up which makes 'add_dir_entry()' more consistent.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 94ffeb8..03b3a01 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -399,6 +399,7 @@ static void add_dir_entry(struct dir_info *parent, char type, const char *name,
 	if (entry->type == 'f') {
 		struct file_info *file = target;
 
+		file->name = dup_string(name);
 		entry->file = file;
 		entry->next_link = file->links;
 		if (file->links)
@@ -472,7 +473,6 @@ static int dir_new(struct dir_info *parent, const char *name)
 	free(path);
 
 	dir = zalloc(sizeof(struct dir_info));
-	dir->parent = parent;
 	if (parent)
 		add_dir_entry(parent, 'd', name, dir);
 	return 0;
@@ -545,8 +545,6 @@ static int file_new(struct dir_info *parent, const char *name)
 	free(path);
 
 	file = zalloc(sizeof(struct file_info));
-	file->name = dup_string(name);
-
 	add_dir_entry(parent, 'f', name, file);
 	add_fd(file, fd);
 	return 0;
-- 
1.7.2.3

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

* [PATCH 33/35] fs-tests: integck: lessen memory consumption
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (31 preceding siblings ...)
  2011-04-20 10:19 ` [PATCH 32/35] fs-tests: integck: clean up add_dir_entry usage Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 34/35] fs-tests: integck: lessen memory consumption even more Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 35/35] fs-tests: integck: assume that the parent is present in new_dir Artem Bityutskiy
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

We do not need to store directory name in the 'struct dir_info' objects,
because we already have it in 'struct dir_entry_info'. So we duplicate
the names for directories in 'dir->name' and 'dir->entry->name'.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 03b3a01..d5ee08e 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -163,7 +163,6 @@ struct symlink_info /* Each symlink has one of these */
 
 struct dir_info /* Each directory has one of these */
 {
-	char *name;
 	struct dir_info *parent; /* Parent directory or null
 					for our top directory */
 	unsigned int number_of_entries;
@@ -332,7 +331,7 @@ static char *dir_path(struct dir_info *parent, const char *name)
 
 	if (!parent)
 		return cat_paths(fsinfo.mount_point, name);
-	parent_path = dir_path(parent->parent, parent->name);
+	parent_path = dir_path(parent->parent, parent->entry->name);
 	path = cat_paths(parent_path, name);
 	free(parent_path);
 	return path;
@@ -411,7 +410,6 @@ static void add_dir_entry(struct dir_info *parent, char type, const char *name,
 
 		entry->dir = dir;
 		dir->entry = entry;
-		dir->name = dup_string(name);
 		dir->parent = parent;
 	} else if (entry->type == 's') {
 		struct symlink_info *symlink = target;
@@ -505,7 +503,7 @@ static int dir_remove(struct dir_info *dir)
 	}
 
 	/* Remove directory form the file-system */
-	path = dir_path(dir->parent, dir->name);
+	path = dir_path(dir->parent, dir->entry->name);
 	if (rmdir(path) != 0) {
 		pcv("cannot remove directory entry %s", path);
 		free(path);
@@ -515,7 +513,6 @@ static int dir_remove(struct dir_info *dir)
 	/* Remove entry from parent directory */
 	remove_dir_entry(dir->entry);
 	free(path);
-	free(dir->name);
 	free(dir);
 	return 0;
 }
@@ -570,7 +567,7 @@ static int link_new(struct dir_info *parent, const char *name,
 			full = 1;
 		} else
 			pcv("cannot create hardlink %s in directory %s to file %s",
-			    path, parent->name, target);
+			    path, parent->entry->name, target);
 		free(target);
 		free(path);
 		return ret;
@@ -706,7 +703,7 @@ static void file_info_display(struct file_info *file)
 	entry = file->links;
 	while (entry) {
 		normsg("      Name: %s", entry->name);
-		normsg("      Directory: %s", entry->parent->name);
+		normsg("      Directory: %s", entry->parent->entry->name);
 		entry = entry->next_link;
 	}
 	normsg("    Length: %llu", (unsigned long long)file->length);
@@ -1510,7 +1507,7 @@ static void dir_check(struct dir_info *dir)
 	qsort(entry_array, n, sz, sort_comp);
 
 	/* Go through directory on file system checking entries match */
-	path = dir_path(dir->parent, dir->name);
+	path = dir_path(dir->parent, dir->entry->name);
 	d = opendir(path);
 	CHECK(d != NULL);
 	for (;;) {
@@ -1867,7 +1864,7 @@ static int symlink_new(struct dir_info *dir, const char *nm)
 			full = 1;
 		else if (errno != ENAMETOOLONG) {
 			pcv("cannot create symlink %s in directory %s to file %s",
-			    path, dir->name, target);
+			    path, dir->entry->name, target);
 			ret = -1;
 		}
 		free(target);
@@ -2356,7 +2353,8 @@ static int integck(void)
 	}
 
 	top_dir = zalloc(sizeof(struct dir_info));
-	top_dir->name = dup_string(fsinfo.test_dir);
+	top_dir->entry = zalloc(sizeof(struct dir_entry_info));
+	top_dir->entry->name = dup_string(fsinfo.test_dir);
 
 	ret = create_test_data();
 	if (ret)
-- 
1.7.2.3

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

* [PATCH 34/35] fs-tests: integck: lessen memory consumption even more
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (32 preceding siblings ...)
  2011-04-20 10:19 ` [PATCH 33/35] fs-tests: integck: lessen memory consumption Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  2011-04-20 10:19 ` [PATCH 35/35] fs-tests: integck: assume that the parent is present in new_dir Artem Bityutskiy
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

This patch kills the "name" field from 'struct file_info' where we stored
the original file name. We do not really need to keep this name around,
becaus it might have long gone and it is not very interesting. Besides,
we have several memory leaks where we leak 'file->name' strings, so this
is the easiest way to fix those leaks as well.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index d5ee08e..310e228 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -143,7 +143,6 @@ struct dir_entry_info;
 
 struct file_info /* Each file has one of these */
 {
-	char *name; /* Original name */
 	struct write_info *writes; /* Record accumulated writes to the file */
 	struct write_info *raw_writes;
 				/* Record in order all writes to the file */
@@ -398,7 +397,6 @@ static void add_dir_entry(struct dir_info *parent, char type, const char *name,
 	if (entry->type == 'f') {
 		struct file_info *file = target;
 
-		file->name = dup_string(name);
 		entry->file = file;
 		entry->next_link = file->links;
 		if (file->links)
@@ -639,7 +637,6 @@ static int file_unlink(struct dir_entry_info *entry)
 	/* Free struct file_info if file is not open and not linked */
 	if (!file->fds && !file->links) {
 		free_writes_info(file);
-		free(file->name);
 		free(file);
 	}
 
@@ -697,7 +694,6 @@ static void file_info_display(struct file_info *file)
 	unsigned int wcnt;
 
 	normsg("File Info:");
-	normsg("    Original name: %s", file->name);
 	normsg("    Link count: %d", file->link_count);
 	normsg("    Links:");
 	entry = file->links;
@@ -805,7 +801,7 @@ static ssize_t file_write_data(struct file_info *file, int fd, off_t offset,
 			}
 			pcv("failed to write %zu bytes to offset %llu of file %s",
 			    block, (unsigned long long)(offset + actual),
-			    file->name);
+			    file->links->name);
 			return -1;
 		}
 		remains -= written;
@@ -955,7 +951,7 @@ static int file_ftruncate(struct file_info *file, int fd, off_t new_length)
 			return 1;
 		} else
 			pcv("cannot truncate file %s to %llu",
-			    file->name, (unsigned long long)new_length);
+			    file->links->name, (unsigned long long)new_length);
 		return -1;
 	}
 
@@ -1199,7 +1195,6 @@ static void file_close(struct fd_info *fdi)
 			free(fdi);
 			if (!file->link_count && !file->fds) {
 				free_writes_info(file);
-				free(file->name);
 				free(file);
 			}
 			return;
@@ -1249,7 +1244,7 @@ static void save_file(int fd, struct file_info *file)
 
 	/* Open file to save contents to */
 	strcpy(name, "/tmp/");
-	strcat(name, file->name);
+	strcat(name, file->links->name);
 	strcat(name, ".integ.sav.read");
 	normsg("Saving %sn", name);
 	w_fd = open(name, O_CREAT | O_WRONLY, 0777);
@@ -1269,7 +1264,7 @@ static void save_file(int fd, struct file_info *file)
 
 	/* Open file to save contents to */
 	strcpy(name, "/tmp/");
-	strcat(name, file->name);
+	strcat(name, file->links->name);
 	strcat(name, ".integ.sav.written");
 	normsg("Saving %s", name);
 	w_fd = open(name, O_CREAT | O_WRONLY, 0777);
@@ -2028,12 +2023,12 @@ static int operate_on_open_file(struct fd_info *fdi)
 				ret = fsync(fdi->fd);
 				if (ret)
 					pcv("fsync failed for %s",
-					    fdi->file->name);
+					    fdi->file->links->name);
 			} else {
 				ret = fdatasync(fdi->fd);
 				if (ret)
 					pcv("fdatasync failed for %s",
-					    fdi->file->name);
+					    fdi->file->links->name);
 			}
 		}
 	}
-- 
1.7.2.3

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

* [PATCH 35/35] fs-tests: integck: assume that the parent is present in new_dir
  2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
                   ` (33 preceding siblings ...)
  2011-04-20 10:19 ` [PATCH 34/35] fs-tests: integck: lessen memory consumption even more Artem Bityutskiy
@ 2011-04-20 10:19 ` Artem Bityutskiy
  34 siblings, 0 replies; 36+ messages in thread
From: Artem Bityutskiy @ 2011-04-20 10:19 UTC (permalink / raw)
  To: MTD list; +Cc: Adrian Hunter

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

We always pass non-NULL 'parent' argument to 'new_dir()', so no need to
test it for NULL.

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

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 310e228..9cb0403 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -455,6 +455,8 @@ static int dir_new(struct dir_info *parent, const char *name)
 	struct dir_info *dir;
 	char *path;
 
+	assert(parent);
+
 	path = dir_path(parent, name);
 	if (mkdir(path, 0777) != 0) {
 		if (errno == ENOSPC) {
@@ -469,8 +471,7 @@ static int dir_new(struct dir_info *parent, const char *name)
 	free(path);
 
 	dir = zalloc(sizeof(struct dir_info));
-	if (parent)
-		add_dir_entry(parent, 'd', name, dir);
+	add_dir_entry(parent, 'd', name, dir);
 	return 0;
 }
 
-- 
1.7.2.3

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

end of thread, other threads:[~2011-04-20 10:16 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 10:18 [PATCH 00/35] fs-tests: integck: handle write errors Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 01/35] fs-tests: integck: introduce power cut testing arguments Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 02/35] fs-tests: integck: check deletion errors in rm_minus_rf_dir Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 03/35] fs-tests: integck: handle write failures in dir_new Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 04/35] fs-tests: integck: handle errors in remount_tested_fs Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 05/35] fs-tests: integck: handle errors when creating test data Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 06/35] fs-tests: integck: make more functions propogate error up Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 07/35] fs-tests: integck: teach file_truncate return error code Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 08/35] fs-tests: integck: handle errors in file_delete Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 09/35] fs-tests: integck: handle all failures in operate_on_open_file Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 10/35] fs-tests: integck: handle errors in file_mmap_write Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 11/35] fs-tests: integck: teach file_write_data return an error Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 12/35] fs-tests: integck: rename BUFFER_SIZE Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 13/35] fs-tests: integck: use unsigned int everywhere Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 14/35] fs-tests: integck: fix placeholders when printing Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 15/35] fs-tests: integck: make file_new return error on create failure Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 16/35] fs-tests: integck: teach dir_new return error on creation failure Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 17/35] fs-tests: integck: teach symlink_new to " Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 18/35] fs-tests: integck: teach link_new " Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 19/35] fs-tests: integck: make operate_on_dir propagate errors up Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 20/35] fs-tests: integck: make rename_entry return error on failure Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 21/35] fs-tests: integck: teach symlink_remove return error on removal failure Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 22/35] fs-tests: integck: teach dir_remove return error and fix a memory leak Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 23/35] fs-tests: integck: teach file_unlink_file return an error Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 24/35] fs-tests: integck: make operate_on_entry handle all errors Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 25/35] fs-tests: integck: make file_open return error on failure Artem Bityutskiy
2011-04-20 10:18 ` [PATCH 26/35] fs-tests: integck: make file_truncate_file return error Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 27/35] fs-tests: integck: fix memory lead in dir_remove Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 28/35] fs-tests: integck: fix memory leak in dir_new Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 29/35] fs-tests: integck: introduce free_writes_info helper Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 30/35] fs-tests: integck: free raw write information Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 31/35] fs-tests: integck: remove symlinks memory leaks Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 32/35] fs-tests: integck: clean up add_dir_entry usage Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 33/35] fs-tests: integck: lessen memory consumption Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 34/35] fs-tests: integck: lessen memory consumption even more Artem Bityutskiy
2011-04-20 10:19 ` [PATCH 35/35] fs-tests: integck: assume that the parent is present in new_dir Artem Bityutskiy

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.