]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: EIO can also be return in power-cut testing
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 23 May 2011 11:30:01 +0000 (14:30 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 27 May 2011 12:55:06 +0000 (15:55 +0300)
Currently when we are doing UBIFS power cut emulation testing we assume that
EROFS is returned in case of an emulated power cut event. However, this is
not true and sometimes Linux returns EIO to user-space instead. Namely, this
happens when we are waiting for write-back to finish. Here is a call trace
form kernel 2.6.39-rc7:

Call Trace:
 [<ffffffff810aaa77>] filemap_write_and_wait_range+0x78/0xb1
 [<ffffffff8110f34d>] vfs_fsync_range+0x38/0xd3
 [<ffffffff8110f42b>] generic_write_sync+0x43/0x65
 [<ffffffff810ab0c9>] generic_file_aio_write+0xaa/0xf2
 [<ffffffffa02224c9>] ubifs_aio_write+0x13a/0x1a1 [ubifs]
 [<ffffffff810ed71f>] do_sync_write+0xcb/0x141
 [<ffffffff810ee016>] vfs_write+0xb0/0x150
 [<ffffffff810ee175>] sys_write+0x48/0x72
 [<ffffffff813e0692>] system_call_fastpath+0x16/0x1b

'filemap_fdatawait_range()' returns hard-coded -EIO if a page write-back
happens with whatever error code.

Thus, this patch teaches integck to handle EIO when doing power cut emulation
testing.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/fs-tests/integrity/integck.c

index 7fd662b01f7bc60c88d42e40bb6540ea3370505a..b9f4666b346f898339315b47f84381797d5e6e6c 100644 (file)
 
 #define CHECK_ERRNO() do {                                                   \
        if (args.power_cut_mode)                                             \
-               CHECK(errno == EROFS);                                       \
+               /*                                                           \
+                * In case of emulated power cut failures the FS has to      \
+                * return EROFS. But unfortunately, the Linux kernel         \
+                * sometimes returns EIO to user-space anyway (when write-   \
+                * back fails the return code is awayse EIO).                \
+                */                                                          \
+               CHECK(errno == EROFS || errno == EIO);                       \
        else                                                                 \
                CHECK(0);                                                    \
 } while(0)
@@ -3248,7 +3254,7 @@ int main(int argc, char *argv[])
                }
 
                CHECK(ret);
-               CHECK(errno == EROFS);
+               CHECK(errno == EROFS || errno == EIO);
 
                free_test_data();