[PATCH 09/35] fs-tests: integck: handle all failures in operate_on_open_file
Artem Bityutskiy
dedekind1 at gmail.com
Wed Apr 20 06:18:42 EDT 2011
From: Artem Bityutskiy <Artem.Bityutskiy at 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 at 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
More information about the linux-mtd
mailing list