fsx: Small improvements and fixes
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 11 Jan 2016 03:43:40 +0000 (14:43 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 11 Jan 2016 03:43:40 +0000 (14:43 +1100)
Move the run_fsx shell function into common/rc.  Fix it to avoid
duplicate output on errors.  Write the actual fsx parameters used into
$seqres.full instead of the BSIZE and PSIZE placeholders.

Include the symbolic fallocate mode in fsx error messages instead of the
numeric value.  Use fprintf(stderr, ...) instead of warn() when
including strerror(errno) doesn't make sense.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/rc
ltp/fsx.c
tests/generic/091
tests/generic/263

index d33e3fb96bdc6a8590925e387827c210af030f93..513526036f5abdf89416b5b2e7155cb382edec01 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3343,6 +3343,20 @@ get_page_size()
 }
 
 
+run_fsx()
+{
+       echo fsx $@
+       args=`echo $@ | sed -e "s/ BSIZE / $bsize /g" -e "s/ PSIZE / $psize /g"`
+       set -- $here/ltp/fsx $args $FSX_AVOID $TEST_DIR/junk
+       echo "$@" >>$seqres.full
+       rm -f $TEST_DIR/junk
+       "$@" 2>&1 | tee -a $seqres.full >$tmp.fsx
+       if [ ${PIPESTATUS[0]} -ne 0 ]; then
+               cat $tmp.fsx
+               exit 1
+       fi
+}
+
 init_rc
 
 ################################################################################
index 6da51e99d6459a81ca4d8cab2605b896adfaacf9..805fdfb0391286420b0ad2108642d32e57efab94 100644 (file)
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -1557,16 +1557,20 @@ int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
 
 #endif
 
+#define test_fallocate(mode) __test_fallocate(mode, #mode)
+
 int
-test_fallocate(int mode)
+__test_fallocate(int mode, const char *mode_str)
 {
 #ifdef HAVE_LINUX_FALLOC_H
        int ret = 0;
        if (!lite) {
                if (fallocate(fd, mode, 0, 1) && errno == EOPNOTSUPP) {
                        if(!quiet)
-                               warn("main: filesystem does not support "
-                                    "fallocate mode 0x%x, disabling!\n", mode);
+                               fprintf(stderr,
+                                       "main: filesystem does not support "
+                                       "fallocate mode %s, disabling!\n",
+                                       mode_str);
                } else {
                        ret = 1;
                        ftruncate(fd, 0);
@@ -1862,8 +1866,7 @@ main(int argc, char **argv)
        if (keep_size_calls)
                keep_size_calls = test_fallocate(FALLOC_FL_KEEP_SIZE);
        if (punch_hole_calls)
-               punch_hole_calls = test_fallocate(FALLOC_FL_PUNCH_HOLE |
-                                                 FALLOC_FL_KEEP_SIZE);
+               punch_hole_calls = test_fallocate(FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE);
        if (zero_range_calls)
                zero_range_calls = test_fallocate(FALLOC_FL_ZERO_RANGE);
        if (collapse_range_calls)
index 30491bfcfdfe7be9bd79c848cafb98b5bfc7d573..da54397fe54da31137e72a55a71c04e16c119529 100755 (executable)
@@ -43,18 +43,6 @@ _require_odirect
 
 rm -f $seqres.full
 
-run_fsx()
-{
-       echo fsx $@ | tee -a $seqres.full
-       args=`echo $@ | sed -e "s/ BSIZE / $bsize /g" -e "s/ PSIZE / $psize /g"`
-       rm -f $TEST_DIR/junk
-       $here/ltp/fsx $args $FSX_AVOID $TEST_DIR/junk >>$seqres.full 2>&1
-       if [ $? -ne 0 ]; then
-               cat $seqres.full
-               exit 1
-       fi
-}
-
 psize=`$here/src/feature -s`
 bsize=`_min_dio_alignment $TEST_DEV`
 
index 7584bc7cc9ac89659a0dbca16fd6a283da691200..b460c8279e04b53cee2ef7e1fe81fcbfff901333 100755 (executable)
@@ -43,18 +43,6 @@ _require_odirect
 
 rm -f $seqres.full
 
-run_fsx()
-{
-       echo fsx $@ | tee -a $seqres.full
-       args=`echo $@ | sed -e "s/ BSIZE / $bsize /g" -e "s/ PSIZE / $psize /g"`
-       rm -f $TEST_DIR/junk
-       $here/ltp/fsx $args $FSX_AVOID $TEST_DIR/junk >>$seqres.full 2>&1
-       if [ $? -ne 0 ]; then
-               cat $seqres.full
-               exit 1
-       fi
-}
-
 psize=`$here/src/feature -s`
 bsize=`_min_dio_alignment $TEST_DEV`