xfstests-dev.git
3 years agolib/: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:14 +0000 (12:04 +1000)]
lib/: spdx license conversion

Scripted like all the others, manually added tags to
Makefile, touchups required for random.c

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agoinclude/: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:13 +0000 (12:04 +1000)]
include/: spdx license conversion

Mostly scripted like all the others, manually added tags to
Makefile and build/config input files.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agodmapi: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:12 +0000 (12:04 +1000)]
dmapi: spdx license conversion

Scripted like all the others.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agosrc: fix up mmap() error checking
Ross Zwisler [Wed, 20 Jun 2018 22:51:46 +0000 (16:51 -0600)]
src: fix up mmap() error checking

I noticed that in some of my C tests in src/ I was incorrectly
checking for mmap() failure by looking for NULL instead of
MAP_FAILED.  Fix those and clean up some places where we were
testing against -1 (the actual value of MAP_FAILED) which was
manually being cast to a pointer.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/xfs: Add _scratch_get_sfdir_prefix function
Marco Benatto [Mon, 18 Jun 2018 17:44:32 +0000 (14:44 -0300)]
common/xfs: Add _scratch_get_sfdir_prefix function

Move get_sfdir_prefix function from xfs/278 to commom/xfs
and rename it to _scratch_get_sfdir_prefix so it can be
used in other xfs tests.

This commit also changes xfs/278 to make use of
_scratch_get_sfdir_prefix instead previous one.

Signed-off-by: Marco Benatto <mbenatto@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: replace btrfs-debug-tree with btrfs inspect-internal dump-tree
Lu Fengqi [Thu, 21 Jun 2018 07:04:22 +0000 (15:04 +0800)]
btrfs: replace btrfs-debug-tree with btrfs inspect-internal dump-tree

Since btrfs-dump-tree has been removed from btrfs-progs, use btrfs
inspect-internal dump-tree instead of btrfs-dump-tree.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agosrc/t_stripealign.c: Fix complier error
Xiao Yang [Wed, 20 Jun 2018 03:12:00 +0000 (11:12 +0800)]
src/t_stripealign.c: Fix complier error

The FIEMAP_EXTENT_SHARED flag was added into kernel since commit
8c0414cd524e, so undefined FIEMAP_EXTENT_SHARED resulted in complier
error on old distros(e.g. RHEL6), as below:
----------------------------------------------------------------------
t_stripealign.c:99: error: 'FIEMAP_EXTENT_SHARED' undeclared (first use in this function)
----------------------------------------------------------------------

We fix it by defining the flag manually.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/170: increase agsize for bigger internal log size
Zorro Lang [Mon, 11 Jun 2018 09:10:40 +0000 (17:10 +0800)]
xfs/170: increase agsize for bigger internal log size

xfs/170 always fails on xfs with "-m rmapbt=1,reflink=1", because
XFS need bigger internal log size if rmapbt and reflink are both
enabled.

One line of xfs/170 as below:

  _test_streams 8 16 4 8 3 0 0

Refer to common/filestreams, we can see xfs/170 trys to create a
128M XFS (agcount=8, agsize=16M), then each stream writes
24M (8 * 3M files), and there're 4 streams.

So the case expects each stream takes 2 AGs, 4 streams takes
different 8 AGs just enough. But internal log will break this
balance. For example:

"mkfs.xfs -f -b size=4k -m rmapbt=1,reflink=1 $dev" will take 3075
4k blocks (12M) by default:
  meta-data=/dev/mapper/xxxx-xfscratch isize=512    agcount=8, agsize=4096 blks
  ...
  log      =internal               bsize=4096   blocks=3075, version=2
           =                       sectsz=512   sunit=0 blks, lazy-count=1
  ...

And the internal log is in the 4th AG:
  # xfs_logprint: /dev/mapper/xxxx-xfscratch
  xfs_logprint:
      data device: 0xfd03
      log device: 0xfd03 daddr: 131120 length: 24600
  # xfs_db -c "convert daddr 131120 agno" /dev/mapper/xxxx-xfscratch
  0x4 (4)

Then if one stream write data into AG-1 at first, then turn to AG-4
after fill 16M agsize. But AG-4 has 12M space for log section, so
only 4M free space for data. Then this stream have to turn to the
next AG after fill the 4M space. All these as below:

  # xfs_bmap -vp stream2-dir/*
  stream2-dir/frame-1:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       32960..39103      1 (192..6335)       6144 000000
  ...
  ...
  stream2-dir/frame-5:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       57536..63679      1 (24768..30911)    6144 000000
  stream2-dir/frame-6:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       155776..161919    4 (24704..30847)    6144 000000
  stream2-dir/frame-7:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       170088..176231    5 (6248..12391)     6144 000000
  stream2-dir/frame-8:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       176232..182375    5 (12392..18535)    6144 000000

Later _test_streams maybe takes AG-5 again, and cause two streams use
AG-5. To avoid this failure, increase the agsize from 16M to 22M,
others stay the same, each stream still writes 2 AGs. Even internal
log takes some space from someone AG, left space should be enough to
write (24 - 22)=2M data.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/223: port t_stripealign to FIEMAP
Darrick J. Wong [Wed, 13 Jun 2018 22:50:57 +0000 (15:50 -0700)]
generic/223: port t_stripealign to FIEMAP

Since XFS has deprecated FIBMAP on FSDAX filesystems, we can't use
FIBMAP to verify stripe alignment anymore.  FIEMAP has existed for
quite some time now, so port it to use that instead, and only fall
back to FIBMAP if FIEMAP doesn't exist.

Tested-by: ross.zwisler@linux.intel.com
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: Add test that checks rmdir(2) can delete a subvolume
Misono Tomohiro [Wed, 13 Jun 2018 06:06:45 +0000 (15:06 +0900)]
btrfs: Add test that checks rmdir(2) can delete a subvolume

Add btrfs test that checks "rmdir" or "rm -r" command can delete a
subvolume like an ordinary directory.

This behavior has been restricted long time but becomes allowed by
kernel commit a79a464d5675 ("btrfs: Allow rmdir(2) to delete an
empty subvolume")

The test will be skipped if kernel does not support the feature,
which can be checked whether /sys/fs/btrfs/features/rmdir_subvol
exists or not.

Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoltp/fsx: output the seed value after logid is initialized
Hou Tao [Tue, 12 Jun 2018 12:43:30 +0000 (20:43 +0800)]
ltp/fsx: output the seed value after logid is initialized

When running multiple fsx processes simultaneously (e.g.
generic/455), it is difficult to tell the seed value for one fsx
process if the seed value is needed to reproduce a log-replay
failure.

Fix it by outputting the seed value after logid is initialized.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: add test for fsync of directory after creating hard link
Filipe Manana [Mon, 11 Jun 2018 18:24:35 +0000 (19:24 +0100)]
generic: add test for fsync of directory after creating hard link

Test that if we create a new hard link for a file which was
previously fsync'ed, fsync a parent directory of the new hard link
and power fail, the parent directory exists after mounting the
filesystem again. The parent directory must be a new directory, not
yet persisted.

This test is motivated by a bug found in btrfs, where the fsync'ed
parent directory was lost after a power failure. The bug in btrfs is
fixed by a patch for the linux kernel titled:

 "Btrfs: sync log after logging new name"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/391: add _require_odirect
Jakob Unterwurzacher [Tue, 12 Jun 2018 19:39:40 +0000 (21:39 +0200)]
generic/391: add _require_odirect

On filesystems that do not support O_DIRECT, the test should skip
itself with

 generic/391  [not run] O_DIRECT is not supported

instead of failing with

 generic/391  - output mismatch ...
     ...
     +open: Invalid argument
      Silence is golden
     ...

This patch make it do that by adding a call to _require_odirect.
Fixes https://github.com/rfjakob/gocryptfs/issues/244 .

Signed-off-by: Jakob Unterwurzacher <jakobunt@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon: improve regex in _check_dmesg
Zorro Lang [Tue, 12 Jun 2018 06:09:06 +0000 (14:09 +0800)]
common: improve regex in _check_dmesg

A dmesg output as below cause all cases fail:

[  508.002072] EDAC DEBUG: ie31200_check: MC0

Due to it matches `egrep -e "BUG:"` in _check_dmesg. But it's not a
real BUG output, so use "\bBUG:" to avoid this mistake.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: make lsqa.pl work with SPDX tags
Dave Chinner [Sat, 9 Jun 2018 01:45:38 +0000 (11:45 +1000)]
fstests: make lsqa.pl work with SPDX tags

The regex matches used to dump the test headers are no longer valid,
so update them to work with the new test header format.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agofstests: convert top level files and tools to SPDX
Dave Chinner [Sat, 9 Jun 2018 01:36:01 +0000 (11:36 +1000)]
fstests: convert top level files and tools to SPDX

Scripted conversion, see script in initial SPDX license commit
message. Many files required touch-ups after the script had run
because of the old and widely different formats. most touchups were
to remove excess empty comment lines the script left behind.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agofstests: convert remaining tests to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:35:53 +0000 (11:35 +1000)]
fstests: convert remaining tests to SPDX license tags

Fully scripted conversion, see script in initial SPDX license commit
message.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agobtrfs: convert tests to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:35:50 +0000 (11:35 +1000)]
btrfs: convert tests to SPDX license tags

Fully scripted conversion, see script in initial SPDX license commit
message.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agoxfs: convert tests to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:35:45 +0000 (11:35 +1000)]
xfs: convert tests to SPDX license tags

Fully scripted conversion, see script in initial SPDX license commit
message.

tests/xfs/044 was hand massaged to remove duplicate copyright and
divider lines before running the script.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agogeneric: convert tests to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:35:42 +0000 (11:35 +1000)]
generic: convert tests to SPDX license tags

Fully scripted conversion, see script in initial SPDX license commit
message.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agofstests: convert new test template to SPDX tags
Dave Chinner [Sat, 9 Jun 2018 01:35:32 +0000 (11:35 +1000)]
fstests: convert new test template to SPDX tags

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agocommon: convert to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:34:49 +0000 (11:34 +1000)]
common: convert to SPDX license tags

These have been scripted conversions then cleaned up by hand as
there was no consistency to the formatting of the license headers in
the common/ directory. Author information was also removed (it's in
the git history) and so now the header format is consistently:

##/bin/bash
# SPDX-License-Identifier: GPL-2.0(+)
# Copyright (c) <date> <owner>. All Rights Reserved.
#
# <file description>

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agofstests: Add LICENSES directory
Dave Chinner [Sat, 9 Jun 2018 01:29:45 +0000 (11:29 +1000)]
fstests: Add LICENSES directory

In preparation for changing tests over to use SPDX tags, add the
initial licenses needed for the common/ and tests/ changeover to
the LICENSES/ directory. For this initial patch set, only the GPLv2
license text is required.

The tests and other common scripts will be converted to tags via a
script and, if necessary touched up to fix any warts the script
can't handle. The script is run on a target via:

for f in `git grep -l "GNU General" <target>` ; do
echo $f
cat $f | awk -f hdr.awk > $f.new
mv -f $f.new $f
done

This, unfortunately, changes the permissions of the files, so each
patch was post processed to remove the mode change fields from
the patches before they were committed. This preserves the file
modes, even though the files were replaced.

The awk script that dos all the substitution work is as follows:

$ cat hdr.awk
BEGIN {
        hdr = 1
        tag = "GPL-2.0"
ignore = 0
        str = ""
cstr = ""
}

/^#[\!#][ ]*\/bin\/bash/ {
print $0
next
}

/^#[\!#][ ]*.*\/perl/ {
print $0
next
}

/any later version./ {
        tag = "GPL-2.0+"
        next
}

/^#[\-]{65}/ {
if (hdr == 1 && ignore == 0) {
ignore = 1
hdr = 0
} else if (ignore == 1) {
# use this to ignore empty comment line after license
ignore = 2
}
next
}

/This program is free software/ {
if (hdr == 1 && ignore == 0) {
ignore = 1
hdr = 0
}
next
}

/02110-1301[, ] *USA/ {
# use this to ignore empty comment line after license
if (ignore = 1) {
ignore = 2
}
next
}

/^#[ ]*Copyright/ {
if (cstr != "")
cstr = cstr "\n"
cstr = cstr $0
next
}

// {
if (ignore == 2) {
print "# SPDX-License-Identifier: " tag
print cstr "\n#"
print str
str=""
ignore = 3

}
if (ignore == 1) {
next
} else if (ignore == 3) {
# ignore trailing empty comment lines
if ($0 == "#")
next
ignore = 0
}

if (str != "")
str = str "\n"
str = str $0
}

END {
print str
}
$

Signed-off-by: Dave Chinner <dchinner@redhat.com>
3 years agogeneric: test swapfile creation, activation, and deactivation
Darrick J. Wong [Thu, 7 Jun 2018 15:17:10 +0000 (08:17 -0700)]
generic: test swapfile creation, activation, and deactivation

Test swapfile activation and deactivation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: make sure pretty printed geometry output matches
Darrick J. Wong [Tue, 5 Jun 2018 16:43:33 +0000 (09:43 -0700)]
xfs: make sure pretty printed geometry output matches

Make sure that all of our commands that can print geometry
information all print the /same/ information.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: abstract xfs_info into $XFS_INFO_PROG
Darrick J. Wong [Tue, 5 Jun 2018 16:43:27 +0000 (09:43 -0700)]
xfs: abstract xfs_info into $XFS_INFO_PROG

Abstract calls to xfs_info into $XFS_INFO_PROG like we do for all
other xfs utilities.

[Eryu: require xfs_info to be present if FSTYP is xfs]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/310: fix _require_scratch_nocheck ordering
Darrick J. Wong [Tue, 5 Jun 2018 16:43:14 +0000 (09:43 -0700)]
xfs/310: fix _require_scratch_nocheck ordering

In xfs/310 we have to _require_scratch_nocheck last because anything
else that calls _require_scratch (e.g. _require_xfs_scratch_rmapbt)
will create the "check scratch after test exit" file.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/122: fix sb_fname[XFSLABEL_MAX] in test
Darrick J. Wong [Tue, 5 Jun 2018 16:43:02 +0000 (09:43 -0700)]
xfs/122: fix sb_fname[XFSLABEL_MAX] in test

We recently redefined sb_fname's array length to use a symbolic
constant instead of a magic number, so update this test accordingly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/439: don't check filesystem afterwards
Darrick J. Wong [Tue, 5 Jun 2018 16:42:56 +0000 (09:42 -0700)]
xfs/439: don't check filesystem afterwards

We deliberately corrupted the scratch fs, so don't check it afterwards.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/401: fix test in case of no filetype support
Amir Goldstein [Tue, 5 Jun 2018 08:08:50 +0000 (11:08 +0300)]
generic/401: fix test in case of no filetype support

Xu Huan reported that this test fails on nfs in some setup.
Apparently, the assumptions made about xfs/ext* do not hold
for nfs.

Relax the verification of filetype not supported case to
allow either DT_UNKNOWN or actual file type on all files and
not only on special dir entires "." and "..".

Convert the unknown d_type replacement code from awk to bash
so it is a bit more readable and flexible.

Reported-by: Xu Huan <xuhuan.fnst@cn.fujitsu.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Tested-by: Xu Huan <xuhuan.fnst@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: nicer report when features are not supported
Amir Goldstein [Fri, 1 Jun 2018 10:44:16 +0000 (13:44 +0300)]
overlay: nicer report when features are not supported

Commit ea7ad43 ("fstests: implement require of multiple overlayfs
features") changed the message when tests are not run due to missing
overlayfs feature.

Restore the check for existing module param before trying to mount
which restores the old message format, e.g.:

[not run] feature 'metacopy' not supported by overlay

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: skip atime related tests on CIFS
xiaoli feng [Thu, 31 May 2018 04:10:14 +0000 (12:10 +0800)]
common/rc: skip atime related tests on CIFS

From the feedback of cifs developer, the behaviour of atime/noatime
for cifs is basically noatime always. So the atime related mount
options have no effect on cifs mounts. And Skip these tests on CIFS.

Signed-off-by: xiaoli feng <xifeng@redhat.com>
Acked-by: Steve French <smfrench@gmail.com>
Acked-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: Regression test for vulnerable directory integrity check
Xiao Yang [Wed, 30 May 2018 08:53:43 +0000 (16:53 +0800)]
xfs: Regression test for vulnerable directory integrity check

If a malicious XFS contains a block+ format directory wherein the
directory inode's core.mode is corrupted, and there are
subdirectories of the corrupted directory, an attempt to traverse up
the directory tree by running xfs_scrub will crash the kernel in
__xfs_dir3_data_check.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: Fix _require_xfs_io_command for scrub probe
Xiao Yang [Mon, 4 Jun 2018 04:50:12 +0000 (12:50 +0800)]
common/rc: Fix _require_xfs_io_command for scrub probe

Currently, xfs_io scrub command doesn't allow the probe function
to have any parameter, so we remove the invalid parameter.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocheck: fail tests if check/dmesg are not clean
Dave Chinner [Mon, 28 May 2018 23:07:37 +0000 (09:07 +1000)]
check: fail tests if check/dmesg are not clean

Currently a test appears to pass even if it leaves a corrupt
filesystem behind, or a splat in the system logs that should not be
there. While the test is internally tracked as failed (and the
summary reports it as failed) the per-test output exits with a
success and so emits a completion time before the post-test checks
are run by the test harness.  Rework the check code to report
post-test check failures as specific test failures rather than as
separate failure line items in the overall harness output.

Reworking where we emit the errors this also allows us to include
the post-test filesystem checking in the test runtime. This is
currently not accounted to the test and can be substantial. Hence
the real elapsed time of each test is not accurately reflected in
the time stats being reported and so regressions in filesystem
checking performance go unnoticed.

Changing the output reporting requires a complete reworking of the
main test check loop. It's a bunch of spaghetti at the moment
because it has post test reporting code at the end of the loop which
must run regardless of the test result.  By moving the post test
reporting to the start of the next loop iteration, we can clean up
the code substantially by using continue directives where
appropriate.

Also, for cases where we haven't run the test or it's already been
marked as failed, don't bother running the filesystem/dmesg checks
for failure as we're already going to report the test as failed.

This touches almost all of the loop, so get rid of the remaining
4 space indents inside the loop while moving all this code around.

[Eryu: fixed wrong test seq name issue in xUnit report when test hit
"continue" in the check loop, e.g. notrun, with Dave ACKing the fix]

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: Add tests for overlay metadata only copy up feature
Vivek Goyal [Fri, 1 Jun 2018 12:59:58 +0000 (08:59 -0400)]
overlay: Add tests for overlay metadata only copy up feature

Add tests for metadata only copy up feature.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: introduce btrfs/volume group
Anand Jain [Tue, 29 May 2018 05:56:12 +0000 (13:56 +0800)]
btrfs: introduce btrfs/volume group

The btrfs/volume group represent a set of btrfs test-cases, which
shall intend to verify the relevant btrfs volume operations.

Under this new group all the existing btrfs/replace group would come
under, and also the device operations test cases which does not have
any group as of now. This group is helpful to verify the btrfs
volume related changes.

Run as
  ./check -g btrfs/volume

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: seed device delete test
Anand Jain [Fri, 1 Jun 2018 15:57:26 +0000 (23:57 +0800)]
btrfs: seed device delete test

Test case to verify that a seed device can be deleted

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: seed device replace test
Anand Jain [Fri, 1 Jun 2018 15:57:25 +0000 (23:57 +0800)]
btrfs: seed device replace test

Test case to verify that a seed device can be replaced

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: nested seed device test
Anand Jain [Fri, 1 Jun 2018 15:57:24 +0000 (23:57 +0800)]
btrfs: nested seed device test

Test case to verify that a sprout device can be a seed device

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: add seed sprout functionality test
Anand Jain [Fri, 1 Jun 2018 15:57:23 +0000 (23:57 +0800)]
btrfs: add seed sprout functionality test

Create a seed device and add the sprout device to it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/009: don't run for btrfs if PAGE_SIZE > 4096
Mark Fasheh [Tue, 29 May 2018 22:34:30 +0000 (00:34 +0200)]
generic/009: don't run for btrfs if PAGE_SIZE > 4096

Btrfs has the same issue as XFS here in that the extent layout on a
> 4096 page size system will not match what is reflected in the test
output.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoext4/306: Fixup resize2fs usage
Jan Kara [Tue, 29 May 2018 16:56:01 +0000 (18:56 +0200)]
ext4/306: Fixup resize2fs usage

Use $RESIZE2FS_PROG instead of direct name to call program with full
path. Also add an appropriate feature test.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoext4/010: Fixup resize2fs and dumpe2fs usage
Jan Kara [Tue, 29 May 2018 16:56:00 +0000 (18:56 +0200)]
ext4/010: Fixup resize2fs and dumpe2fs usage

Use $RESIZE2FS_PROG and $DUMPE2FS_PROG instead of names directly to
make progs be executed with full path. Also add proper feature test
macros.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoext4/032: Fix up resize2fs usage
Jan Kara [Tue, 29 May 2018 16:55:59 +0000 (18:55 +0200)]
ext4/032: Fix up resize2fs usage

The test uses resize2fs(8) without proper feature test macro and
also without specifying full path to it. Fix that.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/310: Cleanup
Jan Kara [Tue, 29 May 2018 16:55:58 +0000 (18:55 +0200)]
xfs/310: Cleanup

Cleanup couple of things that were objected to when creating test
ext4/033 out of this one.

Use _require_scratch_nocheck instead of recreating scratch fs before
exiting. Avoid needless cleanup of dmhugedev on exit - _cleanup
takes care of that. Use _scratch_unmount where possible.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoext4: Test for s_inodes_count overflow during fs resize
Jan Kara [Tue, 29 May 2018 16:55:57 +0000 (18:55 +0200)]
ext4: Test for s_inodes_count overflow during fs resize

Test for overflow of s_inodes_count during filesystem resizing.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agodmhugedisk: Allow specifying of chunk size
Jan Kara [Tue, 29 May 2018 16:55:56 +0000 (18:55 +0200)]
dmhugedisk: Allow specifying of chunk size

Ext4 will want to use dmhugedisk infrastructure for testing resize
bugs.  Ext4 fs images are rather sparse (especially with smaller
block sizes) so the current chunk size of 512 sectors leads to large
space consumption.  Allow test to specify chunk size.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: Make ./new work for non-root user
Jan Kara [Tue, 29 May 2018 16:51:19 +0000 (18:51 +0200)]
fstests: Make ./new work for non-root user

Currently 'new' script sources common/config which tries to find
mkfs and fails if not found (which is likely for non-root user).
This is inconvenient as development usually does not happen as root.
In fact the vast majority of setup in common/config and common/rc is
not necessary for 'new'. Split out the necessary bits into new
common/test_names and use it in 'new'. Cleanup common/rc and
common/config now that they're only used from 'check' and 'setup'.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: get rid of set_prog_path
Dave Chinner [Tue, 29 May 2018 16:51:18 +0000 (18:51 +0200)]
fstests: get rid of set_prog_path

It's just a one line wrapper that adds complexity, remove it. Move
the couple of calls in tests to common/config, but leave the xfsdump
setup in place and just convert it.

[Eryu: add the missing CHECKBASHISMS_PROG definition, define
mkfs.btrfs and mkfs.f2fs with set_mkfs_prog_path_with_opts]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: update the punch, collapse, insert, and zero groups
Theodore Ts'o [Tue, 29 May 2018 19:01:28 +0000 (15:01 -0400)]
fstests: update the punch, collapse, insert, and zero groups

Update the group files to annotate those tests which have a
_require_xfs_io_command for punch, collapse, insert, and zero.  This
makes it easier to exclude tests that use one of these fallocate
commands.  Or if you want to specifically test for those fallocate
commands you can do this.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/206: filter/fix for minor geometry reporting changes
Eric Sandeen [Fri, 25 May 2018 14:00:59 +0000 (09:00 -0500)]
xfs/206: filter/fix for minor geometry reporting changes

The pending common geometry printing function has removed the fiddly
little differences between the various utilities, so now we'll need
to accommodate that in xfs/206, which looks at mkfs & growfs output.

all now print "internal log" vs. just "internal"
ascii-ci now always has a "," after it

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/484: Need another process to check record locks
Xiao Yang [Mon, 21 May 2018 05:42:00 +0000 (13:42 +0800)]
generic/484: Need another process to check record locks

According to fcntl(2) manpage, A single process always gets F_UNLCK
in the l_type field when using fcntl(F_GETLK) to acquire the
existing lock set by itself because it could convert the existing
lock to a new lock unconditionally.  So we need another process to
check if the lock exists.

Also remove redundant exit(0).

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Xiong Zhou <xzhou@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/447: fix typo
Darrick J. Wong [Wed, 23 May 2018 15:49:07 +0000 (08:49 -0700)]
xfs/447: fix typo

Fix a trivial typo that keeps barfing up:
./tests/xfs/447: line 60: /dev_null: Read-only file system

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocheck: Make the test harness unmount fs when finishing a test
Xiao Yang [Tue, 22 May 2018 09:49:59 +0000 (17:49 +0800)]
check: Make the test harness unmount fs when finishing a test

Finishing xfs/132 left a shutdown scratch fs and the test harness
didn't unmount the fs(because we told it not to check the fs) so the
test harness called by subsequent xfs/133 tried to "test -d
$SCRATCH_MNT" and received the IO error from the dead fs.

i.e. Running xfs/132 and xfs/133 together got the following error:
------------------------------------------------------------
...
xfs/132 1s ... 1s
xfs/133 1s ... [failed, exit status 1] - output mismatch (see /var/lib/xfstests/results//xfs/133.out.bad)
...
QA output created by 133
-Format and mount
-Corrupt filesystem
-Remount, try to append
-Write did not succeed (ok).
+SCRATCH_DEV=/dev/sda11 is mounted but not on SCRATCH_MNT=common/config: - aborting
+Already mounted result:
+/dev/sda11 /mnt/xfstests/scratch
...
------------------------------------------------------------

Even if we don't check fs, the test harness is supposed to unmount
fs and return an initial state before running the next test.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test invalid swap file activation
Omar Sandoval [Wed, 16 May 2018 20:38:49 +0000 (13:38 -0700)]
generic: test invalid swap file activation

Swap files cannot have holes, and they must at least two pages.
swapon(8) and mkswap(8) have stricter restrictions, so add versions
of those commands without any restrictions.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: add test for truncate/fpunch of an active swapfile
Omar Sandoval [Wed, 16 May 2018 20:38:48 +0000 (13:38 -0700)]
generic: add test for truncate/fpunch of an active swapfile

These should not be allowed.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: add test for dedupe on an active swapfile
Omar Sandoval [Wed, 16 May 2018 20:38:47 +0000 (13:38 -0700)]
generic: add test for dedupe on an active swapfile

Similar to generic/356 that makes sure we can't dedupe an active
swapfile.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: enable swapfile tests on Btrfs
Omar Sandoval [Tue, 22 May 2018 23:33:57 +0000 (16:33 -0700)]
generic: enable swapfile tests on Btrfs

Commit 8c96cfbfe530 ("generic/35[67]: disable swapfile tests on
Btrfs") disabled the swapfile tests on Btrfs because it did not
support swapfiles at the time. Now that we're adding support, we
want these tests to run, but they don't. _require_scratch_swapfile
always fails for Btrfs because swapfiles on Btrfs must be set to
nocow. After fixing that, generic/356 and generic/357 fail for the
same reason. After fixing _that_, both tests still fail because we
don't allow reflinking a non-checksummed extent (which nocow
implies) to a checksummed extent.

Add a helper for formatting a swap file which does the chattr, and
chattr the second file, which gets these tests running on kernels
supporting Btrfs swapfiles.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofstests: create swap group
Omar Sandoval [Wed, 16 May 2018 20:38:45 +0000 (13:38 -0700)]
fstests: create swap group

I'm going to add a bunch of tests for swap files, so create a group
for them and add the existing tests.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/475: fix confusing comment
Darrick J. Wong [Mon, 21 May 2018 16:07:34 +0000 (09:07 -0700)]
generic/475: fix confusing comment

The comment about the dmerror switcheroo is hard to understand and
wrong.  Fix both problems by rewriting it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/490: fix cleanup function
Theodore Ts'o [Sun, 20 May 2018 18:45:17 +0000 (14:45 -0400)]
generic/490: fix cleanup function

generic/490 fails because cleanup tries to delete . and .. since $tmp
is left unset, and so "rm -f $tmp.*" does nothing useful. Instead
define $tmp and delete temp files created by seek_sanity_test.

[Eryu: define $tmp and remove $tmp.* too on cleanup]

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/quota: sort lines of repquota output
Zorro Lang [Sun, 20 May 2018 16:22:02 +0000 (00:22 +0800)]
common/quota: sort lines of repquota output

The golden image of some cases (e.g: generic/305 generic/326
generic/327 generic/328 xfs/214 xfs/330 and xfs/440) depend on the
output of repquota() function.

When it reports multi-users, we can't control the order of lines,
then always hit failures likes:

  ...
   Create the original files
  -root 3072 0 0
   nobody 0 0 0
   fsgqa 0 0 0
  +root 3072 0 0
  ...

So sort the lines to make sure it won't break the golden image.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: drop test 472
Theodore Ts'o [Sun, 20 May 2018 19:46:08 +0000 (15:46 -0400)]
generic: drop test 472

From Goldwyn Rodrigues <rgoldwyn@suse.de>:

   "From earlier discussions, In between errors of a direct I/O cannot
   be handled correctly and may need a lot of tracking that it is not
   worth performing.

   It would be better to drop this test case and add in the documentation
   that a direct I/O error could mean that the write() may or may not have
   occurred and underlying data may be inconsistent."

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: add tests 405 and 459 to the group 'thin'
Theodore Ts'o [Sat, 19 May 2018 21:47:19 +0000 (17:47 -0400)]
generic: add tests 405 and 459 to the group 'thin'

Currently the only test in group 'thin' is 347.  On some recent
kernels tests that use dm-thin causing kernel crashes, so it's useful
to be able to be exclude all tests that use dm-thin.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoreport: make sure control charcters are encoded in xUnit report
Theodore Ts'o [Sat, 19 May 2018 17:43:10 +0000 (13:43 -0400)]
report: make sure control charcters are encoded in xUnit report

Control characters (such as backspace, used in progress reports by
mkfs.ext4, for example) can make Python's XML parsers choke, claiming
that it is an invalid XML document.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: Handle missing [gs]etcap tools
Jan Kara [Fri, 18 May 2018 08:02:39 +0000 (10:02 +0200)]
generic: Handle missing [gs]etcap tools

Add proper requires for getcap and setcap tools to tests that need
them.  Also define standard variables GETCAP_PROG and SETCAP_PROG.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test online label ioctl
Eric Sandeen [Thu, 17 May 2018 15:28:26 +0000 (10:28 -0500)]
generic: test online label ioctl

This tests the online label ioctl that btrfs has, which has been
recently proposed for XFS.

To run, it requires an updated xfs_io with the label command and a
filesystem that supports it

A slight change here to _require_xfs_io_command as well, so that
tests which simply fail with "Inappropriate ioctl" can be caught in
the common case.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/459: use xfs_freeze instead of fsfreeze
Amir Goldstein [Mon, 14 May 2018 05:49:49 +0000 (08:49 +0300)]
generic/459: use xfs_freeze instead of fsfreeze

This is what all other tests use as well as _require_freeze

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/486: Get rid of the redundant error=%d printing
Xiao Yang [Thu, 17 May 2018 03:32:27 +0000 (11:32 +0800)]
generic/486: Get rid of the redundant error=%d printing

1) Without the fix, perror() can indicate the actual error(ENODATA).
2) After calling perror() and redirecting the output of perror()
   to a file, errno seems to be set to EINVAL unexpectedly.
   See the following mail for detailed info:
   https://www.spinics.net/lists/fstests/msg09675.html

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/quota: Fix _qmount_options for ext4 journalled quotas
Jan Kara [Mon, 14 May 2018 17:03:51 +0000 (19:03 +0200)]
common/quota: Fix _qmount_options for ext4 journalled quotas

_qmount_options didn't properly replace ext[34] journalled quotas
mount options. As such the mount option string got garbled and the
test (e.g. generic/379) failed.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/quota: Make project quota handling work for ext2 & ext3
Jan Kara [Mon, 14 May 2018 17:03:49 +0000 (19:03 +0200)]
common/quota: Make project quota handling work for ext2 & ext3

Project quota can work for ext2 & ext3 the same way as for ext4.
Handle them properly as currently the tests just fail because of
unknown prjquota mount option. After this patch, tests will be "not
run" because ext4 driver refuses to use project quota mount options
for "old" fs types.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test first read with freeze right after mount
Amir Goldstein [Mon, 14 May 2018 05:49:51 +0000 (08:49 +0300)]
generic: test first read with freeze right after mount

With ext4, this leads to freeze proection bypass WARN_ON in
ext4_journal_check_start.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofstests: define and use TIMEOUT_PROG
Amir Goldstein [Mon, 14 May 2018 05:49:50 +0000 (08:49 +0300)]
fstests: define and use TIMEOUT_PROG

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: Add SEEK_DATA tests for offsets in the middle of holes
Jan Kara [Mon, 14 May 2018 09:47:07 +0000 (11:47 +0200)]
generic: Add SEEK_DATA tests for offsets in the middle of holes

ext4 had a bug for files with indirect extents where it wrongly
reported a size of a hole in some cases and thus SEEK_DATA
implementation could skip some data in a file. Test for that. The
problem is fixed by patch "ext4: Fix hole length detection in
ext4_ind_map_blocks()".

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test for fsync of file with xattrs
Filipe Manana [Fri, 11 May 2018 15:43:43 +0000 (16:43 +0100)]
generic: test for fsync of file with xattrs

Test that xattrs are not lost after calling fsync multiple times
with a filesystem commit in between the fsync calls.

This test is motivated by a bug found in btrfs which is fixed by a
patch for the linux kernel titled:

  Btrfs: fix xattr loss after power failure

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: test mount vs superblock shrinker races
Dave Chinner [Fri, 11 May 2018 02:11:52 +0000 (12:11 +1000)]
xfs: test mount vs superblock shrinker races

Test case for superblock shrinkers running while the filesystem is
being set up and/or torn down and tripping over inconsistent state.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: test ENOSPC caused by many orphan items
Omar Sandoval [Thu, 10 May 2018 06:21:55 +0000 (23:21 -0700)]
btrfs: test ENOSPC caused by many orphan items

Btrfs has a bug where we can prematurely ENOSPC if we have lots of
orphaned files, i.e., deleted files which are still open. Add a test
which repeatedly creates and deletes a file while keeping all of the
file descriptors open. This should succeed but doesn't on Btrfs
without the fix.

[Eryu: use multi_open_unlink command to keep files open & unlinked
instead of shell scripts]

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: skip growfs test on large device
Zorro Lang [Mon, 14 May 2018 14:41:53 +0000 (22:41 +0800)]
xfs: skip growfs test on large device

When test on large SCRATCH_DEV, growing a small XFS to huge size is
a horrible thing (e.g grow 128M to 500T) and it doesn't add any more
test coverage. So skip this kind of tests if LARGE_SCRATCH_DEV is
yes.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/484: add missing _require_test_program
Amir Goldstein [Sun, 13 May 2018 16:03:59 +0000 (19:03 +0300)]
generic/484: add missing _require_test_program

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: add test for seeing unseen fsync errors on newly open files
Jeff Layton [Wed, 9 May 2018 14:10:58 +0000 (10:10 -0400)]
btrfs: add test for seeing unseen fsync errors on newly open files

This adds a regression test for the following kernel patch:

    b4678df184b3 ("errseq: Always report a writeback error once")

This is motivated by some rather odd behavior done by the PostgreSQL
project. The main database writers will offload the fsync calls to a
separate process, which can open files after a writeback error has
already occurred.

This used to work with older kernels that reported the error to only
one fd, but with the errseq_t changes we lost the ability to see
errors that occurred before the open. The above patch restores that
behavior.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test for seeing unseen fsync errors on newly open files
Jeff Layton [Tue, 8 May 2018 12:52:24 +0000 (08:52 -0400)]
generic: test for seeing unseen fsync errors on newly open files

This adds a regression test for the following kernel patch:

    b4678df184b3 ("errseq: Always report a writeback error once")

This is motivated by some rather odd behavior done by the PostgreSQL
project. The main database writers will offload the fsync calls to a
separate process, which can open files after a writeback error has
already occurred.

This used to work with older kernels that reported the error to only
one fd, but with the errseq_t changes we lost the ability to see
errors that occurred before the open. The above patch restores that
behavior.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: checkbashisms in all script files
Darrick J. Wong [Tue, 8 May 2018 16:53:59 +0000 (09:53 -0700)]
xfs: checkbashisms in all script files

Find all the /bin/sh scripts in xfsprogs and check for bashisms.

Cc: sandeen@sandeen.net
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/{159,160}: require chattr instead of lsattr
Amir Goldstein [Sun, 6 May 2018 06:36:08 +0000 (09:36 +0300)]
generic/{159,160}: require chattr instead of lsattr

The tests _require_test_lsattr, but don't actually use lsattr. They
use chattr +i/-i, so require the appropriate command.

_require_test_lsattr checks the FS_IOC_GETFLAGS ioctl on a directory
and that is not supported in overlayfs. _require_chattr checks the
ioctl on a file, which is supported in overlayfs, so this change
makes the tests run and pass on overlayfs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/rc: decouple xfs_io flink check from xfs_io -T check
Amir Goldstein [Sun, 6 May 2018 06:36:07 +0000 (09:36 +0300)]
common/rc: decouple xfs_io flink check from xfs_io -T check

The 3 tests that _require_xfs_io_command "flink", actually require
O_TMPFILE support and flink command, but the former is far unlikely
to be missing. The test btrfs/058 doesn't even use the flink
command.

When running these tests on a filesystem that does not support
O_TMPFILE (e.g. overlayfs) the result is not very infomative:

 generic/004 1s ... [not run] xfs_io flink failed (old kernel/wrong fs?)

Decouple the requirements for "flink" command and "-T" command line
flag and require the former explicitly in tests that use it.

As a result the report is now more informative:

 generic/004 1s ... [not run] O_TMPFILE is not supported

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: test inobt/on disk free state mismatches
Dave Chinner [Mon, 7 May 2018 23:05:51 +0000 (09:05 +1000)]
xfs: test inobt/on disk free state mismatches

Fuzzing has recently uncovered a couple of conditions where we don't
detect corruptions that reallocate already allocated inodes. This
test exercises those cases, and checks that we shut down the
filesystem appropriately when such a corruption occurs.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofstests: many dangerous+auto tests are not dangerous anymore
Dave Chinner [Sun, 6 May 2018 23:05:35 +0000 (09:05 +1000)]
fstests: many dangerous+auto tests are not dangerous anymore

There are a bunch of tests that are run by the auto group that are
marked dangerous. This was done because the test exercised a crash
or other fatal error that has since been fixed. Remove the dangerous
tag from the auto tests that pass on a 4.17-rc3 kernel as they are
not dangerous anymore.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofstests: remove old electric fence support
Dave Chinner [Sun, 6 May 2018 22:45:31 +0000 (08:45 +1000)]
fstests: remove old electric fence support

Just not used anymore.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agooverlay: test multiple origin references to the same lower file
Amir Goldstein [Fri, 4 May 2018 09:41:31 +0000 (12:41 +0300)]
overlay: test multiple origin references to the same lower file

Multiple origin references to the same lower file from upper files
that are not hardlinks will falsely return the same st_ino/st_dev
for two different overlay files and will cause 'diff' to falsely
report that content of files is the same when it is not.

This test checks that overlayfs detects and fails lookup of a
multiply referenced origin.

The check for multiply referenced origin was a by-product of kernel
commit 31747eda41ef ("ovl: hash directory inodes for fsnotify")

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agooverlay/049: update fix commit id
Amir Goldstein [Fri, 4 May 2018 09:41:30 +0000 (12:41 +0300)]
overlay/049: update fix commit id

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/132: remove duplicate test
Amir Goldstein [Sat, 5 May 2018 10:31:22 +0000 (13:31 +0300)]
xfs/132: remove duplicate test

Test description says: "This is the same test as generic/156 except
that we also check the inode reflink flag.", only since commit
f1c3fee ("xfs: remove NOCOW_FL testing from test") it is almost
exactly the same test as generic/156.
almost - because since xfs/132 diverged from generic/156 the change
911efb0 ("reflink: change to relative margins") is only applied to
the original test.

Anyway, there doesn't seem to be a reason to keep this duplicated
test anymore, so remove it.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoREADME: document the new default run mode
Dave Chinner [Sat, 5 May 2018 00:19:51 +0000 (10:19 +1000)]
README: document the new default run mode

Also document the new way to run all tests (i.e. check -g all) and
clean up all the stray whitespace in the readme file.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocheck: run auto test group by default
Dave Chinner [Fri, 4 May 2018 00:05:09 +0000 (10:05 +1000)]
check: run auto test group by default

Everyone who starts using fstests runs "check" without parameters,
and then has problems with it running dangerous tests. most people
just want fstests to act as a regression test suite, not a fuzzer or
exercise known crash conditions. Hence make the default behaviour to
be "run the auto group" rather than "run every test".

To enable people to run all tests easily (if they really want to)
add a special group keyword named "all". This wildcard will trigger
selecting all the tests in fstests as per the original "check
without parameters" behaviour.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobuild: Use the original install-sh file from SGI
Theodore Ts'o [Thu, 3 May 2018 05:07:28 +0000 (01:07 -0400)]
build: Use the original install-sh file from SGI

The install-sh file is much more efficient than the libtool version
(50% faster wall clock time; much more than that when running in a
qemu emulation build environment).  There doesn't seem to be any
real need for the libtool version, so bring back the original
install-sh script.

[Eryu: move install-sh to include dir and copy it from there after
libtoolize in Makefile]

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: fix blocktrash fuzzers
Darrick J. Wong [Tue, 1 May 2018 15:40:17 +0000 (08:40 -0700)]
xfs: fix blocktrash fuzzers

The blocktrash fuzz tests for xfs will try to mount and write to the
filesystem after corrupting it.  However, the mount may not necessarily
succeed, in which case we must not write junk to the root filesystem.
Use the new _try_scratch_mount to guard against that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/422: add fsstress to the freeze-and-rmap-repair race test
Darrick J. Wong [Tue, 1 May 2018 15:40:03 +0000 (08:40 -0700)]
xfs/422: add fsstress to the freeze-and-rmap-repair race test

Add fsstress to the pile of things that we race with rmap repair to
ensure that the rmap repair isolates the filesystem correctly while it
is doing its repairs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/453: test creation of malicious directory entries
Darrick J. Wong [Tue, 1 May 2018 15:39:57 +0000 (08:39 -0700)]
generic/453: test creation of malicious directory entries

Create malicious . and .. entries (you didn't see the zero-width
joiners at the end, did you?) in a directory to see if scrub will pick
them up.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/45[34]: test unicode confusables
Darrick J. Wong [Tue, 1 May 2018 15:39:51 +0000 (08:39 -0700)]
generic/45[34]: test unicode confusables

Test if a filesystem will allow us to create names with easily
confusable unicode sequences (character spoofing) and, if on XFS,
whether or not xfs_scrub will notice.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/45[34]: check unicode names only if xfs_scrub linked against libicu
Darrick J. Wong [Tue, 1 May 2018 15:39:45 +0000 (08:39 -0700)]
generic/45[34]: check unicode names only if xfs_scrub linked against libicu

Since we've rewriting the xfs_scrub Unicode name scanner to use libicu
to detect potential spoof names, change our check for unicode-enabled
name scanning xfs_scrub to look for libicu instead of libunistring,
adjust the golden output to reflect the new library's detection
capabilities and make sure we get all the scrub output by invoking with
-v.

Note that this requires xfsprogs 4.16 or newer; since xfs_scrub is (for
now) an experimental program, we don't care about breaking backwards
compatibility.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/45[34]: add unicode directional override checks
Darrick J. Wong [Tue, 1 May 2018 15:39:39 +0000 (08:39 -0700)]
generic/45[34]: add unicode directional override checks

Try injecting a Unicode directional override character in the middle of
a name to see if the fs can handle it / xfs_scrub will complain.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>