xfstests: fix seek_sanity_test for fs w/o fallocate

currently the seek_sanity_test (generic/285) fails on ext3
or ext2 due to fallocate() failures.  Just ignore that test
if the fs doesn't support fallocate.

Note: this patch was originally submitted by Zheng Liu. 
http://oss.sgi.com/archives/xfs/2013-05/msg00534.html

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zheng Liu <gnehzuil.liu@gmail.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
This commit is contained in:
Eric Sandeen
2013-06-03 07:28:17 -05:00
committed by Rich Johnston
parent 1515c26fd4
commit 3e889c6735
+26 -4
View File
@@ -95,9 +95,13 @@ static int do_fallocate(int fd, off_t offset, off_t length, int mode)
int ret; int ret;
ret = fallocate(fd, mode, offset, length); ret = fallocate(fd, mode, offset, length);
if (ret) if (ret) {
/* Don't warn about a filesystem w/o fallocate support */
if (errno == EOPNOTSUPP)
return ret;
fprintf(stderr, " ERROR %d: Failed to preallocate " fprintf(stderr, " ERROR %d: Failed to preallocate "
"space to %ld bytes\n", errno, (long) length); "space to %ld bytes\n", errno, (long) length);
}
return ret; return ret;
} }
@@ -215,8 +219,14 @@ static int test09(int fd, int testnum)
/* preallocate 8M space to file */ /* preallocate 8M space to file */
ret = do_fallocate(fd, 0, filsz, 0); ret = do_fallocate(fd, 0, filsz, 0);
if (ret < 0) if (ret < 0) {
/* Report success if fs doesn't support fallocate */
if (errno == EOPNOTSUPP) {
fprintf(stdout, "Test skipped as fs doesn't support fallocate.\n");
ret = 0;
}
goto out; goto out;
}
ret = do_pwrite(fd, buf, bufsz, bufsz * 10); ret = do_pwrite(fd, buf, bufsz, bufsz * 10);
if (!ret) { if (!ret) {
@@ -261,8 +271,14 @@ static int test08(int fd, int testnum)
/* preallocate 4M space to file */ /* preallocate 4M space to file */
ret = do_fallocate(fd, 0, filsz, 0); ret = do_fallocate(fd, 0, filsz, 0);
if (ret < 0) if (ret < 0) {
/* Report success if fs doesn't support fallocate */
if (errno == EOPNOTSUPP) {
fprintf(stdout, "Test skipped as fs doesn't support fallocate.\n");
ret = 0;
}
goto out; goto out;
}
ret = do_pwrite(fd, buf, bufsz, bufsz * 10); ret = do_pwrite(fd, buf, bufsz, bufsz * 10);
if (ret) if (ret)
@@ -304,8 +320,14 @@ static int test07(int fd, int testnum)
/* preallocate 4M space to file */ /* preallocate 4M space to file */
ret = do_fallocate(fd, 0, filsz, 0); ret = do_fallocate(fd, 0, filsz, 0);
if (ret < 0) if (ret < 0) {
/* Report success if fs doesn't support fallocate */
if (errno == EOPNOTSUPP) {
fprintf(stdout, "Test skipped as fs doesn't support fallocate.\n");
ret = 0;
}
goto out; goto out;
}
ret = do_pwrite(fd, buf, bufsz, bufsz * 10); ret = do_pwrite(fd, buf, bufsz, bufsz * 10);
if (ret) if (ret)