jlayton/xfstests.git
23 months agogeneric: test revalidation of encrypted dentries master
Eric Biggers [Thu, 4 May 2017 21:55:48 +0000 (14:55 -0700)]
generic: test revalidation of encrypted dentries

Add a test which verifies that dentries in an encrypted directory
are invalidated when an encryption key is added --- which should
cause the plaintext filenames to be visible and accessible,
replacing the encoded ciphertext filenames and any negative dentries
for the plaintext names.  This primarily tests for a bug which was
fixed in the v4.5 kernel, plus a v4.6 fix for incorrect RCU usage in
the earlier fix.

Cc: linux-fscrypt@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agopunch-alternating: add some options
Eric Sandeen [Thu, 4 May 2017 18:25:05 +0000 (13:25 -0500)]
punch-alternating: add some options

I didn't end up using this, but somebody else might find
it useful, so sending it.

This change lets us specify punch patterns other than
literally every other block.

i.e. punch-alternating with no options will do:

...HDHDHDHDHDHD...

-i 4 -s 2 will do:

...DDHHDDHHDDHH...

or -i 3 -s 1 will do:

...DDHDDHDDHDDH...

[eguan: don't allow 0 size and fixed perror string]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agoattr: add support for cephfs
Luis Henriques [Wed, 3 May 2017 10:54:13 +0000 (11:54 +0100)]
attr: add support for cephfs

Block size for cephfs is 4M, which makes generic/020 test fail as the
value for MAX_ATTRS and MAX_ATTRVAL_SIZE will be too high.  Restrict these
two variables to sane values for this FSTYP.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: "Yan, Zheng" <ukernel@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agocommon/rc: catch updated suspicious RCU usage message in _check_dmesg()
Eric Biggers [Thu, 4 May 2017 00:57:30 +0000 (17:57 -0700)]
common/rc: catch updated suspicious RCU usage message in _check_dmesg()

In the v4.11 kernel, the suspicious RCU usage message uses the word
"ERR" rather than "INFO".  Update _check_dmesg to accept both
versions.

[eguan: see kernel commit 4d4f88fa235f ("lockdep: Make RCU
suspicious-access splats use pr_err")]

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agoxfs: test fragmented multi-fsb readdir
Eric Sandeen [Thu, 4 May 2017 00:21:19 +0000 (19:21 -0500)]
xfs: test fragmented multi-fsb readdir

Regression test for kernel commit:
023cc840 xfs: handle array index overrun in xfs_dir2_leaf_readbuf()

See commit for detailed problem description.

tl;dr: readahead on weirdly fragmented multi-block directories
was broken.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agooverlay/017: test persistent inode numbers after mount cycle
Amir Goldstein [Fri, 28 Apr 2017 08:24:48 +0000 (11:24 +0300)]
overlay/017: test persistent inode numbers after mount cycle

Overlayfs directory inodes are constant across copy up,
but not persistent on mount cycle.

Compare the inode numbers before and after mount cycle.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agooverlay/017: verify constant inode number after rename
Amir Goldstein [Fri, 28 Apr 2017 08:24:47 +0000 (11:24 +0300)]
overlay/017: verify constant inode number after rename

The test verifies constant inode number after copy up.

Verify that inode number remains constant also after rename
and drop caches (when overlayfs needs to find the lower
inodes in another location).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agooverlay/017: create helpers to record and check inode numbers
Amir Goldstein [Fri, 28 Apr 2017 08:24:46 +0000 (11:24 +0300)]
overlay/017: create helpers to record and check inode numbers

Use helpers to records and check inode numbers so we can repeat
the same test after rename and mount cycle.

Suggested-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agooverlay/017: use af_unix to create socket test file
Amir Goldstein [Fri, 28 Apr 2017 08:24:45 +0000 (11:24 +0300)]
overlay/017: use af_unix to create socket test file

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agooverlay/017: fix some comments
Amir Goldstein [Fri, 28 Apr 2017 08:24:44 +0000 (11:24 +0300)]
overlay/017: fix some comments

Align all comments to the term 'constant inode numbers' and
explain why hardlinks are excluded from this test.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agooverlay/017: silence test output
Amir Goldstein [Fri, 28 Apr 2017 08:24:43 +0000 (11:24 +0300)]
overlay/017: silence test output

Change test to output golden silence on success.

We are going to run the same check several times,
so instead of cloning the test output, cloning the
silence will be more conveniet.

Generalize cleanup of temp files for the same reason.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agoxfs: xfs_growfs target path must be an active xfs mountpoint
Bill O'Donnell [Thu, 27 Apr 2017 18:31:10 +0000 (13:31 -0500)]
xfs: xfs_growfs target path must be an active xfs mountpoint

xfs_growfs manpage clearly states that the target path must be an
active xfs mountpoint. This is a test to ensure that if the target
path isn't an active xfs mountpoint, the command is rejected. The
purpose is to check the command response, but not necessarily the
functionality of xfs_growfs. Test cases include absolute paths,
relative paths, symbolic links, and bind mounts.

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agogeneric: add regression test for stale mmap reads
Ross Zwisler [Wed, 26 Apr 2017 18:05:31 +0000 (12:05 -0600)]
generic: add regression test for stale mmap reads

This adds a regression test for the following kernel patch:

  dax: fix data corruption due to stale mmap reads

The above patch fixes an issue where users of DAX can suffer data
corruption from stale mmap reads via the following sequence:

- open an mmap over a 2MiB hole

- read from a 2MiB hole, faulting in a 2MiB zero page

- write to the hole with write(3p).  The write succeeds but we incorrectly
  leave the 2MiB zero page mapping intact.

- via the mmap, read the data that was just written.  Since the zero page
  mapping is still intact we read back zeroes instead of the new data.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agogeneric: test eofblocks race with file extending aio dio writes
Zorro Lang [Wed, 26 Apr 2017 16:23:36 +0000 (00:23 +0800)]
generic: test eofblocks race with file extending aio dio writes

It's possible for post-eof blocks to end up being used for direct
I/O writes. dio write performs an upfront unwritten extent
allocation, sends the dio and then updates the inode size (if
necessary) on write completion. If a file release occurs while a
file extending dio write is in flight, it is possible to mistake the
post-eof blocks for speculative preallocation and incorrectly
truncate them from the inode. This means that the resulting dio
write completion can discover a hole and allocate new blocks rather
than perform unwritten extent conversion.

A kernel warning can be reproduced by generic/299 on XFS:
  XFS: Assertion failed: tp->t_blk_res_used <= tp->t_blk_res, \
       file: fs/xfs//xfs_trans.c, line: 309

The root cause is that xfs_free_eofblocks() uses i_size to truncate
post-eof blocks from the inode, but async, file extending direct
writes do not update i_size until write completion, long after inode
locks are dropped. Therefore, xfs_free_eofblocks() effectively
truncates the inode to the incorrect size.

Besides reproduce above kernel warning, the verification of written
data is an important distinction between this test and generic/299.
For cover this filesystem corruption testing, write this new case to
check data integrality manually, not only depend on a kernel
warning.

To increase the test stress of aio-dio-eof-race, add two arguments
to this source code to change the file size will be written.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agobuild: allow cros-compilation on chromeOS
Gwendal Grignou [Wed, 19 Apr 2017 23:33:48 +0000 (16:33 -0700)]
build: allow cros-compilation on chromeOS

- Request LIBTOOL to be used
- Set topbuildir based on a Makefile variable to call libtool
- Use /usr/local instead of /var for xfstest final location
- Move macros from aclocal.m4 to acinclude.m4, aclocal.m4 is autogenerated.
- Use autoconf variables @prefix@, @exec_prefix@.

The regular way of compiling xfstests - make - remains.
But it now runs autoreconf and libtoolize -i to produce a valid
configure.
Verified with 'make install --dry-run' that files are installed at the
same place.
Verified compiling in chromeOS chroot works as well.

[eguan: resolve merge conflicts and update .gitignore and remove
generated files by realclean]

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agoxfs: xfs_repair should junk empty attribute leaf blocks
Zorro Lang [Thu, 13 Apr 2017 07:31:09 +0000 (15:31 +0800)]
xfs: xfs_repair should junk empty attribute leaf blocks

There was a bug during log replay, the attr/attr3 leaf verifier
reported corruption when encountering a leaf attribute with a
count of 0 in the header, as below:

Metadata corruption detected at xfs_attr3_leaf block 0x480988/0x1000

commit f714016 from xfsprogs has fixed this bug. This test case
will emulate this corruption by xfs_db and use xfs_repair to fix
it.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agosrc/t_mmap_dio: fix incorrect argument count check
Ross Zwisler [Mon, 24 Apr 2017 17:49:31 +0000 (11:49 -0600)]
src/t_mmap_dio: fix incorrect argument count check

t_mmap_dio.c actually requires 4 arguments, not 3 as the current
check enforces:

usage: t_mmap_dio <src file> <dest file> <size> <msg>
open src(No such file or directory) len 0 (null)

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Fixes: 456581661b4d ("xfs: test per-inode DAX flag by IO")
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agobtrfs: fix local array declarations
Filipe Manana [Fri, 21 Apr 2017 15:00:52 +0000 (16:00 +0100)]
btrfs: fix local array declarations

We were declaring local arrays using a notation that does not seem to be
standard resulting in failures on some systems, like for example in a
Debian Stretch installation with bash version 4.4.11(1)-release:

$ ./check btrfs/003 btrfs/027
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 debian3 4.10.0-rc8-btrfs-next-37+
MKFS_OPTIONS  -- /dev/sdc
MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1

btrfs/003 45s ... [failed, exit status 1] - output mismatch (see /home/fdmanana/git/hub/xfstests/results//btrfs/003.out.bad)
    --- tests/btrfs/003.out 2016-08-23 10:17:35.027012095 +0100
    +++ /home/fdmanana/git/hub/xfstests/results//btrfs/003.out.bad 2017-04-21 15:53:58.807366940 +0100
    @@ -1,2 +1,4 @@
     QA output created by 003
    -Silence is golden
    +./tests/btrfs/003: line 102: devs[]: bad array subscript
    +dev balance failed
    +(see /home/fdmanana/git/hub/xfstests/results//btrfs/003.full for details)
    ...
    (Run 'diff -u tests/btrfs/003.out /home/fdmanana/git/hub/xfstests/results//btrfs/003.out.bad'  to see the entire diff)
btrfs/027 7s ... [failed, exit status 1] - output mismatch (see /home/fdmanana/git/hub/xfstests/results//btrfs/027.out.bad)
    --- tests/btrfs/027.out 2016-08-23 10:17:35.035012077 +0100
    +++ /home/fdmanana/git/hub/xfstests/results//btrfs/027.out.bad 2017-04-21 15:53:59.835367271 +0100
    @@ -1,2 +1,7 @@
     QA output created by 027
     Silence is golden
    +./common/rc: line 935: devs[]: bad array subscript
    +./common/rc: line 893: devs[]: bad array subscript
    +mkfs -m raid1 -d raid1 failed
    +Bug: str empty, must call _spare_dev_get before its put
    +(see /home/fdmanana/git/hub/xfstests/results//btrfs/027.full for details)
    ...
    (Run 'diff -u tests/btrfs/027.out /home/fdmanana/git/hub/xfstests/results//btrfs/027.out.bad'  to see the entire diff)
Ran: btrfs/003 btrfs/027
Failures: btrfs/003 btrfs/027
Failed 2 of 2 tests

So fix this by changing the declaration pattern "local dev[]=..." to the
standard way of "local -a dev=...".

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agobtrfs: use $FILEFRAG_PROG instead of filefrag
Xiao Yang [Fri, 21 Apr 2017 10:10:40 +0000 (18:10 +0800)]
btrfs: use $FILEFRAG_PROG instead of filefrag

$FILEFRAG_PROG has been defined in common/config, so
we could apply 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>
23 months agoext4: check mount's handling for very large s_first_meta_bg
Xiao Yang [Fri, 21 Apr 2017 10:10:39 +0000 (18:10 +0800)]
ext4: check mount's handling for very large s_first_meta_bg

On ext4 filesystem, the kernel carshes at mount time when
s_first_meta_bg's value exceeds the largest possible meta_bg
number.  This kernel bug has been fixed in:

3a4b77c ext4: validate s_first_meta_bg at mount time

[eguan: add comments on the first_meta_bg value]

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>
23 months agoxfs/293: make test more robust
Eric Sandeen [Thu, 20 Apr 2017 15:30:36 +0000 (10:30 -0500)]
xfs/293: make test more robust

xfs/293 is supposed to make sure every command in xfs_io
is documented, but it was missing the inode command because
it's a common word, and depending on how man formatted the
page, the magic "   inode" string could show up and appear
to indicate that documentation is present for the command
when it's not actually there.

Change the test to inspect the manpage source directly, with
the assumption that each documented command will start
with ^\.B.*$COMMAND on a manpage line.

This handles a few different compressed manpage formats -
I don't know if anybody uses bz2 or xz, but hey.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agofstests: add generic test for file handles
Amir Goldstein [Wed, 19 Apr 2017 16:29:19 +0000 (19:29 +0300)]
fstests: add generic test for file handles

Cloned from xfs specific test xfs/238, which checks
stale file handles of deleted files.

This test uses the generic open_by_handle_at() syscall
and also tests for non-stale file handles of linked files.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agosrc/open_by_handle: flexible usage options
Amir Goldstein [Wed, 19 Apr 2017 16:29:18 +0000 (19:29 +0300)]
src/open_by_handle: flexible usage options

More usage options for testing open_by_handle, which are needed
for testing stable handles across copy up in overlayfs.

usage: open_by_handle [-c|-l|-u|-d] <test_dir> [num_files]

Examples:

1. Create test set of N files and try to get their NFS handles:

   open_by_handle -c <test_dir> [N]

   This is used by new helper _require_exportfs() to check
   if filesystem supports exportfs

2. Get file handles for existing test set, drop caches and try to
   open all files by handle:

   open_by_handle <test_dir> [N]

3. Get file handles for existing test set, unlink all test files,
   drop caches, try to open all files by handle and expect ESTALE:

   open_by_handle -d <test_dir> [N]

4. Get file handles for existing test set, hardlink all test files,
   then unlink the original files, drop caches and try to open all
   files by handle (should work):

   open_by_handle -l <test_dir> [N]
   open_by_handle -u <test_dir> [N]

   This test is done with 2 invocations of the program, first to
   hardlink (-l) and then to unlink the originals (-u), because
   we would like to be able to perform the hardlinks on overlay
   lower layer and unlink on upper layer.

   NOTE that open_by_handle -u doesn't check if the files are
   hardlinked, it just assumes that they are.  If they are not
   then the test will fail, because file handles would be stale.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agosrc/open_by_handle: program to exercise open_by_handle_at() syscall
Amir Goldstein [Wed, 19 Apr 2017 16:29:17 +0000 (19:29 +0300)]
src/open_by_handle: program to exercise open_by_handle_at() syscall

This is a clone of src/stale_handle.c test that uses generic
open_by_handle_at() syscall instead of the xfs specific ioctl.

No test is using this program yet.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agofstests: remove IRIX test program open_unlink
Amir Goldstein [Wed, 19 Apr 2017 16:29:16 +0000 (19:29 +0300)]
fstests: remove IRIX test program open_unlink

It does not seem to be used by any test.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
23 months agogeneric: fix statx definition for non-x86 architecture
Gwendal Grignou [Wed, 19 Apr 2017 23:54:53 +0000 (16:54 -0700)]
generic: fix statx definition for non-x86 architecture

Fix a compilation error for ARM:
__ILP32__ is defined but not __X32_SYSCALL_BIT.

The check should only apply for x86_64 architecture, statx for other
architectures is not implemented yet - see commit 7acc839c9e57
"statx: Add a system call to make enhanced file info available".

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoxfs/348: update error message when transmogrifying symlink into directory
Darrick J. Wong [Thu, 13 Apr 2017 15:39:43 +0000 (08:39 -0700)]
xfs/348: update error message when transmogrifying symlink into directory

We introduced the inline directory verifier in 4.11 to prevent the
system from trying to use corrupt inline directories.  This has the
effect of changing the error message in one step of the i_mode fuzz
tester, so update the test accordingly.

Note that prior to the existence of the verifier, this test would
occasionally result in memory corruption that did not become evident
until later.

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>
2 years agogeneric: test FIEMAP on extended attribute blocks
Darrick J. Wong [Thu, 6 Apr 2017 16:01:30 +0000 (09:01 -0700)]
generic: test FIEMAP on extended attribute blocks

Make sure that FIEMAP produces some output when we add enough xattrs
to force the xattrs to be stored in an external block.

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>
2 years agobtrfs: remove snapshot aware defrag test
Liu Bo [Wed, 12 Apr 2017 01:27:18 +0000 (18:27 -0700)]
btrfs: remove snapshot aware defrag test

Since snapshot aware defrag has been disabled in kernel, and we all
have learned to ignore the failure of btrfs/010, lets just remove
it.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: Check the stx_attributes settable by chattr
David Howells [Mon, 10 Apr 2017 13:33:12 +0000 (14:33 +0100)]
generic: Check the stx_attributes settable by chattr

Check the stx_attributes that can be set by calling chattr.

The script probes the filesystem with chattr to find out which of
+a, +c, +d and +i are supported before testing combinations of
attrs.  Note that if a filesystem supports chattr with these, but
doesn't paste the flag values into stx_attributes, the test will
fail as there's no way to distinguish cleared from unset.

Certain chattr flags are reflected in specific stx_attributes flags:

chattr flag stx_attributes flag
+a STATX_ATTR_APPEND
+c STATX_ATTR_COMPRESSED
+d STATX_ATTR_NODUMP
+i STATX_ATTR_IMMUTABLE

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agodoc: Partially expand the documentation
David Howells [Mon, 10 Apr 2017 13:33:00 +0000 (14:33 +0100)]
doc: Partially expand the documentation

Partially expand the documentation available in xfstests to include
requirements checking and auxiliary programs for testing.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: Add first statx test
David Howells [Mon, 10 Apr 2017 13:32:52 +0000 (14:32 +0100)]
generic: Add first statx test

Add a statx test script that does the following:

 (1) Creates one each of the various types of file object and creates a
     hard link to the regular file.

     Note that the creation of an AF_UNIX socket is done with netcat in a
     bash coprocessing thread.  This might be best done with another
     in-house helper to avoid a dependency on nc.

 (2) Invokes the C test program included in this patch after the creation
     and hands it a list of things to check appropriate to each object.

 (3) Asks the test program to check the creation time of each object
     against that of the preceding object.

 (4) Makes various tests on the timestamps of the hardlinked file.

The patch also creates a C[*] test program to do the actual stat checking.
The test program then does the following:

 (1) Compares the output of statx() to that of fstatat().

 (2) Optionally compares the timestamps to see that they're sensibly
     ordered with respect to each other.

 (3) Optionally compares the timestamps to those of a reference file.

 (4) Optionally compares the timestamps to a specified time.

 (5) Optionally compares selected stats to values specified on the command
     line.

 (6) Optionally compares all the stats to those of a reference file,
     requiring them to be the same (hard link checking).

For example:

./src/stat_test /dev/null \
       stx_type=char \
       stx_rdev_major=3 \
       stx_rdev_minor=8 \
       stx_nlink=1 \
       ref=/dev/zero \
       ts=B,b

The test program can also be given a --check-statx parameter to give a
quick exit code-based answer on whether statx() exists within the kernel.

[*] Note that it proved much easier to do this in C than trying to do it in
    shell script and trying parsing the output of xfs_io.  Using xfs_io has
    other pitfalls also: it wants to *open* the file, even if the file is
    not an appropriate type for this or does not grant permission to do so.
    I can get around this by opening O_PATH, but then xfs_io fails to
    handle XFS files because it wants to issue ioctls on every fd it opens.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: Add an auxiliary program to create an AF_UNIX socket
David Howells [Mon, 10 Apr 2017 13:32:44 +0000 (14:32 +0100)]
fstests: Add an auxiliary program to create an AF_UNIX socket

Add an auxiliary program to create an AF_UNIX socket at the
specified location so that tests can do things with it.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric/422: check fallocate KEEP_SIZE flag correctly
Eryu Guan [Mon, 10 Apr 2017 03:02:57 +0000 (11:02 +0800)]
generic/422: check fallocate KEEP_SIZE flag correctly

This fixes a merge error in last update, "-k" should be passed to
_require_xfs_io_command() as a separate parameter.

Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: add orangefs (pvfs2) support
Martin Brandenburg [Fri, 7 Apr 2017 20:09:43 +0000 (16:09 -0400)]
fstests: add orangefs (pvfs2) support

The filesystem was renamed OrangeFS from PVFS2 recently.  The mount
-t type remains pvfs2, so I have used that name throughout despite
the kernel module being named orangefs.

We've been maintaining this as a patch for quite some time.

The easiest way to use is to setup a single server installation with
multiple filesystems orangefs and scratch, put the following in
/etc/xfsqa.config, and run ./check -pvfs2 -g quick.

TEST_DIR=/mnt
TEST_DEV=tcp://server1vm:3334/orangefs
SCRATCH_MNT=/scratch
SCRATCH_DEV=tcp://server1vm:3334/scratch

Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agosrc/t_immutable: add ftruncate to append only tests
Amir Goldstein [Fri, 7 Apr 2017 09:15:39 +0000 (12:15 +0300)]
src/t_immutable: add ftruncate to append only tests

The truncate and ftruncate syscalls check the IS_APPEND() flag
in 2 different vfs code paths and I had to fix both in order to
fix overlayfs IS_APPEND() violations.

Add the ftruncate test to t_immutable, so overlay/030 can verify
the fix.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: test immutable and append-only upper files
Amir Goldstein [Thu, 6 Apr 2017 05:49:20 +0000 (08:49 +0300)]
overlay: test immutable and append-only upper files

Run the t_immutable test program for immutable/append-only files
and directories in an overlayfs upper directory.

This test is similar and was derived from generic/079, but
the original test is _notrun on overlay mount because FS_IOC_GETFLAGS
FS_IOC_SETFLAGS ioctls fail on overlay directory inodes.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric/071: check if fs supports fallocate KEEP_SIZE flag
Filipe Manana [Tue, 4 Apr 2017 06:34:31 +0000 (07:34 +0100)]
generic/071: check if fs supports fallocate KEEP_SIZE flag

So that the test is skipped for filesystems that don't support it
instead of failing (like NFS 4.2 for example).

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: test for number of bytes used by files after buffered writes
Filipe Manana [Tue, 4 Apr 2017 06:34:30 +0000 (07:34 +0100)]
generic: test for number of bytes used by files after buffered writes

Test that a filesystem's implementation of the stat(2) system call
reports correct values for the number of blocks allocated for a file
when there are delayed allocations.

This test is motivated by a bug in btrfs which is fixed by the
following path for the linux kernel:

 "Btrfs: fix reported number of inode blocks"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/rc: check fs supports xfs_io falloc's specific flags
Filipe Manana [Tue, 4 Apr 2017 06:34:29 +0000 (07:34 +0100)]
common/rc: check fs supports xfs_io falloc's specific flags

For example NFS 4.2 supports fallocate but it does not support its
KEEP_SIZE flag, so we want to skip tests that use fallocate with
that flag on filesystems that don't support it.

Suggested-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric/079: use _require_test_program
Amir Goldstein [Thu, 6 Apr 2017 05:49:19 +0000 (08:49 +0300)]
generic/079: use _require_test_program

use _require_test_program helper and specify both +i and +a
to _required_chattr, because test sets them both.

Also remove unneeded _scratch_unmount from _cleanup.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: _require_chattr() must get an input arg
Amir Goldstein [Thu, 6 Apr 2017 05:49:18 +0000 (08:49 +0300)]
fstests: _require_chattr() must get an input arg

_require_chattr() was never intended to be called without an input
argument (specifiying the required attribute to set).

However, calling it without input arguments did work and error
was silently discarded into full test output.

Fix the function to abort on missing input argument and fix the
only test that called _require_chattr() with no input argument.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: Remove IRIX os support from template
Qu Wenruo [Wed, 5 Apr 2017 03:26:28 +0000 (11:26 +0800)]
fstests: Remove IRIX os support from template

Since the last release of IRIX is already 10 years ago and support
for it has ended after 2014, there is no need to support IRIX any
way.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: test encryption key revocation during concurrent I/O
Eric Biggers [Fri, 31 Mar 2017 19:48:36 +0000 (12:48 -0700)]
generic: test encryption key revocation during concurrent I/O

Add a test which revokes a keyring key while other processes are
performing I/O on an encrypted file that was "unlocked" using that key.
The crashes unpatched kernels with filesystem encryption enabled.

This bug was present in kernels v4.2 and later.  It has been fixed in
v4.11-rc4, v4.10.7, v4.9.20, and v4.4.59.

Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: Add test for fallocate() PUNCH_HOLE|KEEP_SIZE
Calvin Owens [Sat, 1 Apr 2017 01:13:41 +0000 (18:13 -0700)]
generic: Add test for fallocate() PUNCH_HOLE|KEEP_SIZE

Verify that punching holes at ends of files does not alter st_size
if we pass FALLOC_FL_KEEP_SIZE to fallocate().

[eguan: add comment about xfs_io's fpunch KEEP_SIZE flag]

Signed-off-by: Calvin Owens <calvinowens@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agobtrfs: use full subcommand names
David Sterba [Thu, 30 Mar 2017 15:06:33 +0000 (17:06 +0200)]
btrfs: use full subcommand names

Update the remaining calls to 'btrfs' that use shortened command
names.  Use of full names is recommended to avoid any ambiguities.

Signed-off-by: David Sterba <dsterba@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agobtrfs: reorder arguments so that options come first
David Sterba [Thu, 30 Mar 2017 15:20:18 +0000 (17:20 +0200)]
btrfs: reorder arguments so that options come first

The option parser in the btrfs utility is going to be updated and
will accept arguments in a stricter form, namely that options must
come before their non-option argument. Otherwise eg. the -f option
in send would be understood as another path and not an option
leading to many test failures.

The canonical form should be:

  btrfs command subcommand [-options] [arguments]

Signed-off-by: David Sterba <dsterba@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoxfs/068: update golden output due to new operations in fsstress
Zorro Lang [Tue, 28 Mar 2017 08:46:35 +0000 (16:46 +0800)]
xfs/068: update golden output due to new operations in fsstress

xfs/068 use a fixed seed (-s) and number of operations (-n) to run
fsstress, to get fixed number of files and directories. But new
operations of fsstress will break this "fixed number". So update
it, after fsstress get new operations.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofsstress: add mwrite/mread into test operation list
Zorro Lang [Tue, 28 Mar 2017 08:46:34 +0000 (16:46 +0800)]
fsstress: add mwrite/mread into test operation list

mmap is a popular and basic operation, most of softwares use it to
access files. More and more customers report bugs related with
mmap/munmap and other stress conditions.

So add mmap read/write test into fsstress to increase mmap related
stress to reproduce or find more bugs easily.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoext4: test mounting filesystem with encrypted inode on orphan list
Eric Biggers [Thu, 23 Mar 2017 19:16:08 +0000 (12:16 -0700)]
ext4: test mounting filesystem with encrypted inode on orphan list

Add an ext4-specific regression test for a bug which caused ext4 to
crash when mounting a filesystem which had an encrypted inode on its
orphan list.

This bug was present in kernels v4.1 and later.  It has been fixed
in v4.11-rc1, v4.10.4, v4.9.16, and v4.4.55.

Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Michael Halcrow <mhalcrow@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/rc: support gluster volume start with a slash
Zorro Lang [Wed, 22 Mar 2017 06:46:28 +0000 (14:46 +0800)]
common/rc: support gluster volume start with a slash

The format of glusterfs' TEST_DEV or SCRATCH_DEV is XXX:XXX or
XXX:/XXX, but xfstests can't accept the latter now. So change
the regular expression from "\w:\w" to ":/?", to accept more
glusterfs device format.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: test renaming encrypted files without key
Eric Biggers [Tue, 21 Mar 2017 21:14:32 +0000 (14:14 -0700)]
generic: test renaming encrypted files without key

Add a new test to test another behavior when accessing encrypted
files without the key: renames should be forbidden, even though they
may be possible cryptographically.  Test both a regular rename and a
cross rename.  (It happens that generic/398 also covers the cross
rename case, but it's primarily for a different reason.)

Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Richard Weinberger <richard@nod.at>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: test pagecache invalidation after direct write
Eryu Guan [Fri, 10 Mar 2017 09:27:38 +0000 (17:27 +0800)]
generic: test pagecache invalidation after direct write

Test if direct write invalidates pagecache correctly, so that
subsequent buffer read reads the correct data from disk.

This test is inspired by LTP tests dio29, and serves as a regression
test for the bug found by it, see kernel commit c771c14baa33
("iomap: invalidate page caches should be after iomap_dio_complete()
in direct write").

The test can be easily expanded to other write/read combinations,
e.g.  buffer write + direct read and direct write + direct read, so
they are also being tested.

Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric/417: reduce extend attribute size
Eryu Guan [Thu, 16 Mar 2017 06:48:07 +0000 (14:48 +0800)]
generic/417: reduce extend attribute size

xattr size 1024 is too big for 1k block size ext3/4 filesystem, so
test fails due to ENSPC message from multi_open_unlink when setting
xattr.

Reduce the xattr size to 512 so it fits in 1k block size ext3/4.

Reviewed-by: Xiong Zhou <xzhou@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: add GlusterFS support
Zorro Lang [Thu, 16 Mar 2017 05:28:19 +0000 (13:28 +0800)]
fstests: add GlusterFS support

Add basic GlusterFS support. Neither new GlusterFS specific tests
nor related patches are included. Only support FSTYP=glusterfs or
check -glusterfs XXX.

To test on glusterfs, two gluster volumes and two mountpoint
directories are needed.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/dmthin: Fix grep command for finding exact value
Harish [Thu, 16 Mar 2017 10:31:25 +0000 (16:01 +0530)]
common/dmthin: Fix grep command for finding exact value

Sometimes there are multiple occurances of meta_name, pool_name,
data_name in dmsetup command which causes failures while adding in
next line. This patch greps for names at start of line.

Signed-off-by: Harish <harish@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/rc: Use -v option with findmnt
Goldwyn Rodrigues [Mon, 13 Mar 2017 18:07:26 +0000 (13:07 -0500)]
common/rc: Use -v option with findmnt

Since btrfs puts in the subvol name in the device, we should
use -v option to not print the bind mounts or btrfs volumes.

Otherwise if a new subvolume is set as the default volume to be
mounted, as what btrfs/009 does, then next _require_scratch fails

  SCRATCH_DEV=/dev/vdc is mounted but not on SCRATCH_MNT=/scratch - aborting
  Already mounted result:
  /dev/vdc[/newvol] /scratch

[eguan: update commit log a bit, add failure example]

Fixes: 5e6892d ("common/rc: use findmnt to check mounted device")
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/config: honor NFS_MOUNT_OPTIONS in _test_mount_opts
Xiao Yang [Wed, 15 Mar 2017 10:37:26 +0000 (18:37 +0800)]
common/config: honor NFS_MOUNT_OPTIONS in _test_mount_opts

NFS_MOUNT_OPTIONS is always not applied on TEST_DEV when it has been
defined.

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>
2 years agobtrfs/139: creation/deletion within qgroup limits
Goldwyn Rodrigues [Tue, 14 Mar 2017 17:30:26 +0000 (12:30 -0500)]
btrfs/139: creation/deletion within qgroup limits

If we create and delete files within the qgroup limits, qg->reserved
(allocations before commits) over-inflates and causes -EDQUOT to be
returned pre-maturely.

Also, 32/64bit data-type exchanges can cause reserved (u64) to go
negative (very large) and -EDQUOT is returned pre-maturely.

Will be fixed by patches with subjects:
btrfs: Retry after commit on getting EDQUOT
btrfs: Change qgroup_meta_rsv to 64bit

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/config: don't hard-code SELinux context
Eric Biggers [Tue, 14 Mar 2017 17:55:46 +0000 (10:55 -0700)]
common/config: don't hard-code SELinux context

If SELinux is enabled, by default xfstests mounts its filesystems
with "-o context=system_u:object_r:nfs_t:s0" so that no SELinux
xattrs get created and interfere with tests.  However, this
particular context is not guaranteed to be available because the
context names are a detail of the SELinux policy.  The SELinux
policy on Android systems, for example, does not have a context with
this name.

To fix this without having to manually override
SELINUX_MOUNT_OPTIONS, just grab the SELinux context of the root
directory.  This is arbitrary, but it should always provide a valid
context.  And if for some reason someone is actually running
xfstests in a specific SELinux context that needs files labeled with
a particular context, then they may still override
SELINUX_MOUNT_OPTIONS.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/quota: remove redundant SELinux detection code
Eric Biggers [Sat, 11 Mar 2017 00:50:47 +0000 (16:50 -0800)]
common/quota: remove redundant SELinux detection code

SELINUX_MOUNT_OPTIONS is already set in common/config.  Setting it again
in common/quota is not necessary.  Nor is SELINUX_MOUNT_OPTIONS specific
to quota tests, so common/quota is not the right place for it.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agobtrfs/020: add _require_loop
Eric Biggers [Sat, 11 Mar 2017 00:55:53 +0000 (16:55 -0800)]
btrfs/020: add _require_loop

btrfs/020 uses a loopback device, so it should have _require_loop.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric/361: add _require_loop
Eric Biggers [Sat, 11 Mar 2017 00:55:12 +0000 (16:55 -0800)]
generic/361: add _require_loop

generic/361 uses a loopback device, so it should have _require_loop.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofilter: match $TEST_* $SCRATCH_* in beginning of path string
Amir Goldstein [Fri, 10 Mar 2017 07:39:56 +0000 (09:39 +0200)]
filter: match $TEST_* $SCRATCH_* in beginning of path string

For example, if $TEST_DIR=/mnt, only replace instances of /mnt that
are in the beginning of a path string, e.g.:

"/mnt/mntA/mntB:/mnt/mntC" => "TEST_DIR/mntA/mntB:TEST_DIR/mntC"

With this change, there is no longer a need to check the case of
$TEST_DEV being a substring of $TEST_DIR, because that would mean
that $TEST_DIR is a prefix of $TEST_DIR and that is not possible.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/rc: use findmnt to check mounted device
Eryu Guan [Fri, 10 Mar 2017 04:26:34 +0000 (12:26 +0800)]
common/rc: use findmnt to check mounted device

Doing 'grep -F "$dev on "' to find the mounted device is not
always accurate, e.g.

 SCRATCH_DEV=/vda6 is mounted but not on SCRATCH_MNT=/vda6/ovl-mnt - aborting
 Already mounted result:
 /dev/vda6 on /vda6 type xfs (rw,relatime,context=system_u:object_r:nfs_t:s0,attr2,inode64,noquota)

Fix it by using findmnt command and specifying the $dev as mount
source, print the result in "$dev $mnt" format. This works for local
filesystems, network filesystems and overlayfs, avoids all kinds of
tricky and error-prone grep pattern/regex.

Also fixed the if-then-fi format in _check_mounted_on() while we're
at it.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoxfs/078: instead file image by mkfs on loopback device
Zorro Lang [Thu, 9 Mar 2017 16:40:19 +0000 (00:40 +0800)]
xfs/078: instead file image by mkfs on loopback device

If test on 4k sector size device, xfs/078 will fail when it try to
make a filesystem image with block size less than 4096. But if we
attach the file image to a loop device, it can accept 512 block
size. So this patch attach a loop device before do mkfs.xfs.

[eguan: replace bare mount/umount with [U]MOUNT_PROG]

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: test orphan inode recovery on RO mount
Eric Sandeen [Fri, 10 Mar 2017 03:57:11 +0000 (11:57 +0800)]
generic: test orphan inode recovery on RO mount

There's a bug in xfs where the orphan inode list
is not processed on a readonly mount, and is still not
processed even if it gets mounted rw.  This test exercises
that, and makes sure that the unlinked list is empty after
a transition to rw and an unmount.

While we're at it, sanity check the same thing for pure ro
and rw unmounts.

Now that shutdown is generic, we can test other filesystems
as well, so this is in the generic group.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: require journal in shutdown tests
Eryu Guan [Mon, 6 Mar 2017 11:45:57 +0000 (19:45 +0800)]
generic: require journal in shutdown tests

Tests in shutdown group are supposed to test journal recovery after
filesystem shutdown, and the tests assume the filesystem in test has
journal support. But with the ext4 shutdown function added in
4.11-rc kernel, ext2 gains shutdown support too when driving with
ext4 driver, so generic/051 fails because fs corruption after test.

Adding _require_metadata_journaling to all generic tests in shutdown
group to ensure there's journal present.

generic/050 is skipped because it has _require_scratch_nocheck,
which indicates no fsck is done after test.

Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric: Test space allocation when there is only fragmented space
Qu Wenruo [Wed, 8 Mar 2017 02:20:40 +0000 (10:20 +0800)]
generic: Test space allocation when there is only fragmented space

This test case will test if file system works well when handling
large write while available space are all fragmented.

This can expose a bug in a btrfs unmerged patch, which wrongly
modified the delayed allocation code, to exit before allocating all
space, and cause hang when unmounting.

The wrong patch is:
[PATCH v6 1/2] btrfs: Fix metadata underflow caused by btrfs_reloc_clone_csum error

The test case will:
1) Fill small filesystem with page sized small files
   All these files has a sequential number as file name
2) Remove files with odd number as file name
   This will free almost half of the space
3) Try to write a file which takes 1/8 of the file system

The method to create fragmented fs may not be generic enough, but
should work for most extent based fs. Unless one file system will
allocate extents from both end of its free space.

Cc: Filipe Manana <fdmanana@kernel.org>
Cc: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoreport: Add xunit format report generator
Dmitry Monakhov [Fri, 3 Mar 2017 08:26:16 +0000 (12:26 +0400)]
report: Add xunit format report generator

xunit[1]/junit[2] are well known report formats for tests frameworks
which supported by most of test CI frameworks(such as Jenkins [3],
Bamboo [4], Avocado [5]) Basically this is just xml document which
can be easily parsed later by external tools.

EXAMPLE:
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="xfstests" errors="0" skipped="1" tests="2" time="7"  hostname="alice" timestamp="2017-02-21T15:15:06"  >
<properties>
<property name="SECTION" value="ext4"/>
<property name="FSTYP" value="ext4"/>
<property name="MOUNT_OPTIONS" value="-o acl,user_xattr "/>
<property name="HOST_OPTIONS" value="/devel/xfstests-dev.git/configs/alice.config"/>
<property name="XFS_MKFS_OPTIONS" value="-bsize=4096"/>
<property name="TIME_FACTOR" value="1"/>
<property name="LOAD_FACTOR" value="1"/>
<property name="TEST_DIR" value="/mnt/test"/>
<property name="TEST_DEV" value="/dev/ram0"/>
<property name="SCRATCH_DEV" value="/dev/ram1"/>
<property name="SCRATCH_MNT" value="/mnt/scratch"/>
<property name="OVERLAY_UPPER_DIR" value="upper"/>
<property name="OVERLAY_LOWER_DIR" value="lower"/>
<property name="OVERLAY_WORK_DIR" value="work"/>
</properties>
<testcase classname="xfstests.ext4" name="generic/001" time="5">
</testcase>
<testcase classname="xfstests.ext4" name="generic/010" time="1">
<skipped message="src/dbtest not built" />
</testcase>
</testsuite>

Footnotes:
[1] https://xunit.github.io/docs/format-xml-v2.html
[2] http://help.catchsoftware.com/display/ET/JUnit+Format
[3] https://jenkins.io
[4] https://www.atlassian.com/software/bamboo
[5] https://github.com/avocado-framework/avocado

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocheck: prepare test report generator infrastructure
Dmitry Monakhov [Fri, 3 Mar 2017 08:26:15 +0000 (12:26 +0400)]
check: prepare test report generator infrastructure

Save testcase data which later may be used by report generators
- Save failure reason to $err_msg variable
- Save number of notrun tests to $n_notrun counter, similar to
  $n_try,$n_bad

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric/409-411: remove all after unbind mountpoints
Zorro Lang [Tue, 7 Mar 2017 08:55:12 +0000 (16:55 +0800)]
generic/409-411: remove all after unbind mountpoints

After some shared subtrees test (bind/slave/shared/private), maybe
some dentries isn't freed. For example, EBUSY maybe returned due to
some bugs. This patch tries to verify that.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/config: make SELinux protection conditional
Gwendal Grignou [Mon, 6 Mar 2017 22:14:16 +0000 (14:14 -0800)]
common/config: make SELinux protection conditional

When selinux utilities are present, xfstests add options to help
circumvent selinux protection. However, on Chrome OS, it leads to
the opposite effect, when it prevents mount to succeed.

BUG=chromium:669641
TEST=xfstest test ext4/001 completes where it use to display:
common/rc: could not mount /dev/loop29 on /usr/local/autotest/tmp/xfstests_TEST

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoext4: add _require_ext4_mkfs_feature to check different features
Xiao Yang [Thu, 2 Mar 2017 06:03:12 +0000 (14:03 +0800)]
ext4: add _require_ext4_mkfs_feature to check different features

1) We add _require_ext4_mkfs_feature to check the specified
   feature whether it is available in mkfs.ext4 or not.

2) We apply _require_ext4_mkfs_feature in ext4/003 and remove
   _require_mkfs_mkfs_bigalloc.

3) We add _require_ext4_mkfs_feature in ext4/306.  When 64bit
   feature is supported by mkfs.ext4, ext4/306 could skip.

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>
2 years agogeneric: reflink concurrent operations
Nave Vardy [Wed, 1 Mar 2017 14:10:34 +0000 (16:10 +0200)]
generic: reflink concurrent operations

perform read operation on the target file while
doing write or fpunch operations on the reflinks.

Signed-off-by: Nave Vardy <nave.vardy@plexistor.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: use OVL_BASE_SCRATCH_MNT instead of SCRATCH_DEV
Amir Goldstein [Tue, 28 Feb 2017 12:18:37 +0000 (14:18 +0200)]
overlay: use OVL_BASE_SCRATCH_MNT instead of SCRATCH_DEV

Use the new var OVL_BASE_SCRATCH_MNT to refer to overlay
base dir instead of the legacy SCRATCH_DEV var.

In overlay/011, when using MOUNT_PROG directly, provide
OVL_BASE_SCRATCH_MNT as device argument instead of 'none'.
This fix is required to support mount of base fs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: mount/unmount base fs before/after running tests
Amir Goldstein [Tue, 28 Feb 2017 12:18:36 +0000 (14:18 +0200)]
overlay: mount/unmount base fs before/after running tests

When TEST/SCRATCH_DEV are configured to the base fs block device,
use this information to mount base fs before running tests,
unmount it after running tests and cycle on _test_cycle_mount
along with the overlay mounts.

This helps catching overlayfs bugs related to leaking objects in
underlying (base) fs.

To preserve expected tests behavior, the semantics are:
- _scratch_mkfs mounts the base fs, cleans all files, creates
  lower/upper dirs and keeps base fs mounted
- _scratch_mount mounts base fs (if needed) and mounts overlay
- _scratch_unmount unmounts overlay and base fs

Tests that use _scratch_unmount to unmount a custom overlay mount
and expect to have access to overlay base dir, were fixed to use
explicit umount $SCRATCH_MNT instead.

The overlay test itself, does not support formatting the base fs,
so config options like MKFS_OPTIONS and FSCK_OPTIONS are ignored
on 'check -overlay'.
The config option MOUNT_OPTIONS is used to mount the base scratch fs.
The config option TEST_FS_MOUNT_OPTS is used to mount the base test fs.
The config option OVERLAY_MOUNT_OPTIONS is used to mount both test and
scratch overlay mounts.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: configure TEST/SCRATCH vars to base fs
Amir Goldstein [Tue, 28 Feb 2017 12:18:35 +0000 (14:18 +0200)]
overlay: configure TEST/SCRATCH vars to base fs

Instead of setting the vars TEST/SCRATCH_DEV to overlay base dirs,
allow setting them to block devices to configure the base fs partition,
where overlay dirs will be created.

For example, the following config file can be used to run tests on
xfs test/scratch partitions:

 TEST_DEV=/dev/sda5
 TEST_DIR=/mnt/test
 SCRATCH_DEV=/dev/sda6
 SCRATCH_MNT=/mnt/scratch
 FSTYP=xfs

Using the same config file, but executing './check -overlay' will
use the same partitions as base fs for overlayfs directories
and set TEST_DIR/SCRATCH_MNT values to overlay mount points, i.e.:
/mnt/test/ovl-mnt and /mnt/scratch/ovl-mnt.

The base fs should be pre-formatted and mounted when starting the test.
An upcoming change is going to support mount/umount of base fs.

The new vars OVL_BASE_SCRATCH_MNT/TEST_DIR are set to point at the
overlayfs base dirs in either legacy or new config method.
Tests should always use these vars and not the legacy SCRATCH/TEST_DEV
vars when referring to overlay base dir.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: rename OVERLAY_LOWER/UPPER/WORK_DIR
Amir Goldstein [Tue, 28 Feb 2017 12:18:34 +0000 (14:18 +0200)]
overlay: rename OVERLAY_LOWER/UPPER/WORK_DIR

As preparation step for configuring test/scratch base fs
for overlay tests:

- Rename OVERLAY_LOWER/UPPER/WORK_DIR => OVL_LOWER/UPPER/WORK
  because we want to use OVL_ prefix for all base fs vars

- Prepend "ovl-" prefix to lower/upper/work path values to
  isolate the overlay test dirs when running on a base fs
  that is also used to run non overlay tests

- Make those vars values non-configurable, because lower/upper/work
  directory names are an internal test detail which should
  not concern the user and because we wish to simplify
  and document the overlay tests setup

- Add helper _filter_ovl_dirs and use it to filter output
  of test overlay/023 which matches the constant string "work"

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agogeneric/064: access SCRATCH_MNT after _scratch_mount
Amir Goldstein [Tue, 28 Feb 2017 12:18:33 +0000 (14:18 +0200)]
generic/064: access SCRATCH_MNT after _scratch_mount

Test is calling _get_block_size $SCRATCH_MNT before
_scratch_mount. This results in block size of the
wrong fs and a failure with overlay base fs setup.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: allow overlay SCRATCH_DEV to be a base fs mount point
Amir Goldstein [Tue, 28 Feb 2017 12:18:32 +0000 (14:18 +0200)]
fstests: allow overlay SCRATCH_DEV to be a base fs mount point

When configure SCRATCH_DEV to a mount point (and not to a directory therein)
then user will get a false positive error in scratch tests:

 $SCRATCH_DEV=/mnt/base/scratch is mounted but not on $SCRATCH_MNT=/mnt/scratch
 Already mounted result:
 /dev/sda6 on /mnt/base/scratch type xfs (rw,relatime,attr2,inode64,noquota)

This is due to the wrong `grep -F $SCRATCH_DEV` which matches the mount
point instead of the device in that mount.
Fix _check_mounted_on() to grep the pattern "$dev on " and "$dev on $mnt"
instead of just grepping for "$dev" and "$mnt" without the " on " anchor.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: fix test and scratch filters for overlapping DEV/MNT paths
Amir Goldstein [Tue, 28 Feb 2017 12:18:31 +0000 (14:18 +0200)]
fstests: fix test and scratch filters for overlapping DEV/MNT paths

When configuring overlay base fs, TEST_DEV/DIR and SCRATCH_DEV/MNT
are derived from the base fs mount points, where *_DEV are the
path of the base fs mount point and TEST_DIR/SCRATCH_MNT are
a directory under the base fs mount point.

This means that the overlay DEV paths are prefixes of the overlay
mount points.
Fix the test and sctach filters to check if TEST_DEV/SCRATCH_DEV is
a substring of TEST_DIR/SCRATCH_MNT and try and match the longer
string first.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: canonicalize mount points on every config section
Amir Goldstein [Tue, 28 Feb 2017 12:18:30 +0000 (14:18 +0200)]
fstests: canonicalize mount points on every config section

Create helper _canonicalize_mountpoint() to check and canonicalize
a mount point path.
Use helper to canonicalize TEST_DIR and SCRATCH_MNT after parse
of every config section.

This is needed for overlay base fs mount.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: use _test_mount() consistently
Amir Goldstein [Tue, 28 Feb 2017 12:18:29 +0000 (14:18 +0200)]
fstests: use _test_mount() consistently

On start of every test run and on every test, in init_rc() helper,
the test partition is verified to be mounted, or is mounted by
the helper _test_mount().

_test_mount() uses mount options $TEST_FS_MOUNT_OPTS and not
$MOUNT_OPTIONS like _scratch_mount() does.

_test_cycle_mount(), which is called by some tests uses the
_test_mount() helper as well.

Contrary to those cases, in _require_test() helper, if test
partition is not mounted, the helper _mount_or_remount_rw()
is called to mount the test partition with $MOUNT_OPTIONS.
Although this should never happen, because of the test in
init_rc(), this case is inconsistent with the rest of the code,
so it has been changed to use _test_mount() as it should.

When running tests with a multi section configuration, and
either FSTYP or MOUNT_OPTIONS change between sections, the
helper _test_unmount() is called to unmount the old test mount
and then _mount_or_remount_rw() is called to mount it again
with new FSTYP and/or MOUNT_OPTIONS.
This is again inconsistent with the rest of the code, so
was changed to use _test_mount() and instead of checking
if MOUNT_OPTIONS have changed between sections, we check if
TEST_FS_MOUNT_OPTS were changed between sections.
Otherwise, we can leave the test partition mounted.

This change is needed to support overlay base fs mount
and for multi section config files which include overlay FSTYP.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agofstests: sanity check that test partitions are not mounted elsewhere
Amir Goldstein [Tue, 28 Feb 2017 12:18:28 +0000 (14:18 +0200)]
fstests: sanity check that test partitions are not mounted elsewhere

When $TEST_DEV is mounted at a different location then $TEST_DIR,
_require_test() aborts the test with an error:
 TEST_DEV=/dev/sda5 is mounted but not on TEST_DIR=/mnt/test

There are several problems with current sanity check:
1. the output of the error is mixed into out.bad and hard to see
2. the test partition is unmounted at the end of the test regardless
   of the fact that it not pass the sanity that we have exclusivity
3. scratch partition has a similar sanity check in _require_scratch(),
   but we may not get to it, because $SCRATCH_DEV is unmounted prior
   to running the tests (which could unmount another mount point).

To solve all these problems, introduce a helper _check_mounted_on().
It checks if a device is mounted on a given mount point and optionally
checks the mounted fs type.

The sanity checks in _require_scratch() and _require_test() are
converted to use the helper and gain the check for correct fs type.

The helper is used in init_rc() to sanity check both test and scratch
partitions, before tests are run and before $SCRATCH_DEV is unmounted.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agocommon/rc: accept "localdomain" to mean YP/NIS disabled
Eric Biggers [Tue, 28 Feb 2017 22:09:36 +0000 (14:09 -0800)]
common/rc: accept "localdomain" to mean YP/NIS disabled

When asked to 'cat' the passwd or group files, currently xfstests runs
the 'domainname' program to get what the kernel thinks the domainname
is.  It seems that traditionally this has been "(none)" if YP/NIS is not
in use.  However, Android devices use a different convention which is to
set the domainname to "localdomain".  Therefore, this patch updates
xfstests to accept both conventions to indicate YP/NIS disabled.  This
stops a number of tests from failing when run on Android.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoxfs: stress test xfs_scrub
Darrick J. Wong [Tue, 28 Feb 2017 20:57:10 +0000 (12:57 -0800)]
xfs: stress test xfs_scrub

Three new tests:

- Repair files that are mapped into memory in running programs
- Run scrub -n concurrently with fsstress
- Run scrub -y concurrently with fsstress

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>
2 years agoreflink: test adjacency of reflinked blocks
Darrick J. Wong [Sat, 25 Feb 2017 01:12:57 +0000 (17:12 -0800)]
reflink: test adjacency of reflinked blocks

If we reflink a file with N blocks to another file one block at a time,
does the destination file end up with the same number of extents as the
source file?  In other words, does the filesystem succeed at combining
adjacent mappings into a maximal extents?

Signed-off-by: Darrick J. Wong <djwong@djwong.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoxfs/004: relax freespace check
Christoph Hellwig [Tue, 28 Feb 2017 00:52:35 +0000 (16:52 -0800)]
xfs/004: relax freespace check

Just check for a greater equals relation so that we don't have
to adjust the test for every new reservation scheme we add..

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agoxfs: minor fixes to the fsmap tests
Darrick J. Wong [Sat, 25 Feb 2017 01:12:51 +0000 (17:12 -0800)]
xfs: minor fixes to the fsmap tests

Refactor the fsmap tests slightly to use new helpers, and
fix some minor output scanning issues.

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>
2 years agoxfs/348: classify this as a fuzzer test
Darrick J. Wong [Sat, 25 Feb 2017 01:12:45 +0000 (17:12 -0800)]
xfs/348: classify this as a fuzzer test

xfs/348 is a fuzzer test since it calls xfs_db to break the scratch fs,
so put it in the fuzzers group.

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>
2 years agocommon/xfs: fix unexpected failure on real 4k sector device
Zorro Lang [Mon, 27 Feb 2017 08:23:03 +0000 (16:23 +0800)]
common/xfs: fix unexpected failure on real 4k sector device

_xfs_mkfs_validation_check() run "$cmd -s size=2s" to be sure if
xfsprogs support stricter input checks. But there's an unexpected
failure on 4k sector device:

  # blockdev --getbsz --getpbsz --getss $dev
  4096
  4096
  4096
  # mkfs.xfs -f -N -d file,name=$tmpfile,size=1g -s size=2s
  illegal sector size 1024; hw sector is 4096
  ....

So change the sector size from '2s' to '8s' to keep away this
failure.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: accessing stacked overlayfs files
Xiong Zhou [Thu, 23 Feb 2017 09:42:46 +0000 (17:42 +0800)]
overlay: accessing stacked overlayfs files

Lower dir comes from another overlayfs dir, then
accessing files in it should work.

CC: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: test flock after copied up
Xiong Zhou [Thu, 23 Feb 2017 09:42:45 +0000 (17:42 +0800)]
overlay: test flock after copied up

Locks of file in lower dir should working after it's
been copied up.

CC: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: can not change underlying immutable file
Xiong Zhou [Thu, 23 Feb 2017 09:42:44 +0000 (17:42 +0800)]
overlay: can not change underlying immutable file

Even timestamp change by touch.

CC: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: filter out xattr starts with "trusted.overlay."
Xiong Zhou [Thu, 23 Feb 2017 09:42:43 +0000 (17:42 +0800)]
overlay: filter out xattr starts with "trusted.overlay."

Overlayfs should only filter out xattr starting with
"trusted.overlay.", not "trusted.overlay".

Setting xattrs like "trusted.overlay.xxx" is not allowed.
Setting xattrs like "trusted.overlayxxx" is allowed.

v4.8-rc1 introduced a regression that we can't set xattrs
like "trusted.overlayxxx".  Kernel commit below fixed it
in v4.8:
  fe2b75952347 ovl: Fix OVL_XATTR_PREFIX

This case tests both get/set of these 2 kinds of xattrs.

Pattern "trusted.overlay.xxx" should fail, however the
errno returned by set/get varies among kernel versions.

Pattern "trusted.overlayxxx" shold always work.

CC: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: permission check with cached acls in tmpfs
Xiong Zhou [Thu, 23 Feb 2017 09:42:42 +0000 (17:42 +0800)]
overlay: permission check with cached acls in tmpfs

tmpfs does not implement ->get_acl method, overlayfs
need to get its cached acls in permission check when
lower or upper fs is tmpfs.

CC: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: test workdir cleanup in mounting
Xiong Zhou [Thu, 23 Feb 2017 09:42:41 +0000 (17:42 +0800)]
overlay: test workdir cleanup in mounting

"work" directory in workdir should be cleaned up
and recreated while overlayfs mounting. Or overlayfs
will be mounted read-only.

CC: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: work dir in overlay inherits no ACLs
Xiong Zhou [Thu, 23 Feb 2017 09:42:40 +0000 (17:42 +0800)]
overlay: work dir in overlay inherits no ACLs

They should be cleaned while mounting overlayfs.

[eguan: remove uncorrect comments about getfacl filter]

CC: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2 years agooverlay: disallow overlayfs as upperdir
Xiong Zhou [Thu, 23 Feb 2017 09:42:39 +0000 (17:42 +0800)]
overlay: disallow overlayfs as upperdir

Using overlayfs dir as upperdir to mount another
overlayfs should fail.

CC: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>