xfstests-dev.git
7 years agogeneric: fix $tmp path in tests
Eryu Guan [Sat, 12 Nov 2016 18:12:33 +0000 (02:12 +0800)]
generic: fix $tmp path in tests

Some tests use "tmp/$$" as $tmp, and this would result in ENOENT
failure if $tmp is referenced in helpers or tests, because we have
no "tmp" dir in pwd.

Fix them to use "/tmp/$$" as all other tests do.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/38[3-6]: require project quota to be enabled on SCRATCH_DEV
Eryu Guan [Sat, 12 Nov 2016 17:22:26 +0000 (01:22 +0800)]
generic/38[3-6]: require project quota to be enabled on SCRATCH_DEV

generic/38[3-6] are made generic from xfs tests to test project
quota on other filesystems, e.g. ext4. But we should make sure
project quota is enabled in between of _scratch_enable_pquota and
_qmount. Otherwise mount will fail if there's no project quota
support on SCRATCH_DEV, e.g. ext2 and ext3.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/37[3-4]: use bind mount instead of 2nd _scratch_mount
Amir Goldstein [Sun, 13 Nov 2016 13:49:37 +0000 (15:49 +0200)]
generic/37[3-4]: use bind mount instead of 2nd _scratch_mount

generic/373 and generic/374 test that cross-mountpoint reflink/dedupe
fail with EXDEV.

For this test, _scratch_mount is called a 2nd time with same mount
arguments, but a different value of SCRATCH_MNT.

This practice is incorrect for overlayfs, which should not be using
the same upper/work dirs on two different overlay super blocks.

Change the test to use bind mount instead, which results in the
expected setup for both block device mount and overlay mount.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: fix fsx fallocate error messages
Christoph Hellwig [Sat, 12 Nov 2016 16:48:49 +0000 (08:48 -0800)]
fstests: fix fsx fallocate error messages

Many of the commands using fallocate had an extra % at the beggining
of the error messages, missed the 0x prefix for hex output and printed
the length where it should print the end of the region.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: testcase for kernelspace xfs_fsr extent handling flaw
Eric Sandeen [Sat, 5 Nov 2016 02:00:09 +0000 (21:00 -0500)]
xfs: testcase for kernelspace xfs_fsr extent handling flaw

This is a testcase for a bug which goes way back; googling
"xfs_trans_log_inode NULL pointer dereference" yields sporadic
reports over several years.

The test sets up several two-extent files with speculative
preallocation on them, and then runs xfs_fsr.  The kernelside
code ignores the preallocation, and therefore sets up the
temporary inode incorrectly after the inode fork swap.

It is a "dangerous" test because the extent mishandling on
the temporary inode causes a null pointer dereference and
oops when the inode's i_itemp pointer gets overwritten
and we blow up in logging code that tries to use it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/021: filter out detailed array element info from xfs_db
Eryu Guan [Fri, 4 Nov 2016 16:16:10 +0000 (00:16 +0800)]
xfs/021: filter out detailed array element info from xfs_db

Starting from xfsprogs commit 384283555871 ("xfs_db: print one array
element per line"), xfs_db prints one array element per line. This
breaks the filter in xfs/021, which now fails as:

  hdr.freemap[0-2] = [base,size] [FREEMAP..]
 +0:[104,1892]
 +1:[0,0]
 +2:[0,0]
  entries[0-2] = [hashval,nameidx,incomplete,root,local] [ENTRIES..]

So we have extra lines that need to be filtered out,

Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: fix some minor problems testing ocfs2
Darrick J. Wong [Wed, 9 Nov 2016 23:00:17 +0000 (15:00 -0800)]
fstests: fix some minor problems testing ocfs2

There are a a few things about ocfs2 tools that need special-casing in
xfstests, so fix them so that we can start testing ocfs2.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agobtrfs: Check false ENOSPC bug caused by incorrect metadata reserve
Qu Wenruo [Thu, 10 Nov 2016 03:18:48 +0000 (11:18 +0800)]
btrfs: Check false ENOSPC bug caused by incorrect metadata reserve

Due to the fact that btrfs uses different max extent size for
compressed and non-compressed write, it calculates metadata
reservation incorrectly.

This can leads to false ENOSPC alert for compressed write.

This test case will check it by using small fs and do parallel write
to trigger it.

It's highly recommened to use MOUNT_OPTIONS="-o compress" and
MKFS_OPTIONS="-n 64k" to trigger it. Without compression, it won't
be triggered.

The fix is not merged and may change in the future, but the function
is good enough:

btrfs: improve inode's outstanding_extents computation
btrfs: fix false enospc for compression

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: test xfs_copy V5 XFS without -d option
Zorro Lang [Tue, 8 Nov 2016 05:33:50 +0000 (13:33 +0800)]
fstests: test xfs_copy V5 XFS without -d option

Before xfsprogs commit a872b62 (xfs_copy: band-aids for CRC
filesystems), xfs_copy requires the "-d" option to copy a V5 XFS,
because it can't rewrite the UUID of V5 XFS properly.

Now xfs_copy already full support to copy a V5 XFS. But for above
old problem, xfstests use below patch to make sure xfs_copy always
use "-d" option to copy a V5 XFS:

  8346e53 common: append -d option to XFS_COPY_PROG when testing v5 xfs

That cause xfstests miss the coverage of copying a V5 XFS without
"-d". For test this feature I did below things:

  1. Changed init_rc(), add "-d" to $XFS_COPY_PROG if xfs_copy can't
     copy a V5 XFS properly.
  2. xfs/073 test V4 xfs forcibly by specify "-m crc=0" in case. I
     think it's useless now, so remove it.
  3. Changed xfs/032. If xfs_copy full support to copy a V5 XFS, test
     with and without "-d" option, or only test with "-d" option.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: multi-thread freeze/unfreeze test under fsstress
Zorro Lang [Mon, 7 Nov 2016 06:30:12 +0000 (14:30 +0800)]
generic: multi-thread freeze/unfreeze test under fsstress

Multi-threads freeze/unfreeze maybe trigger some bugs, e.g: panic,
hang or data corruption etc. It does't check the return value of
freeze/unfreeze, but it tries to make sure fsstress won't run fails,
and no any other bugs happen.

[eguan: add comment on why we check _scratch_mount failure]

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: make xfs_io mandatory
Eryu Guan [Sun, 6 Nov 2016 17:43:33 +0000 (01:43 +0800)]
fstests: make xfs_io mandatory

_test_inode_flag() and _test_inode_extsz() use "which $XFS_IO_PROG"
to check if xfs_io command is available. And "-i" option was added
to XFS_IO_PROG varibable by commit 54659ecdb575 ("fstests: run
xfs_io with -i option if supported"). So the command becomes "which
/usr/sbin/xfs_io -i", and it stops and waits for input from stdin,
because "-i" option of "which" means "Read aliases from stdin".

I've seen xfs/008 hang when testing with latest xfsprogs, where
xfs_io has "-i" support.

Fix it by removing the xfs_io command detections, and making xfs_io
mandatory in common/config.

Also fix the indentions in these functions, use tab instead of
spaces, while we're at it.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agocommon: add CephFS support
Joao Eduardo Luis [Fri, 4 Nov 2016 10:04:39 +0000 (11:04 +0100)]
common: add CephFS support

Add basic CephFS support. No new CephFS specific tests are included,
just FSTYP="ceph" enablement.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofilter: xfs_io output has dropped "64" from error messages
Dave Chinner [Wed, 2 Nov 2016 21:15:25 +0000 (08:15 +1100)]
filter: xfs_io output has dropped "64" from error messages

Upstream xfs_io has been converted to always use LFS compliant
(i.e. 64 bit) pwrite() rather than pwrite64(). Similar changes have
been made for multiple syscalls that have "*64" variants. hence the
error output of all these commands has changed, such as "pwrite64:
..." to "pwrite: ....".

Make a filter to catch the *64 variants and strip it, and
convert all the golden output to use the non-*64 variant. This will
make all golden output matching work correctly regardless of what
version of xfs_io is in use.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agosrc/seek_sanity_test: discover allocation size
Benjamin Coddington [Mon, 24 Oct 2016 13:52:41 +0000 (09:52 -0400)]
src/seek_sanity_test: discover allocation size

Try to discover the allocation size.  For NFS, the st_blksize is
optimized for the network, and will usually be much larger than the
allocation size of the exported filesystem, which may trigger
preallocation strategies in the exported filesystem causing the seek
tests here to fail.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/054: only filter ROOT_INO at the beginning
Eryu Guan [Sat, 22 Oct 2016 05:27:33 +0000 (13:27 +0800)]
xfs/054: only filter ROOT_INO at the beginning

In the test ROOT_INO is filtered out and/or replaced, but if
ROOT_INO is also 32, more "32"s are filtered and replaced than
expected. This happens to me when testing 512B block size XFS and 1k
block size CRC enabled XFS.

Fix it by filtering out only ROOT_INO at the beginning of a line,
and removing all "g" modifiers in sed expressions.

Also the ROOT_INO should be the root inode number of TEST_DIR not
SCRATCH_MNT.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/314: remove from acl group
Eric Biggers [Fri, 21 Oct 2016 21:22:06 +0000 (14:22 -0700)]
generic/314: remove from acl group

generic/314 no longer tests POSIX ACLs.  It only tests the SGID bit.
Therefore, it should not be in the acl group anymore.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agooverlay/013: adjust test expectation to kernel v4.8
Amir Goldstein [Wed, 19 Oct 2016 08:52:33 +0000 (11:52 +0300)]
overlay/013: adjust test expectation to kernel v4.8

Commit 4d0c5ba (vfs: do get_write_access() on upper layer of overlayfs)
that was merged for kernel v4.8 changes the behavior of execve+truncate
in a subtle way.

When file is executed from lower and then truncated, the truncation is
allowed, becasue it only affects the size of the copied up file and does
not affect the VM mapping of the executed lower file.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agooverlay/013: fix bug in test_upper creation
Amir Goldstein [Wed, 19 Oct 2016 08:52:32 +0000 (11:52 +0300)]
overlay/013: fix bug in test_upper creation

test_upper file was supposed to be in upper layer,
but it was wrongly created in lower layer.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agot_truncate_self: describe self better in error message
Amir Goldstein [Wed, 19 Oct 2016 08:52:31 +0000 (11:52 +0300)]
t_truncate_self: describe self better in error message

Include the name of the program that is trying to trucate itself
to error messages to distinguish between output for different
test cases (e.g. test_lower and test_upper in overlay/013).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: Check linking O_TMPFILE into namespace with POSIX ACLs
Andreas Gruenbacher [Wed, 19 Oct 2016 11:50:14 +0000 (13:50 +0200)]
generic: Check linking O_TMPFILE into namespace with POSIX ACLs

When an O_TMPFILE file is linked into a directory with a POSIX
default ACL, the file should inherit the default ACL and the umask
needs to be ignored.

[eguan introduced testdir var and added test to acl group]

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: remove the device parameter from __populate_check_xfs_dir
Xiao Yang [Wed, 19 Oct 2016 05:33:07 +0000 (13:33 +0800)]
xfs: remove the device parameter from __populate_check_xfs_dir

In commit c08ebd092 ("xfs: fix $XFS_DB_PROG usage"), the need for
callers to pass the device to populate into
__populate_check_xfs_dir() was removed. So we can now clean up all
the callers by removing the device 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 <eguan@redhat.com>
7 years agoxfs: fix more xfs_db open-coding instances
Darrick J. Wong [Mon, 17 Oct 2016 22:09:34 +0000 (15:09 -0700)]
xfs: fix more xfs_db open-coding instances

Convert some more cases of 'xfs_db $SCRATCH_DEV' to _scratch_xfs_db
that were left out of the initial cleanup patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: fix fallocate commands that need the unshare switch
Darrick J. Wong [Mon, 17 Oct 2016 22:09:28 +0000 (15:09 -0700)]
fstests: fix fallocate commands that need the unshare switch

We re-added the UNSHARE flag to fallocate, so go make sure that all
the unshare tests actually check that the installed copy of xfs_io
supports the 'funshare' command and that the underlying filesystem
understands the flag, and change the tests themselves to use
funshare.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: set the refcount btree cowflag when setting up cow
Darrick J. Wong [Mon, 17 Oct 2016 22:09:21 +0000 (15:09 -0700)]
xfs: set the refcount btree cowflag when setting up cow

When we're setting up a fake cow extent in the refcountbt to test
cleanup of fake cow extents, set the cowflag in the record field
to reflect our new disk format of storing the staging extents in
the right side of the tree.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: run xfs_io with -i option if supported
Amir Goldstein [Mon, 17 Oct 2016 07:31:41 +0000 (10:31 +0300)]
fstests: run xfs_io with -i option if supported

Try to run xfs_io with command line option -i, which starts an idle
thread before performing any io.

The purpose of this idle thread is to test io from a multi threaded
process. With single threaded process, the file table is not shared
and file structs are not reference counted.

In order to improve the chance of detecting file struct reference
leaks, we should run xfs_io commands with this option as much as
possible.

Analysis of the effect of xfs_io -i on tests runtime showed that it
may lead to slightly longer run times in extreme cases (e.g +3s for
generic/132), but has a negligible effect on runtime of tests among
the 'quick' group (worst case +0.3s for generic/130).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: strip quotes from "$XFS_IO_PROG" call sites
Amir Goldstein [Mon, 17 Oct 2016 07:23:33 +0000 (10:23 +0300)]
fstests: strip quotes from "$XFS_IO_PROG" call sites

The value of "$XFS_IO_PROG" may contain extra flags after the
binary path (e.g. -F), so it is wrong to use the variable inside
quotes in xfs_io execution call sites.

This bug surfaced while testing the new xfs_io -i flag.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: fix call sites that used xfs_io directly
Amir Goldstein [Mon, 17 Oct 2016 07:23:32 +0000 (10:23 +0300)]
fstests: fix call sites that used xfs_io directly

Convert those few remaining call sites to use the XFS_IO_PROG env var.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/122: remove dead code
Eryu Guan [Sat, 8 Oct 2016 08:40:24 +0000 (16:40 +0800)]
xfs/122: remove dead code

Seems this hunk of dead code is used for debug purpose to inspect
what the output looks like after _attribute_filter. Just remove it.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/314: don't test SGID behavior after setfacl
Eric Biggers [Wed, 12 Oct 2016 22:03:08 +0000 (15:03 -0700)]
generic/314: don't test SGID behavior after setfacl

Linux 4.9 (since commit 073931017b49: "posix_acl: Clear SGID bit
when setting file permissions") now may clear the SGID bit when
setting a POSIX ACL, to match chmod() behavior.  This was making
generic/314 fail. Since SGID bit clearing on setfacl is already
tested by generic/375, just remove the problematic portion of
generic/314.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/375: test both regular file and directory
Eric Biggers [Wed, 12 Oct 2016 22:03:07 +0000 (15:03 -0700)]
generic/375: test both regular file and directory

generic/375 previously only tested SGID being cleared on a regular
file. It should test SGID being cleared on a directory too. Though
this is not required by POSIX, it is the Linux behavior.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agocommon/rc: use real device name in _sysfs_dev function
Zorro Lang [Tue, 11 Oct 2016 09:40:39 +0000 (17:40 +0800)]
common/rc: use real device name in _sysfs_dev function

_sysfs_dev try to find the major and minor device numbers of
SCRATCH_DEV, by 'stat -c%t $SCRATCH_DEV' and 'stat -c%T
$SCRATCH_DEV'.

But if the SCRATCH_DEV is symlink (e.g: /dev/mapper/
testvg-scratchdev), stat command can't find correct device numbers.
So try to find the real name of the SCRATCH_DEV at first.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: renumber tests after merge
Eryu Guan [Sat, 8 Oct 2016 06:02:04 +0000 (14:02 +0800)]
xfs: renumber tests after merge

Tests were merged with high seq numbers to avoid conflicts with
other tests. Now renumber them to contiguous numbers, as all other
tests have been merged correctly. This is easier to do than
assigning the final seq numbers at commit time.

Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: check copy-on-write fragmentation
Darrick J. Wong [Fri, 30 Sep 2016 02:24:02 +0000 (19:24 -0700)]
xfs: check copy-on-write fragmentation

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: test realtime rmapbt code
Darrick J. Wong [Fri, 30 Sep 2016 02:23:55 +0000 (19:23 -0700)]
xfs: test realtime rmapbt code

Test the realtime rmap btree code by exercising various IO patterns
on realtime files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: more rmapbt tests
Darrick J. Wong [Fri, 30 Sep 2016 02:23:47 +0000 (19:23 -0700)]
xfs: more rmapbt tests

More tests for the reverse mapping functionality.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: exercise and validate the xfs_io inode command
Eric Sandeen [Fri, 30 Sep 2016 02:32:25 +0000 (21:32 -0500)]
xfs: exercise and validate the xfs_io inode command

Run various modes of the xfs_io "inode" command.

This fails today, I have some patches to fix it up.
The "grep -q" for failures strings are fairly loose
because I'm changing them, and don't want to depend
on the exact error or usage message ...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: fix $XFS_DB_PROG usage
Darrick J. Wong [Fri, 30 Sep 2016 02:23:41 +0000 (19:23 -0700)]
xfs: fix $XFS_DB_PROG usage

xfs_db requires us to pass in the log device, if any; this can be
accomplished via _scratch_xfs_db_options (if we're operating on the
scratch device, anyway).  However, many of the tests/xfs/ scripts
pass only $SCRATCH_DEV directly, so they'll fail if we test with an
external log.  Fix that by adding a new _scratch_xfs_db helper.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: use get_block_size helper
Darrick J. Wong [Fri, 30 Sep 2016 02:23:34 +0000 (19:23 -0700)]
fstests: use get_block_size helper

Don't open code grabbing the block size; just use the helper.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofsx: fix compiler warning due to bad prototype
David Disseldorp [Fri, 30 Sep 2016 11:52:18 +0000 (13:52 +0200)]
fsx: fix compiler warning due to bad prototype

I see the following with gcc 4.8.5 [-Wunprototyped-calls]:
warning: call to function 'cleanup' without a real prototype

Fix this by moving the function definition up, and dropping the
prototype.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/032: test the next block size if mkfs fails
Zorro Lang [Fri, 30 Sep 2016 06:58:46 +0000 (14:58 +0800)]
xfs/032: test the next block size if mkfs fails

If test on a 512b sector size device, xfs/032 will try to do:

  mkfs.xfs -s size=512 -b size=512 ...

The 512b block size is not acceptable for V5 XFS. So if mkfs.xfs
fails, try next block size (blksize *= 2) directly.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/349,350,351: remove from quick group
Eryu Guan [Mon, 26 Sep 2016 11:13:05 +0000 (19:13 +0800)]
generic/349,350,351: remove from quick group

These tests are meant to test block devices, so they're not in auto
group. And quick group is a subset of auto group, so remove quick as
well.

Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/287: fix wrong seq number in test
Eryu Guan [Tue, 27 Sep 2016 14:13:02 +0000 (22:13 +0800)]
xfs/287: fix wrong seq number in test

It's 287 not 285.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/052: use _check_scratch_fs not _xfs_check
Eryu Guan [Mon, 26 Sep 2016 08:44:42 +0000 (16:44 +0800)]
generic/052: use _check_scratch_fs not _xfs_check

generic/052 was made generic from an xfs test, and generic functions
should be used not the xfs-specific ones.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/207,327: fsxattr no longer has the reflink flag
Darrick J. Wong [Thu, 29 Sep 2016 02:28:40 +0000 (19:28 -0700)]
xfs/207,327: fsxattr no longer has the reflink flag

The FS_XFLAG_REFLINK flag was removed from struct fsxattr prior to
the inclusion of reflink in XFS, so remove it from the test outputs.
Note that the inode flag still exists; it's simply not presented
to userspace any more.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/130: don't modify files after failed mount
Darrick J. Wong [Thu, 29 Sep 2016 02:28:34 +0000 (19:28 -0700)]
xfs/130: don't modify files after failed mount

In xfs/130, we try to mount a filesystem with the expectation that it
will fail.  Therefore, it is inappropriate to try to write to the
mountpoint, since it could otherwise be writable.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/122: decrease the log update done item sizes
Darrick J. Wong [Thu, 29 Sep 2016 02:28:27 +0000 (19:28 -0700)]
xfs/122: decrease the log update done item sizes

Redundant fields were removed from the rmap/refcount/bmap update done
log items, so fix the size tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: shutdown fs after log recovery
Brian Foster [Mon, 15 Aug 2016 12:56:26 +0000 (08:56 -0400)]
generic: shutdown fs after log recovery

XFS had a bug that lead to a possible out-of-order log recovery
situation (e.g., replay a stale modification from the log over more
recent metadata in destination buffer). This resulted in false
corruption reports during log recovery and thus mount failure.

This condition is caused by system crash or filesystem shutdown
shortly after a successful log recovery. Add a test to run a
combined workload, fs shutdown and log recovery loop known to
reproduce the problem on affected kernels.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/361: require that file system uses a real block device
Theodore Ts'o [Fri, 23 Sep 2016 20:05:20 +0000 (16:05 -0400)]
generic/361: require that file system uses a real block device

This test tries to use _mkfs_dev to format a loop device and then
tries to mount it.  For file systems that don't use block devices
(nfs, tmpfs, etc.) this is doomed to failure.  So skip this test if
$SCRATCH_DEV is not a block device.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/317: use id to get user id
Eryu Guan [Fri, 23 Sep 2016 15:32:27 +0000 (23:32 +0800)]
generic/317: use id to get user id

Greping username "fsgqa" in passwd file to get user id doesn't
always work, because the given username could match multiple
entries, e.g. when we have user "123456-fsgqa" (used by other tests)
in passwd file.

Fix it by using "id -u $qa_user" to get the user id directly.

Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agobtrfs: test free space tree mount options
Omar Sandoval [Thu, 22 Sep 2016 19:37:53 +0000 (12:37 -0700)]
btrfs: test free space tree mount options

The behavior of different combinations of space_cache mount options
wasn't well defined, which led to a regression between my initial
patches adding the free space tree and the 4.5 release. Add a test to
exercise all of the meaningful permutations of clear_cache,
nospace_cache, and space_cache.

This is a regression test for Linux kernel commit "Btrfs: fix mount -o
clear_cache,space_cache=v2".

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: truncate heavily reflinked file
Wang Xiaoguang [Fri, 23 Sep 2016 03:12:07 +0000 (11:12 +0800)]
generic: truncate heavily reflinked file

In btrfs, there is a bug about btrfs' truncate codes, it'll leak
some fs space as the truncate operation proceeds. If this truncate
operation is very large, later metadata request in this truncate
operation may fail for enospc error. I also have sent a kernel
patch fot btrfs to fix this issue.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: move now-generic xfs project quota tests generic
Eryu Guan [Fri, 23 Sep 2016 01:51:26 +0000 (09:51 +0800)]
fstests: move now-generic xfs project quota tests generic

Now that these tests have been made generic, move them into the
generic/ dir and update group files.

xfs/133 -> generic/383
xfs/134 -> generic/384
xfs/196 -> generic/385
xfs/262 -> generic/386

Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: make some xfs project quota tests generic
Eric Sandeen [Thu, 22 Sep 2016 22:51:03 +0000 (17:51 -0500)]
xfs: make some xfs project quota tests generic

This patch makes some xfs project quota tests generic,
so that there is at least some coverage on ext4 for this
(semi-)new feature.

It requires bleeding edge xfsprogs, so that xfs_quota and
xfs_io's chproj command can operate on "foreign" filesystems,
and requires relatively new e2fsprogs to enable the project
quota feature on-disk.

The mechanism for enabling project quota on ext4 is a bit
arcane, but hopefully I've encapsulated it reasonably well here.

Changes:

* look for "project" feature in _require_prjquota
* look for accounting not enforcement (-P) in _require_prjquota
* add a _scratch_enable_pquota to turn on project quota feature
* s/pquota/quota/ in _qmount_option for ext4
* add helper to test for xfs_io chproj on foreign filesystems
* switch from block to inode quota in xfs/133 because empty
  ext4 dirs consume one block
* cosmetic/generic changes for mkfs, require tests, etc.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: move now-generic quota tests to generic
Eric Sandeen [Tue, 20 Sep 2016 22:24:59 +0000 (17:24 -0500)]
fstests: move now-generic quota tests to generic

Now that these tests have been made generic, move them into
the generic/ dir and update group files.

xfs/054 -> generic/379
xfs/118 -> generic/380
xfs/138 -> generic/381
xfs/260 -> generic/382

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: modify quota tests to work on generic filesystems
Eric Sandeen [Thu, 22 Sep 2016 18:54:16 +0000 (13:54 -0500)]
xfs: modify quota tests to work on generic filesystems

Fix several xfs quota tests to work on non-xfs filesystems.

New _require function to be sure that the xfs_quota tool can operate
on foreign filesystems; if it can, and if it needs to, it adds "-f"
to the XFS_QUOTA_PROG variable.

Modify _qmount to do quotacheck/quotaon to mount and /enable/
quota.  On xfs this isn't needed and/or fails; it's ignored.

All quota-related options used as arguments to _qmount are changed
from i.e. uquota to i.e. usrquota; the latter is standard across
almost all linux filesytems, including xfs.

xfs/260 filters out the root/default quota line, because ext4
consumes a different amount of space than xfs, and it's not what
we're testing for, so just ignore it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/260: fix output to match actions
Eric Sandeen [Tue, 20 Sep 2016 22:15:47 +0000 (17:15 -0500)]
xfs/260: fix output to match actions

The test creates 30 inodes, but says it created 300.
Just fix that up so the repquota output matches the
comments in the output file.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: require scratch dev in tests using dm targets
Eryu Guan [Thu, 22 Sep 2016 08:52:36 +0000 (16:52 +0800)]
fstests: require scratch dev in tests using dm targets

We build dm device on top of scratch dev so we require $SCRATCH_DEV
to be a valid block device in _require_dm_target(). And we need to
_require_scratch before _require_dm_target, otherwise test fails if
there's no SCRATCH_DEV defined, where it should _notrun.

  +Usage: _require_block_device <dev>

So add _require_scratch_nocheck to generic/347 (we do the fs check
on thinp device), move _require_scratch before _require_dm_target in
xfs/006 and xfs/264.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agocommon/rc: fix fsmap check
Xiao Yang [Tue, 20 Sep 2016 05:23:12 +0000 (13:23 +0800)]
common/rc: fix fsmap check

We don't need -T to detect GETFSMAP and the flag doesn't exist
on really old versions of xfs_io, so just get rid of it.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: various operations on mounted fs
Zorro Lang [Wed, 14 Sep 2016 15:55:58 +0000 (23:55 +0800)]
xfs: various operations on mounted fs

xfsprogs takes use of ustat(2) to check if a given device is
mounted, but ustat(2) is deprecated and may not be available on
newer architectures, e.g. aarch64. In such cases, xfsprogs failed to
detect mounted device, which would result in something like
xfs_mdrestore overwriting a mounted XFS.

So adding a case to do xfs_mdrestore, xfs_copy, xfs_db, mkfs and
xfs_repair against mounted XFS to make sure they refuse to do so.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/098: fix xfs_repair on newer xfsprogs
Xiao Yang [Wed, 14 Sep 2016 02:52:36 +0000 (10:52 +0800)]
xfs/098: fix xfs_repair on newer xfsprogs

1) use _repair_scratch_fs instead of xfs_repair
   The obsolete xfs_repair always cleared the log regardless of
   whether it is corrupted and current xfs_repair only cleared the
   log when -L option is specified.  xfs_repair -L option should be
   used to clear it if xfs_repair failed to clear log.
2) catch non-zero return value instead of 2
   It can be applied to both the old return value 1 and the new
   return value 2
3) add filter_xfs_dmesg to ignore mount related warnings
   If we corrupt log and mount on a CONFIG_XFS_WARN build, there
   will be mount related warnings in dmesg as expected.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agooverlay: sgid inheritance over whiteout
Eryu Guan [Thu, 25 Aug 2016 08:16:12 +0000 (16:16 +0800)]
overlay: sgid inheritance over whiteout

Newly created files and dirs should inherit sgit bit from parent
dir, no matter the new files & dirs are created over whiteout or
not.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: test getbmapx shared extent reporting
Darrick J. Wong [Thu, 25 Aug 2016 23:29:30 +0000 (16:29 -0700)]
xfs: test getbmapx shared extent reporting

Test that getbmapx returns exact shared extents.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: test getfsmap ioctl
Darrick J. Wong [Thu, 25 Aug 2016 23:29:24 +0000 (16:29 -0700)]
xfs: test getfsmap ioctl

Add some simple tests for the new getfsmap ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: simple permission check on hard links
Eryu Guan [Wed, 7 Sep 2016 09:57:15 +0000 (17:57 +0800)]
generic: simple permission check on hard links

Overlayfs had a bug that hardlinks don't share inode, if
chmod/chown/etc. is performed on one of the links then the inode
belonging to the other one won't be updated. The following patch
fixed this issue:

51f7e52 ovl: share inode for hard link

This is a simple test that has nothing overlayfs specific, so make
it a generic test.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agocommon/rc: Enhance _exclude_scratch_mount_option to handle multiple options
Qu Wenruo [Thu, 8 Sep 2016 02:52:21 +0000 (10:52 +0800)]
common/rc: Enhance _exclude_scratch_mount_option to handle multiple options

Enhance _exclude_scratch_mount_option() function to normalize mount
options. Now it can understand and extract real mount option from
string like "-o opt1,opt2 -oopt3".

And now we do word grep to handle mount options like noinode_cache
and inode_cache.

Finally, allow it to accept multiple options at the same time. No
need for multiple _exclude_scratch_mount_option lines now

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/279: filter scsi debug device correctly
Eryu Guan [Mon, 5 Sep 2016 05:24:24 +0000 (13:24 +0800)]
xfs/279: filter scsi debug device correctly

This test assumes scsi debug device is "/dev/sd." when doing the
filter, but that isn't always true, I've seen failure like

  -mkfs with opts: DEVICE
  +mkfs with opts: DEVICEl

So use $SCSI_DEBUG_DEV to match the correct scsi debug device name.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agooverlay: copy-up lowerdir which has opaque xattr set
Eryu Guan [Mon, 8 Aug 2016 16:45:46 +0000 (00:45 +0800)]
overlay: copy-up lowerdir which has opaque xattr set

When copying up a directory with opaque xattr set, the xattr was
copied up as well, after a remount the opaque flag is honored so the
copied-up directory is treated as opaque, which causes files created
in the lowerdir to be hidden when using multiple lower directories.

This is fixed by "ovl: don't copy up opaqueness".

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agocommon/rc: introduce _overlay_mount_dirs helper
Eryu Guan [Tue, 9 Aug 2016 07:28:47 +0000 (15:28 +0800)]
common/rc: introduce _overlay_mount_dirs helper

Introduce a new _overlay_mount_dirs() helper to do the actual
overlay mount operation and factor _overlay_scratch_mount and
_overlay_mount code to use a single implemention of
_overlay_mount_dirs(). Also convert all bare mount of overlay in
tests to use it.

Suggested-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoext4/021: use $XFS_IO_PROG instead of xfs_io
Xiao Yang [Mon, 5 Sep 2016 05:56:47 +0000 (13:56 +0800)]
ext4/021: use $XFS_IO_PROG instead of xfs_io

We should use $XFS_IO_PROG to add "-F" option when we need it.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/122: check the ag reservation counter ioctl
Darrick J. Wong [Thu, 25 Aug 2016 23:29:43 +0000 (16:29 -0700)]
xfs/122: check the ag reservation counter ioctl

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/122: track xfs_scrub_metadata
Darrick J. Wong [Thu, 25 Aug 2016 23:29:37 +0000 (16:29 -0700)]
xfs/122: track xfs_scrub_metadata

Make sure the metadata scrub ioctl structure doesn't change size.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: test swapext with reflink
Darrick J. Wong [Thu, 25 Aug 2016 23:29:03 +0000 (16:29 -0700)]
xfs: test swapext with reflink

Add a few tests to stress the new swapext code for reflink and rmap.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/122: test btree header block sizes
Darrick J. Wong [Thu, 25 Aug 2016 23:28:51 +0000 (16:28 -0700)]
xfs/122: test btree header block sizes

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/159, 160: deal with EACCES -> EPERM transition
Darrick J. Wong [Thu, 25 Aug 2016 23:28:44 +0000 (16:28 -0700)]
generic/159, 160: deal with EACCES -> EPERM transition

As of 4.8 we can receive EPERM (instead of EACCES) for attempts to
reflink/dedupe to an immutable file.  Fix this up so that we accept
either answer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/130,235: deal with an unreplayable dirty log
Darrick J. Wong [Thu, 25 Aug 2016 23:28:38 +0000 (16:28 -0700)]
xfs/130,235: deal with an unreplayable dirty log

Now that we have log replay items, an FS shutdown due to a corrupt
btree results in a log that can't be replayed.  The only solution
here is to zap the log when we're fixing the corrupt fs, so do that
here.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/122: decrease the log update done item sizes
Darrick J. Wong [Thu, 25 Aug 2016 23:28:32 +0000 (16:28 -0700)]
xfs/122: decrease the log update done item sizes

Redundant fields were removed from the rmap/refcount/bmap update
done log items, so fix the size tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agotests/xfs: don't run tests if cowextsize isn't present
Darrick J. Wong [Thu, 25 Aug 2016 23:28:25 +0000 (16:28 -0700)]
tests/xfs: don't run tests if cowextsize isn't present

Some of the tests forgot to check that xfs_io has a cowextsize
command, so fix that here.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/172: raise fs size
Wang Xiaoguang [Wed, 31 Aug 2016 11:50:55 +0000 (19:50 +0800)]
generic/172: raise fs size

In original codes, if block size is 4096, fs size will be limited
to 60MB. In such small fs, btrfs is not able to write 40MB data,
because some space has been reserved internally, so the first
_pwrite_byte in this test case will fail for enospc error.

Also from this test case's test purpose, it tries to reflink a file
that uses more than half of the fs space, so here we can just define
fs size to be 256MB, the file to be reflinked to be 168MB.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: listxattr syscall with different buffer sizes
Artem Savkov [Tue, 30 Aug 2016 07:39:07 +0000 (09:39 +0200)]
generic: listxattr syscall with different buffer sizes

Add test that calls listxattr syscall with different buffer size
arguments checking if it fails properly.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoREADME: fix up dependency lists
Eric Sandeen [Tue, 30 Aug 2016 19:12:27 +0000 (14:12 -0500)]
README: fix up dependency lists

2 things: Make the dependency lines cut-and-paste-able with
line continuations, and fix up the Fedora deps a bit
(remove "awk" - should be "gawk" - and add a couple other
missing dependencies)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: rw remount with unknown ro-compat features
Zorro Lang [Sun, 28 Aug 2016 12:50:25 +0000 (20:50 +0800)]
xfs: rw remount with unknown ro-compat features

Although ro-compat features cannot be mounted rw, a bug allows an
ro->rw remount transition, and this will corrupt the filesystem if
it contains ro-compat features unknown to the running kernel.

This bug has been fixed on linux kernel (d0a58e8 xfs: disallow rw
remount on fs with unknown ro-compat features), this case is the
regression testcase of that bug.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/095: add xfs_file_aio_read into warning whitelist
Zorro Lang [Fri, 26 Aug 2016 14:45:30 +0000 (22:45 +0800)]
generic/095: add xfs_file_aio_read into warning whitelist

Current generic/095 warning whitelist include:
"xfs_file_dio_aio_read" and "xfs_file_read_iter"

But from the history we can see:
1) xfs_file_dio_aio_read() was splited from xfs_file_read_iter() by
below commit:

  bbc5a74 xfs: split xfs_file_read_iter into buffered and direct I/O helpers

2) xfs_file_read_iter() came from xfs_file_aio_read() as below
commit:

  b4f5d2c xfs: switch to ->read_iter()

Some Linux distro (e.g: RHEL-7) still use the old kernel with old
function xfs_file_aio_read().

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agofstests: add punch, collapse, insert, zero test groups
Theodore Ts'o [Wed, 24 Aug 2016 21:01:28 +0000 (17:01 -0400)]
fstests: add punch, collapse, insert, zero test groups

Define test groups for those tests which have _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.

This obviates an out-of-tree xfstests patch I maintain which used an
XFS_IO_AVOID environment variable to suppress running tests that use
punch, collapse, insert, etc.  This was rejected because of the
claim that it could be done using groups.  So this commit is in
response to those upstream comments.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: fsync after file rename
Filipe Manana [Tue, 23 Aug 2016 20:14:23 +0000 (21:14 +0100)]
generic: fsync after file rename

Test that if we rename a file, without changing its parent
directory, create a new file that has the old name of the file we
renamed, doing an fsync against the file we renamed works correctly
and after a power failure both files exists.

This is motivated by an issue found in btrfs, introduced in the
linux kernel 4.8-rc2, that caused lockdep to report a deadlock
scenario. The btrfs issue is fixed by the patch titled:

  "Btrfs: fix lockdep warning on deadlock against an inode's log mutex"

Tested against ext3/4, xfs, f2fs and reiserfs as well.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: Check clearing of SGID in chmod and acl_set_file
Andreas Gruenbacher [Tue, 23 Aug 2016 21:51:39 +0000 (23:51 +0200)]
generic: Check clearing of SGID in chmod and acl_set_file

Check if SGID is cleared upon chmod / setfacl when the owner is not
in the owning group.  As of today, the kernel fails to clear SGID in
setxattr (which is what acl_set_file is implemented on top of) in
that case; see this patch:

  https://patchwork.kernel.org/patch/9290507/

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: EIO error handling test
Zorro Lang [Fri, 19 Aug 2016 17:56:32 +0000 (01:56 +0800)]
xfs: EIO error handling test

Besides fail_at_unmount, all EIO error handling can stop umount
hanging on IO error too.

This case test EIO/max_retries and EIO/retry_timeout_seconds as
below:

1) fail_at_unmount=0 && \
   EIO/max_retries=1 && \
   EIO/retry_timeout_seconds=0

2) fail_at_unmount=0 && \
   EIO/max_retries=-1 && \
   EIO/retry_timeout_seconds=1

Make sure when fail_at_unmount=0, umount won't hang there.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/006: refactor reset error handling code to common/rc
Zorro Lang [Fri, 19 Aug 2016 17:56:31 +0000 (01:56 +0800)]
xfs/006: refactor reset error handling code to common/rc

Nearly 1/3 code is used to reset the xfs error handling attributes,
This part can be picked up, and used for other cases. So move them
to a new function _reset_xfs_sysfs_error_handling() in common/rc.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/033: source mkfs output again if isize less than 512
Zorro Lang [Sun, 21 Aug 2016 14:47:39 +0000 (22:47 +0800)]
xfs/033: source mkfs output again if isize less than 512

When blocksize is 512b, xfs/033 will run mkfs.xfs again to make sure
inode size is 512b. As below:

  # devzero blows away 512byte blocks, so make 512byte inodes (at least)
  _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
  . $tmp.mkfs
  [ $isize -lt 512 ] && \
          _scratch_mkfs_xfs -isize=512 | _filter_mkfs >/dev/null 2>&1

But after "566ebd5 mkfs: default to CRC enabled filesystems",
xfsprogs enable CRC as default. If MKFS_OPTIONS is "-b size=512 -m
crc=0", the first "_scratch_mkfs_xfs" will make crc=0, but the
second will change "crc" to "1", because it'll waive the "-b
size=512 -m crc=0" options.

xfs/033 need to check xfs's sb_features, to use different .out
files. So we should import the mkfs output($tmp.mkfs file) again, if
we mkfs again.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agocommon/rc: improve _require_metadata_journaling() for ext4
Eric Whitney [Fri, 19 Aug 2016 16:47:38 +0000 (12:47 -0400)]
common/rc: improve _require_metadata_journaling() for ext4

The code in _require_metadata_journaling() currently rejects ext4
file systems that have been created without a journal.  However, an
ext4 file system with a journal should also be rejected if the
journal is not loaded and made available for use at mount time.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric/135: redirect stderr from _scratch_mkfs
Eric Whitney [Thu, 18 Aug 2016 15:04:56 +0000 (11:04 -0400)]
generic/135: redirect stderr from _scratch_mkfs

In generic/135, benign warning message output from _scratch_mkfs on
stderr can cause a golden output mismatch, as can occur when testing
an ext4 bigalloc file system.  It's the only generic test that does
not also redirect stderr when directing _scratch_mkfs' stdout to
/dev/null.  Since error output from _scratch_mkfs doesn't seem
important to the overall intent of the test, there should be no harm
in making its stderr handling consistent.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/191: skip tests on older xfsprogs
Xiao Yang [Thu, 18 Aug 2016 03:09:16 +0000 (11:09 +0800)]
xfs/191: skip tests on older xfsprogs

If we don't have temp file used to test on xfsprogs 3.2.2,
_require_xfs_mkfs_validation will fail because mkfs.xfs can't create
this file. We need to skip tests before xfsprogs 4.7.0, so fix it.

This feature was introduced in xfsprogs 4.2.0 by commit 20cec860e16b
("mkfs.xfs: always use underlying fs sector size when mkfs'ing a
file")

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agosrc/test-nextquota: fix build failure with glibc 2.24
Omar Sandoval [Wed, 17 Aug 2016 00:18:28 +0000 (17:18 -0700)]
src/test-nextquota: fix build failure with glibc 2.24

glibc 2.24 defines Q_GETNEXTQUOTA but not `struct nextdqblk`. We
need to define it ourselves, but let's give it a hacky name that
won't cause another build error when the definition is added to
glibc.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: test xfs_quota "state" command
Eric Sandeen [Tue, 16 Aug 2016 03:23:11 +0000 (22:23 -0500)]
xfs: test xfs_quota "state" command

This exercises the xfs_quota "state" command for every
combination of user, group, and project quota enablement
on both crc (with project quota inode on disk) and non-crc
(where project quota overlaps group quota on disk) filesystems.

It currently requires patches to the upstream kernel
("quota: fill in Q_XGETQSTAT inode information for inactive quotas")
and to xfsprogs ("xfs_quota: wire up XFS_GETQSTATV") to pass.

Rather than trying to make it run on older kernels without
crc capability, I restrict the test to crc-capable environments,
but test with and without crcs enabled (and hence with and without
project quota inode on disk).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agocommon/quota: add prjquota to _qmount_option() filter
Eric Sandeen [Fri, 12 Aug 2016 22:46:54 +0000 (17:46 -0500)]
common/quota: add prjquota to _qmount_option() filter

_qmount_option() did not properly filter the
"prjquota" mount option along with the "pquota"
variant, as it does for the other types.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agosrc/t_immutable: allow EPERM on immutable inode
Eryu Guan [Tue, 9 Aug 2016 08:04:16 +0000 (16:04 +0800)]
src/t_immutable: allow EPERM on immutable inode

Starting from kernel commit 337684a1746f ("fs: return EPERM on
immutable inode"), EPERM is returned instead of EACCES on immutable
inodes. So update src/t_immutable.c to accept EPERM as a PASS.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs/122: add the realtime rmapbt inode and btree fields
Darrick J. Wong [Thu, 21 Jul 2016 23:48:00 +0000 (16:48 -0700)]
xfs/122: add the realtime rmapbt inode and btree fields

Add the on-disk structures added by the realtime rmapbt.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoxfs: scrub fs at the end of the test
Darrick J. Wong [Thu, 21 Jul 2016 23:47:51 +0000 (16:47 -0700)]
xfs: scrub fs at the end of the test

Teach _check_xfs_filesystem to scrub mounted filesystems before
unmounting and fscking them. This is mostly to test the online scrub
tool...

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoreflink: test cross-mountpoint reflink and dedupe
Darrick J. Wong [Thu, 21 Jul 2016 23:47:32 +0000 (16:47 -0700)]
reflink: test cross-mountpoint reflink and dedupe

Test sharing blocks via reflink and dedupe between two different
mountpoints of the same filesystem. This shouldn't work, since we
don't allow cross-mountpoint functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agoREADME: document Fedora, RHEL, and CentOS dependencies
Eric Sandeen [Fri, 5 Aug 2016 15:46:27 +0000 (10:46 -0500)]
README: document Fedora, RHEL, and CentOS dependencies

Document all build and runtime requirements for xfstests
on Fedora/RHEL/CentOS boxes, as was done earlier for Ubuntu.

Minor other README edits as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
7 years agogeneric: test accurate shared extent reporting
Darrick J. Wong [Fri, 5 Aug 2016 07:38:54 +0000 (15:38 +0800)]
generic: test accurate shared extent reporting

Ensure that we can create a file with a single extent, reflink two
blocks out of the middle of that extent, and the resulting fiemap
reports two shared extents, instead of lazily reporting the entire
huge extent as shared.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>