xfstests-dev.git
4 years agotests: port generic/097 to Linux
Eric Biggers [Fri, 21 Jul 2017 04:22:04 +0000 (21:22 -0700)]
tests: port generic/097 to Linux

This IRIX-specific test did some basic testing of extended attributes.
Port it to Linux; this mainly involved updating it to use the 'getfattr'
and 'setfattr' programs instead 'attr'.  Note that although 'attr' is
available on Linux, it's mainly for IRIX compatibility, the man page
recommends against using it on non-XFS filesystems, and it doesn't
support listing user xattrs only.  (In the last point it actually
differs from IRIX 'attr', but probably no one cares anymore.)  getfattr
also sorts its output by xattr name, so its output will be the same on
all filesystems unlike 'attr -l'.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agotests: port generic/093 to Linux
Eric Biggers [Fri, 21 Jul 2017 04:22:04 +0000 (21:22 -0700)]
tests: port generic/093 to Linux

This IRIX-specific test mainly tested whether a file's capabilities are
cleared when it is written to.  Port the test to the Linux libcap tools
and update it to expect the Linux semantics which are a little simpler:
capabilities are always cleared even if the program is root (or has
CAP_FSETID).  The test also tests that chmod doesn't affect open file
descriptors; this is mostly unrelated, but keep it in for now.

[eguan: add _require_test_program rule for src/writemod]

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/192: use shorter sleep and tolerate 2s delay
Eric Biggers [Wed, 19 Jul 2017 22:25:08 +0000 (15:25 -0700)]
generic/192: use shorter sleep and tolerate 2s delay

generic/192 would sleep 40 seconds, update a file's atime, and then
fail if the atime was not exactly 40 seconds later.  This is
unreliable since things may be slow enough to cause an extra second
to elapse.  "Fix" this by allowing for 2 seconds of delay.  Also,
while we're at it shorten the sleep to a much more reasonable 5
seconds.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/421: stop test from hanging on buggy kernels
Eric Biggers [Wed, 19 Jul 2017 20:35:51 +0000 (13:35 -0700)]
generic/421: stop test from hanging on buggy kernels

On some buggy kernels, the 'find' command in generic/421 encounters
a "Permission denied" error when trying to search $dir, so it
doesn't find the file it's supposed to.  This causes 'cat' to read
from stdin, hanging the test.  Quote the argument to cat to make the
test fail right away rather than hanging.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: add a less thorough testing mode for fsync-err program
Jeff Layton [Mon, 17 Jul 2017 18:10:13 +0000 (14:10 -0400)]
generic: add a less thorough testing mode for fsync-err program

Currently we just have this test run on a whitelist of filesystems,
but it would be best to be able to run it on all of them. The
problem is that a lot of filesystems basically shut down once they
hit metadata errors.

Allow the fsync-err testcase to operate in two different modes. One
mode just does basic testing to ensure that we get an error back on
all fd's when we fsync. The other does a more thorough test to
ensure that we get back 0 on subsequent fsyncs when there hasn't
been any write activity.

For now, we just opt-in to the more thorough testing on certain
filesystems: xfs, ext3 and ext4 on the generic test. All other
filesystems will run in simple mode.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: add test of file mode when setfacl fails
Ernesto A. Fernández [Wed, 19 Jul 2017 05:51:50 +0000 (02:51 -0300)]
generic: add test of file mode when setfacl fails

Check that the group permission bits of a file are not altered when
setfacl fails. At the time of this patch the test fails for at least
ext2, ext4, jfs and btrfs.

The failure in setfacl is induced by filling the device and setting
as many user attributes to the file as possible. For xfs this is not
enough, and the test will not run.

[eguan replaced setfattr with $SETFATTR_PROG and added enospc group]

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/attr: fix check for _require_attrs()
Ernesto A. Fernández [Wed, 19 Jul 2017 04:06:35 +0000 (01:06 -0300)]
common/attr: fix check for _require_attrs()

As of now xfstests decides if a filesystem supports attributes by trying
to write one to the mount point. For some reason this fails on reiserfs,
making it impossible to run tests that _require_attrs.

Fix this by checking against $TEST_DIR/syscalltest instead of $TEST_DIR.

This is probably what was intended, since the syscalltest file is touched
right before running attr. It is also consistent with how the check for
acl support is done.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: support jfs in _scratch_mkfs_sized
Ernesto A. Fernández [Fri, 14 Jul 2017 22:06:19 +0000 (19:06 -0300)]
common/rc: support jfs in _scratch_mkfs_sized

Add support for jfs in _scratch_mkfs_sized. Fix the block size in
4096, which seems to be the only option in jfs_mkfs.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: test direct IO write against raid5/6 filesystems
Filipe Manana [Thu, 13 Jul 2017 14:10:40 +0000 (15:10 +0100)]
btrfs: test direct IO write against raid5/6 filesystems

Test that a direct IO write works against raid5/6 filesystems and that
after the write operation we are able to read back the correct data
and scrub operations don't find any errors.

This test is motivated by a regression introduced in the merge window
for the 4.13 linux kernel, which was undetected by the current set of
test cases. The issue is fixed by the following patch:

  "Btrfs: fix write corruption due to bio cloning on raid5/6"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test negative SEEK_HOLE/SEEK_DATA offsets
Darrick J. Wong [Thu, 13 Jul 2017 19:06:41 +0000 (12:06 -0700)]
generic: test negative SEEK_HOLE/SEEK_DATA offsets

Check that we get -ENXIO if the user calls SEEK_HOLE/SEEK_DATA with
a negative file offset.

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>
4 years agooverlay: enable the index feature for overlay/hardlink tests
Amir Goldstein [Wed, 12 Jul 2017 09:43:25 +0000 (12:43 +0300)]
overlay: enable the index feature for overlay/hardlink tests

Overlayfs hardlink test are expected to fail if overlayfs does not
support the inodes index feature, so don't un them if kernel does
not support the feature.

If the feature is supported, enable it with the index=on mount option
for the hardlink tests, regardless of the build time default determined
by kernel config option CONFIG_OVERLAY_FS_INDEX.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: add helper _require_scratch_feature
Amir Goldstein [Wed, 12 Jul 2017 09:43:24 +0000 (12:43 +0300)]
fstests: add helper _require_scratch_feature

The helper is used to test if a specific filesystem feature can
be enabled. Currently only implemented testing overlayfs features.

Overalyfs features (e.g. redirect_dir, index) are configurable from
Kconfig (the build default), by module parameter (the system default)
and per mount using the mount option ${feature}=[on|off].

The helper is going to be used by overlay tests, which depend
on the inodes index feature.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test mount error cases with exclusive directories
Amir Goldstein [Wed, 12 Jul 2017 12:07:59 +0000 (15:07 +0300)]
overlay: test mount error cases with exclusive directories

Overlayfs is often used to mount several mounts that share a single
lower dir, but every overlayfs mount should have its own private
upperdir and private workdir.

Overlayfs mount on kernel <= v4.12 does not check if upper/work dirs
are currently in-use by another overlayfs mount on the system and bad
things can happen with such configuration.

Expect EBUSY when trying to mount overlay when:
- Upper dir is in-use by another overlay mount
- Work dir is in-use by another overlay mount

This test does not depend on the overlay index feature.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test cases that force read-only mount
Amir Goldstein [Tue, 11 Jul 2017 19:52:05 +0000 (22:52 +0300)]
overlay: test cases that force read-only mount

Verify that overlay is mounted read-only and that it cannot
be remounted rw.

- Mount with no upper dir
- Failure to create work dir

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: create overlay/mount test group
Amir Goldstein [Tue, 11 Jul 2017 19:52:04 +0000 (22:52 +0300)]
overlay: create overlay/mount test group

Add tests overlay/022 and overlay/024 to overlay/mount test group.
These tests check behavior of overlay mount cases.

Cc: Xiong Zhou <xzhou@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>
4 years agooverlay/014: fix test with inodes index enabled
Amir Goldstein [Tue, 11 Jul 2017 19:52:03 +0000 (22:52 +0300)]
overlay/014: fix test with inodes index enabled

When overlayfs is configured with CONFIG_OVERLAY_FS_INDEX=y,
workdir from previous overlay mount cannot be reused in a new
overlay mount that uses a different upper dir.

Fix the test to use a different workdir when mounting with a
different upper dir.

This change has not effect on older kernels and overlay
configured without CONFIG_OVERLAY_FS_INDEX.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/014: remove unneeded require and include
Amir Goldstein [Tue, 11 Jul 2017 19:52:02 +0000 (22:52 +0300)]
overlay/014: remove unneeded require and include

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoreflink: test unlinking a huge extent with a lot of refcount adjustments
Darrick J. Wong [Wed, 21 Jun 2017 21:57:48 +0000 (14:57 -0700)]
reflink: test unlinking a huge extent with a lot of refcount adjustments

Test a regression in XFS where we blow out a transaction reservation if
we create a big file, share every other block, and delete the first
file.  There's nothing particularly fs-specific about this stress test,
so put it in generic.

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>
4 years agoxfs/297: fail test if _scratch_mount fails
Brian Foster [Thu, 6 Jul 2017 18:06:20 +0000 (14:06 -0400)]
xfs/297: fail test if _scratch_mount fails

xfs/297 formats the scratch device with test specific mkfs options
that limit the use of certain mount options (i.e., if logbsize !=
256k). If an incompatible mount option is set, the mount fails but
the test proceeds to run against the root filesystem.

Update xfs/297 to fail if the mount of the scratch device fails for
whatever reason.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/095, generic/247: unmount correct devices
Eric Biggers [Thu, 6 Jul 2017 05:31:36 +0000 (22:31 -0700)]
generic/095, generic/247: unmount correct devices

In commit d55123c080cb ("generic/247: filter out expected XFS warnings
for mixed mmap/direct I/O"), _scratch_unmount was removed from
generic/095 and added to generic/247.  But actually generic/095 *should*
be unmounting SCRATCH_DEV; and generic/247 should be unmounting
TEST_DEV, not SCRATCH_DEV, since it doesn't use a scratch device (it was
failing if SCRATCH_DEV was not defined).  Fix it.

[eguan: the original bug was introduced by me not Brian, as I
removed _scratch_unmount from wrong test]

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test dropping nlink below zero
Amir Goldstein [Wed, 5 Jul 2017 12:02:06 +0000 (15:02 +0300)]
overlay: test dropping nlink below zero

nlink of overlay inode could be dropped indefinitely by adding
un-accounted lower hardlinks underneath a mounted overlay and
trying to remove them.

The simplest way to understand this test is this:
Imagine that you have a tool (e.g. xfs_db) with which you can add
hardlinks, without changing the value of nlink stored on-disk for
the inode. This is exactly what this test does when it adds lower
hardlinks underneath a mounted overlay.

Commit 5f8415d6b87e ("ovl: persistent overlay inode nlink for
indexed inodes") fixes this issue, although the issue was never
exposed in any released kernel.

With overlayfs indexed copy up and without the fix, the test
triggers WARN_ON(inode->i_nlink == 0) in drop_link().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test nlink accounting of overlay hardlinks
Amir Goldstein [Wed, 5 Jul 2017 12:02:05 +0000 (15:02 +0300)]
overlay: test nlink accounting of overlay hardlinks

nlink of overlay inode should account for the union of lower
and upper hardlinks.

persistent overlay union nlink is stored in an extended attribute
on the upper inode.

In order to test persistent overlay nlink accounting, the test is
repeated with both warm and cold dentry/inode cache.

[eguan: add comments on what fields report_nlink prints]

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test concurrent copy up of lower hardlinks
Amir Goldstein [Wed, 5 Jul 2017 12:02:04 +0000 (15:02 +0300)]
overlay: test concurrent copy up of lower hardlinks

Two tasks make a modification concurrently on two hardlinks of a
large lower inode.  The copy up should be triggered by one of the
tasks and the other should be waiting for copy up to complete.  Both
copy up targets should end up being upper hardlinks and both
metadata changes should be visible in both hardlinks.

With kernel <= v4.12, hardlinks are broken on copy up, meaning that
copy up is performed independetly and the resulting upper copy up
targets each have only one of the the metadata changes visible.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/018: test lower hardlinks re-unite on copy up
Amir Goldstein [Wed, 5 Jul 2017 12:02:03 +0000 (15:02 +0300)]
overlay/018: test lower hardlinks re-unite on copy up

Test that when two lower hardlinks are copied up, they end up
as two upper hardlinks of the same upper inode.

Drop caches before copy up so there is no knowledge of the
copied up hardlink in inode/dcache.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/018: test broken hardlinks after mount cycle
Amir Goldstein [Wed, 5 Jul 2017 12:02:02 +0000 (15:02 +0300)]
overlay/018: test broken hardlinks after mount cycle

This test checks if overlayfs hardlinks are preserved across
copy up.  Check if they are preserved also after copy up and
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>
4 years agooverlay/018: print hardlink content to golden output
Amir Goldstein [Wed, 5 Jul 2017 12:02:01 +0000 (15:02 +0300)]
overlay/018: print hardlink content to golden output

diff may skip comparing content of files with identical st_ino/st_dev.
Overlayfs stat(2) may return same st_dev/st_ino for hardlink copy ups,
but it does not mean that read(2) will return the same content.

Convert the test to output hardlink files content to golden output
instead of using diff.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/018: re-factor and add to hardlink group
Amir Goldstein [Wed, 5 Jul 2017 12:02:00 +0000 (15:02 +0300)]
overlay/018: re-factor and add to hardlink group

Use helpers to records and check inode numbers so we can repeat
the same test after each hardlink copy up and 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>
4 years agogeneric/446: add __xfs_get_blocks() into _filter_xfs_dmesg
Xiao Yang [Mon, 3 Jul 2017 07:35:59 +0000 (15:35 +0800)]
generic/446: add __xfs_get_blocks() into _filter_xfs_dmesg

On xfs filesystem, the following patch fixed system crash caused by
this race, but it introduced the __xfs_get_blocks() warning when the
race occurred:
04197b3 ("xfs: don't BUG() on mixed direct and mapped I/O")

On upstream kernel, the fix patch was cleared by:
acdda3a ("xfs: use iomap_dio_rw")

When the fix patch was applied and not cleared(e.g, on RHEL7.4),
this case triggered the __xfs_get_blocks() warning as expected.
Moreover, generic/095 may reproduce the same warning occasionally.
So we could add __xfs_get_blocks() into _filter_xfs_dmesg.

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>
4 years agoxfs: scrub while appending to a file
Darrick J. Wong [Wed, 21 Jun 2017 21:58:22 +0000 (14:58 -0700)]
xfs: scrub while appending to a file

It turns out that there was a bug in xfs_bmap_count_blocks wherein
the block count returned would count or not count delalloc blocks
depending on the fork format.  This is a bug that is easily exposed
via scrub, so check the output of that function here -- the buggy
version of the function produces online fsck errors.

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>
4 years agoext4: don't online scrub ever
Darrick J. Wong [Fri, 30 Jun 2017 04:58:12 +0000 (21:58 -0700)]
ext4: don't online scrub ever

The ext4 online scrub program is no longer under active development,
so remove all the test code that tried to use it.

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>
4 years agocommon/rc: test that the xfs_io scrub/repair commands actually work
Darrick J. Wong [Fri, 30 Jun 2017 04:12:39 +0000 (21:12 -0700)]
common/rc: test that the xfs_io scrub/repair commands actually work

When we call _require_xfs_io_command for the scrub ioctl, we have to
actually try calling the ioctl to make sure that the ioctl is
present on the running kernel.

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>
4 years agocommon/populate: remember multi-device configurations
Darrick J. Wong [Fri, 30 Jun 2017 04:12:04 +0000 (21:12 -0700)]
common/populate: remember multi-device configurations

Record the external log and realtime device configurations when we
create a sample filesystem.  ext4 tightly binds to external logs,
so we have to preserve that too.

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>
4 years agooverlay/031: add tests of whiteouts in lowerdir and both dirs
zhangyi (F) [Mon, 3 Jul 2017 10:43:31 +0000 (18:43 +0800)]
overlay/031: add tests of whiteouts in lowerdir and both dirs

In overlay/031, it only cover the test case of whiteouts in
origined upper dir. This patch add two cases cover the other
two situations:

1) Lower origined dir have whiteouts;
2) Both upper and lower origined dirs have whiteouts (although
this case is pass now, still add this to cover all three kinds
of situations).

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/031: factor out _create_whiteout() helper
zhangyi (F) [Fri, 30 Jun 2017 03:20:10 +0000 (11:20 +0800)]
overlay/031: factor out _create_whiteout() helper

Factor out helper for create an leftover whiteout,
this is common to repeat test of whiteout check in
different underlaying directories.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: test freeze/rmap repair race
Darrick J. Wong [Wed, 21 Jun 2017 21:58:11 +0000 (14:58 -0700)]
xfs: test freeze/rmap repair race

The rmapbt repair code plays some dirty tricks with the fs freezer
to avoid running afoul of regular xfs locking requirements.  Add a
test to check that filesystem write activities do not deadlock with
the repair program.

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>
4 years agogeneric: test a race between dio reads and mapped writes
Xiao Yang [Thu, 29 Jun 2017 06:36:41 +0000 (14:36 +0800)]
generic: test a race between dio reads and mapped writes

This test reproduces a race between a direct I/O read and
a mapped write to a hole in a file.  On xfs filesystem, it
will trigger a BUG_ON(), and this XFS bug has been fixed by:

04197b3 ("xfs: don't BUG() on mixed direct and mapped I/O")

[ eguan: umount before check dmesg log, and add rw group ]

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>
4 years agoxfs/274: flip shared bits to reflect xfsprogs usage
Darrick J. Wong [Wed, 21 Jun 2017 21:57:20 +0000 (14:57 -0700)]
xfs/274: flip shared bits to reflect xfsprogs usage

xfs_io's fsmap command flipped the attrfork and shared bits, so we
have to change them here too.

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>
4 years agogeneric/247: filter out expected XFS warnings for mixed mmap/direct I/O
Brian Foster [Wed, 28 Jun 2017 14:14:42 +0000 (10:14 -0400)]
generic/247: filter out expected XFS warnings for mixed mmap/direct I/O

generic/247 reproduces some of the same, expected warnings from XFS
as generic/095. These warnings occur due to mixed buffered/mapped
I/O racing with direct I/O to the same file.

generic/095 contains a custom dmesg filter to prevent test failure
in the event of such warnings. Lift the helper from generic/095 to
common/xfs and reuse it in generic/247 to implement the same
behavior.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: handle the case when syscall isn't available
Luis Henriques [Wed, 28 Jun 2017 11:20:51 +0000 (12:20 +0100)]
common/rc: handle the case when syscall isn't available

_require_xfs_io_command() isn't handling the case where the
requested syscall isn't available. To fix this simply check the
error returned by xfs_io.

Usually the userspace should be synced with kernelspace, the case
that a syscall is supported by userspace tool but not kernelspace
should not happen, but in rare test setups it's possible, e.g.
building an initramfs that contains the testing tools from a recent
distro, and running the tests against an old kernel (which does not
include such syscall).

[ eguan: it's not copy_file_range syscall specific issue, update
summary and commit log, and provide more background information ]

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs/027: reorder the arguments of btrfs replace
Lu Fengqi [Wed, 28 Jun 2017 05:45:31 +0000 (13:45 +0800)]
btrfs/027: reorder the arguments of btrfs replace

The option parser only accept options before non-option argument.
Although David Sterba has submitted commit df8c7225ba00 ("btrfs:
reorder arguments so that options come first"), but this case seems
to be left out.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: test incremental send after replacing directory with a file
Filipe Manana [Sun, 25 Jun 2017 23:13:39 +0000 (00:13 +0100)]
btrfs: test incremental send after replacing directory with a file

Test that an incremental send/receive operation works correctly after
moving some directory inode A, renaming a regular file inode B into the
old name of inode A and finally creating a new hard link for inode B at
directory inode A.

This issue is fixed by the following patch for the linux kernel:

  "Btrfs: incremental send, fix invalid path for link commands"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/430: Fix filename in "copy beyond end" test
Luis Henriques [Mon, 26 Jun 2017 16:40:52 +0000 (17:40 +0100)]
generic/430: Fix filename in "copy beyond end" test

The cmp command was using the wrong file to perform the comparison.
Use $testdir/beyond instead of $testdir/end.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoREADME: remove incorrect check -udf usage
David Disseldorp [Mon, 26 Jun 2017 13:40:16 +0000 (15:40 +0200)]
README: remove incorrect check -udf usage

The -udf parameter for check does not exist. UDF can still be tested
via the configuration parameter FSTYP=udf.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/seek_sanity_test: Fix for filesystems without unwritten extent support
Andreas Gruenbacher [Fri, 23 Jun 2017 13:32:14 +0000 (15:32 +0200)]
src/seek_sanity_test: Fix for filesystems without unwritten extent support

src/seek_sanity_test assumes that after preallocating space in a
file with fallocate, fseek SEEK_HOLE / SEEK_DATA will still report
the allocated space as a hole.  On filesystems without unwritten
extent support, that space will be reported as data, though.  On
such filesystems, skip the unwritten extent tests.

Tested on ext4, xfs, and gfs2 + patches for fseek SEEK_HOLE /
SEEK_DATA support.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: Another SEEK_HOLE/SEEK_DATA sanity test
Andreas Gruenbacher [Fri, 23 Jun 2017 00:11:16 +0000 (02:11 +0200)]
generic: Another SEEK_HOLE/SEEK_DATA sanity test

Both ext4 and xfs have a bug in the page cache scanning code for
SEEK_HOLE / SEEK_DATA in unwritten extents: the start offset isn't
taken into account when scanning a page, so seeking can fail on
filesystems with a block size less than half of the page size.  For
example, the following command fails on a filesystem with a block
size of 1k:

  xfs_io -f -c "falloc 0 4k" \
            -c "pwrite 1k 1k" \
            -c "pwrite 3k 1k" \
            -c "seek -a -r 0" foo

Like with generic/436, the actual tests are added to seek_sanity_test.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoseek_sanity_test: Report the actual allocation size
Andreas Gruenbacher [Fri, 23 Jun 2017 00:11:15 +0000 (02:11 +0200)]
seek_sanity_test: Report the actual allocation size

Instead of reporting the preferred block size for I/O as returned by
stat(2) as the allocation size, report the actual allocation size.
Clean things up a little in the process.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/401: Test mountpoint not subdir for filetype support
Eric Sandeen [Fri, 23 Jun 2017 16:12:41 +0000 (11:12 -0500)]
generic/401: Test mountpoint not subdir for filetype support

With pending changes for xfs_info/xfs_growfs, the tool
now requires an actual mount point to work properly.

Change this test to test $SCRATCH_MNT not the subdir
beneath 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>
4 years agogeneric: Test SGID inheritance with default ACLs
Jan Kara [Thu, 22 Jun 2017 13:28:28 +0000 (15:28 +0200)]
generic: Test SGID inheritance with default ACLs

Test that subdirectory properly inherits SGID bit even if parent
directory has default ACLs.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: seek data and holes that are in the CoW fork only
Darrick J. Wong [Wed, 21 Jun 2017 21:57:57 +0000 (14:57 -0700)]
xfs: seek data and holes that are in the CoW fork only

Create a file with a hole in the data fork and CoW reservations in the
same region in the CoW fork.  Ensure that SEEK_HOLE/DATA find the data.

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>
4 years agoxfs/040: use compare-libxfs in xfsprogs
Darrick J. Wong [Wed, 21 Jun 2017 21:57:39 +0000 (14:57 -0700)]
xfs/040: use compare-libxfs in xfsprogs

xfsprogs now ships with a tool to compare its libxfs against a kernel
libxfs.  Since the old srcdiff tool assumes dmapi.h (IRIX only) and the
pre-libxfs directory tree layout, fix the test and remove the old 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>
4 years agogeneric: test writev with page fault when it processes iov
Zorro Lang [Thu, 22 Jun 2017 05:55:33 +0000 (13:55 +0800)]
generic: test writev with page fault when it processes iov

We met a kernel assertion failure recently as below:

  XFS: Assertion failed: tp->t_blk_res_used <= tp->t_blk_res, file: fs/xfs/xfs_trans.c, line: 309

Eric Sandeen digged into it and find a good reproducer.

The problem comes when the several IO vectors are copied in, and
it runs into page faults, which stops the copy before all vectors
are copied. XFS sees this as a failed/short write, and so tries
to unmap the blocks & truncate away the pages in xfs_vm_write_end.

generic_perform_write is looping, and comes back around for the
other iovecs, but the page is still there, the buffer head is still
mapped, and so a new delalloc block isn't allocated - and ends up
being allocated at writeback time, despite the fact that we "should"
have accounted for it all at delalloc write time, and trips the
assert.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: make a btrfs version of writeback error reporting test
Jeff Layton [Fri, 16 Jun 2017 19:36:19 +0000 (15:36 -0400)]
btrfs: make a btrfs version of writeback error reporting test

For btrfs, we can test how it reports data writeback errors on fsync by
implementing a suggestion from Chris Mason:

Build a filesystem with 2 devices that stripes the data across
both devices, but mirrors metadata across both. Then, make one
of the devices fail and test what it does.

[eguan: add comments about creating btrfs with "-d raid0 -m raid1"]

Cc: Chris Mason <clm@fb.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test writeback error handling on dmerror devices
Jeff Layton [Fri, 16 Jun 2017 19:36:18 +0000 (15:36 -0400)]
generic: test writeback error handling on dmerror devices

Ensure that we get an error back on all fds when a block device is
open by multiple writers and writeback fails.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: add a writeback error handling test
Jeff Layton [Fri, 16 Jun 2017 19:36:17 +0000 (15:36 -0400)]
generic: add a writeback error handling test

I'm working on a set of kernel patches to change how writeback errors
are handled and reported in the kernel. Instead of reporting a
writeback error to only the first fsync caller on the file, it has
the the kernel report them once on every file description that was
open at the time of the error.

This patch adds a test for this new behavior. Basically, open many fds
to the same file, turn on dm_error, write to each of the fds, and then
fsync them all to ensure that they all get an error back.

To do that, I'm adding a new tools/dmerror script that the C program
can use to load the error table from the script. It's also suitable for
setting up, frobbing and tearing down a dmerror device for by-hand testing.

For now, only ext2/3/4 and xfs are whitelisted on this test, since those
filesystems are included in the initial patchset. We can add to that as
we convert filesystems, and eventually make it a more general test.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoext3: allow it to put journal on a separate device when doing scratch_mkfs
Jeff Layton [Fri, 16 Jun 2017 19:36:16 +0000 (15:36 -0400)]
ext3: allow it to put journal on a separate device when doing scratch_mkfs

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoext4: allow ext4 to use $SCRATCH_LOGDEV
Jeff Layton [Fri, 16 Jun 2017 19:36:15 +0000 (15:36 -0400)]
ext4: allow ext4 to use $SCRATCH_LOGDEV

The writeback error handling test requires that you put the journal on a
separate device. This allows us to use dmerror to simulate data
writeback failure, without affecting the journal.

xfs already has infrastructure for this (a'la $SCRATCH_LOGDEV), so wire
up the ext4 code so that it can do the same thing when _scratch_mkfs is
called.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: don't allow realtime swap files
Darrick J. Wong [Mon, 19 Jun 2017 20:24:02 +0000 (13:24 -0700)]
xfs: don't allow realtime swap files

Linux swapfiles use bmap which has no ability to tell the swap code
that the blocks its reporting aren't actually on the data device.
Therefore, swapon on a realtime file could corrupt random blocks on
the data device, so we must ensure that swapon cannot happen.

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>
4 years agooverlay: test whiteout check in impure dir
zhangyi (F) [Mon, 19 Jun 2017 03:53:39 +0000 (11:53 +0800)]
overlay: test whiteout check in impure dir

The unmerged and impure upper directories may contain invalid
whiteouts when we umount && modify lowerdir(e.g. clean up dir) and
remount overlay. This may lead to whiteouts exposure and rmdir
failure.

This case test impure dir's whiteouts check in ovl_iterate() and
ovl_remove_xxx().

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/397: be compatible with ignored SIGPIPE
Eric Biggers [Mon, 12 Jun 2017 21:15:28 +0000 (14:15 -0700)]
generic/397: be compatible with ignored SIGPIPE

If generic/397 is executed in an environment with SIGPIPE ignored,
it fails because the 'yes' program prints an error message:

    yes: standard output: Broken pipe
    yes: write error

This can be reproduced with:

    trap '' SIGPIPE; ./check generic/397

Fix it by generating the string of 255 y's using just 'head' and
'tr' instead of 'yes', 'head', and 'tr'.

Although it's not really a good idea to execute xfstests with
SIGPIPE ignored, this is the only test I've noticed where it causes
a problem, so it might as well be fixed in the test.

It would be much nicer to prevent this problem for all tests by
making the 'check' script restore the default SIGPIPE handler.  But
that isn't straightforward because bash's 'trap' builtin doesn't
allow un-ignoring signals that were ignored on entry to the shell.

[ eguan added more background infomation to commit log, which is
  also from Eric.

I think it's an easy problem for others to run into, since sometimes
processes ignore SIGPIPE because they want to get write errors
instead, but then when doing fork() + exec() they forget to reset
the SIGPIPE handler. Notably, Python got this wrong and it wasn't
fixed until Python 3, so any programs executing the 'check' script
from a Python 2 script will usually get this wrong (see:
https://bugs.python.org/issue1652). And usually everything works
fine but every once in a while there is a weird problem like this
which has to be debugged. ]

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: incremental send after renaming a file and a directory
Filipe Manana [Tue, 13 Jun 2017 15:06:39 +0000 (16:06 +0100)]
btrfs: incremental send after renaming a file and a directory

Test that an incremental send works if we rename some directory inode A
and then rename some file inode B to the name inode A had, for the case
where the directory inode A is an ancestor of inode B in the parent
snapshot.

This issue is fixed by the following patch for the linux kernel:

  "Btrfs: incremental send, fix invalid path for unlink commands"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon: UDF does not support journalling
Jan Kara [Wed, 14 Jun 2017 07:19:21 +0000 (09:19 +0200)]
common: UDF does not support journalling

UDF does not support journalling. Make the appropriate feature test fail
for it.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/360: Create symlink with valid path
Jan Kara [Wed, 14 Jun 2017 07:19:20 +0000 (09:19 +0200)]
generic/360: Create symlink with valid path

A test is creating symlink with a path containing name 1023 characters
long. Such file name is invalid for most filesystems (the limit on file
name lenght is mostly 255 characters) and UDF actually complains about
this and so the test fails. Since the point of this test is to verify
storage of the symlink, change the test to use a valid path where each
component name has only 254 characters.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test for buggy fscrypt context consistency check
Eric Biggers [Fri, 9 Jun 2017 22:36:33 +0000 (15:36 -0700)]
generic: test for buggy fscrypt context consistency check

Add a regression test for a bug where ->lookup() in an encrypted
directory would incorrectly return EPERM, depending on which inodes
happened to have their keys still cached in memory following removal of
the keyring key.  This bug was fixed in v4.12-rc1, v4.9.29, and v4.4.70.

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>
4 years agobtrfs: test incremental send after renaming and linking file
Filipe Manana [Wed, 7 Jun 2017 15:36:31 +0000 (16:36 +0100)]
btrfs: test incremental send after renaming and linking file

Test that an incremental send operation works correctly when an inode A
is renamed, a new hard link added to it and some other inode B is renamed
to the old name of inode A.

The btrfs bug is fixed by the following patch for the linux kernel:

  "Btrfs: send, fix invalid path after renaming and linking file"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: Fix block device requirements and manual scratch mounts
David Oberhollenzer [Wed, 7 Jun 2017 08:20:47 +0000 (10:20 +0200)]
fstests: Fix block device requirements and manual scratch mounts

Some tests require the scratch volume to be a block device,
although they don't do anything block device specific like
the device mapper tests. They actually only require a local
device and fail with network or overlay pseudo mount devices.

The same tests also try to mount the scratch device manually
after running _scratch_mkfs. For UBIFS, _scratch_mkfs simply
truncates the UBI volume and relies on the kernel to re-format
the volume on the next mount. This fails if the fs type is not
specified explicitly when mounting.

This patch replaces the block device requirement with a
generic check for a local device and adds a filesystem
specification to all manual mounts of the scratch device
to a mount point.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/398: Accept failing with EPERM in addition to ENOKEY for rename without key
David Oberhollenzer [Wed, 7 Jun 2017 08:20:46 +0000 (10:20 +0200)]
generic/398: Accept failing with EPERM in addition to ENOKEY for rename without key

Some filesystems (e.g. UBIFS) fail with EPERM when trying to move a
file into an encrypted directory via cross rename, without having
access to the encryption key.

Since rename is perfectly allowed to return EPERM, which is also
tested for, and no precise specification seems to exist that
clarifies when to expect EPERM and when ENOKEY, this patch modifies
the generic/398 test to accept both, for the test case where the key
is not available.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: Add support for UBIFS
David Oberhollenzer [Wed, 7 Jun 2017 08:20:45 +0000 (10:20 +0200)]
fstests: Add support for UBIFS

UBIFS is a filesystem for unmanaged flash memory devices. It works
on top of UBI (Unsorted Block Images) which is a wear leveling and
volume management layer on top of flash memory devices, which are
handled by the MTD subsystem (memory technology device).

Since the semantics of flash devices are drastically different from
regular block devices (blocks or "pages" must be erased before
writing, only larger groups of pages or "erase blocks" can be erased
at once, page write must be in order within an erase block, etc...)
it was decided to expose MTD devices as character devices with
ioctls for operations like erase.

Since erasing a flash erase block causes physical wear on the
device, eventually causing the erase blocks to go bad, the UBI layer
provides mainly transparent wear leveling on top of MTD devices. UBI
does not attempt to emulate a regular block device, but rather
something like a flash memory with idealized characteristics that
can be partitioned into multiple UBI volumes in a fashion somewhat
similar to LVM. UBI volumes are also exposed to user space as
character devices.

This patch mainly deals with some quirks of UBIFS like working on
top of character devices instead of block devices. Also UBIFS
automatically formats UBI devices when trying to mount an empty
device. The mkfs.ubifs program is mainly used for creating images.
This patch changes _scratch_mkfs and _scratch_mkfs_encrypted to
truncate the UBI volume instead, relying on the kernel to reformat
it on the next mount.

For _scratch_mkfs_encrypted this is actually required to get the
encryption tests to run, because mkfs.ubifs, at the time of writing
this, the kernel support for UBIFS encryption is fairly recent and
mkfs.ubifs does not have proper support yet.

The necessity of an additional -ubifs switch was discussed but auto
detection of UBIFS formated UBI devices could not be reproduced on
my end and is unlikely to work with empty UBI volumes anyway.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: Add tests for character devices
David Oberhollenzer [Wed, 7 Jun 2017 08:20:44 +0000 (10:20 +0200)]
common/rc: Add tests for character devices

Implement _is_char_dev similar to _is_block_dev to test for
character devices.

Add a _require_local_device test. This test is similar to
_require_block_device but checks if the path refers to a
block or a character device.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: test Btrfs delalloc accounting overflow
Omar Sandoval [Wed, 7 Jun 2017 06:57:10 +0000 (23:57 -0700)]
btrfs: test Btrfs delalloc accounting overflow

This is a regression test for patch "Btrfs: fix delalloc accounting
leak caused by u32 overflow". It creates a bunch of delalloc extents
and merges them together to make sure the accounting is done right.

[eguan: use $XFS_IO_PROG instead of xfs_io]

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/019: Silence possible kill failure
Nikolay Borisov [Tue, 6 Jun 2017 13:37:22 +0000 (16:37 +0300)]
generic/019: Silence possible kill failure

When the filesystem is force-killed in generic/019 and fsstress is
compiled with DEBUG then it's possible for check_cwd() to fail. In
this case fsstress would just die and invoking kill on its pid would
produce an error to the output file:

+./tests/generic/019: line 157: kill: (32750) - No such process

Fix this possibility by ignoring the result of the output command,
this won't affect the test coverage.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: Fix wrong word in _require_group
Nikolay Borisov [Fri, 2 Jun 2017 14:50:46 +0000 (17:50 +0300)]
common/rc: Fix wrong word in _require_group

Make _require_group yield the correct error message when the
requested group is not found.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: hole punching followed by writes in the same range
Filipe Manana [Tue, 30 May 2017 04:52:50 +0000 (05:52 +0100)]
generic: hole punching followed by writes in the same range

Test that if we punch a hole in a file, with either a range that goes
beyond the file's size or covers a file range that is already a hole,
and that if after we do some buffered write operations that cover
different parts of the hole, no warnings are emmitted in syslog/dmesg
and the file's content is correct after remounting the filesystem.

This test is motivated by a bug in btrfs that is manifested in kernel
4.12-rc1 onwards (the bug existed long time ago but was not so easy
to expose before 4.12-rc1). The btrfs patch that fixes the issue is
titled: "Btrfs: fix invalid extent maps due to hole punching".

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/listxattr: Fix reading past the end of the user buffer
Nikolay Borisov [Tue, 30 May 2017 14:10:07 +0000 (17:10 +0300)]
src/listxattr: Fix reading past the end of the user buffer

listxattr reaturns a null-terminated list of entries that represent
the xattr names. However, if it is passed larger buffer than it
requires it won't zero-out the rest of the memory. The way the
loop iterator in listxattr.c is written makes it go print every
null-terminated entry up to bufsize (which is user passed parameter).
This can lead to a situation where listxattr users N bytes out of
M bytes big buffer ( M > N). This will leave the rest (M-N)
as garbage, which in turn will be printed by listxattr. Fix this
by converting the 'for' loop to 'while' and properly ensuring
we are reading at most howevermany elements the syscall reported
it returned

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobuild: workaround build failures with old autoconf version
Eryu Guan [Tue, 16 May 2017 07:39:35 +0000 (15:39 +0800)]
build: workaround build failures with old autoconf version

Xiao Yang reported that fstests failed to build on RHEL6.9 hosts due
to old autoreconf didn't pass -I to aclocal -I. (This was fixed by
autoconf commit 44fbeef86d03 ("Pass autoreconf -I to aclocal -I"),
but not on RHEL6.9).

So call aclocal, autoheader and autoconf directly instead of
autoreconf, as what's done in xfsprogs Makefile.

Reported-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: Add regression test for tail page zeroing
Jan Kara [Mon, 29 May 2017 11:32:15 +0000 (13:32 +0200)]
generic: Add regression test for tail page zeroing

Add test checking for a race in ext4 writeback that could result in
zeroing too much from the tail page during writeback.

[eguan: removed from quick group, it needs longer time on xfs and
btrfs]

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agonfs: test nfs4_getfacl near page size ACL from server
Eryu Guan [Tue, 16 May 2017 11:35:15 +0000 (19:35 +0800)]
nfs: test nfs4_getfacl near page size ACL from server

Test nfs4_getfacl gets ACL list correctly from server when the ACL
length is close enough to the end of a page. On buggy NFS client
getxattr could return ERANGE. Upstream commit ed92d8c137b7 ("NFSv4:
fix getacl ERANGE for some ACL buffer sizes") fixed this bug in 4.11
kernel.

Note that this reproducer was originally written by J. Bruce Fields.

Cc: J. Bruce Fields <bfields@redhat.com>
Cc: Weston Andros Adamson <dros@primarydata.com>
Cc: linux-nfs@vger.kernel.org
Reviewed-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobuild: Stop relying on OpenSSL
Theodore Ts'o [Thu, 25 May 2017 17:41:34 +0000 (13:41 -0400)]
build: Stop relying on OpenSSL

The OpenSSL dependency was added for one program, fssum, and it needs
it only because it needs a md5 implementation.  Use Solar Designer's
openssl compatible implementation of md5 so we no longer need to
depend on OpenSSL.

Since the OpenSSL libraries are not always available, we had to add
extra complexity to test to see whether fssum exists.

The other problem with depending on the OpenSSL libraries is that
shared library compatibility situation is terrible; a fssum binary
built on a system using libssl1.0.0 is *NOT* run on a system with
libssl1.0.2, since the shared libraries are incompatible even across a
minor version bump.  (Sigh.)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/108: Fix return value check from _get_scsi_debug_dev
Nikolay Borisov [Thu, 25 May 2017 09:08:46 +0000 (12:08 +0300)]
generic/108: Fix return value check from _get_scsi_debug_dev

_get_scsi_debug_dev is supposed to return a "/dev/$device".
However, in case the scsi device is not mapped to a disk, hence
/dev/sd* doesn't exist, then get_scsi_debug_dev would return only
the "/dev/" string. In generic/108 we check whether return value is
"" and only then consider it a failure. This behavior allows the
test to erroneously consider _get_scsi_debug_dev succeeded even if
it returned a malformed string. Fix this by correctly checking
whether the return value is "/dev/"

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/288: filter out extra mkfs warning
Zorro Lang [Thu, 25 May 2017 08:38:38 +0000 (16:38 +0800)]
xfs/288: filter out extra mkfs warning

From xfsprogs v4.7, mkfs.xfs add respecification detection by
commit 9090e18. Then mkfs will fail and return if we run it
as below:

  mkfs.xfs -m crc=1,finobt=1 -m crc=0 ....

Then _scratch_mkfs_xfs can deal with this problem. But for old
xfsprogs ( < v4.7), it replace the first "crc=1" with the second
"crc=0". Then "crc=0,finobt=1" cause a warning, but keep running:

  "warning: finobt not supported without CRC support, disabled."

This extra warning breaks the golden image of xfs/288, so filter
it out in case.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/196: fallback to fail_writes for old kernel
Zorro Lang [Wed, 24 May 2017 14:52:58 +0000 (22:52 +0800)]
xfs/196: fallback to fail_writes for old kernel

linux XFS rename all "fail_writes" references to "drop_writes" in
v4.11. Some old kernel still use the name "fail_writes", e.g.
RHEL-7. For testing on old kernel, we need to fallback to
"fail_writes".

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/seek_sanity_test: fix test15 SEEK_HOLE expected results
Luis Henriques [Tue, 23 May 2017 16:19:55 +0000 (17:19 +0100)]
src/seek_sanity_test: fix test15 SEEK_HOLE expected results

Filesystesm with the "default behavior" will always return the
offset of the end of the file when lseek'ing with SEEK_HOLE.  This
test does the following:

 - fallocate 4 << 20 bytes
 - write PAGE_SIZE bytes at offset 0
 - writes PAGE_SIZE bytes at offset 4 << 20

Thus, using lseek in an FS with the "default behavior" will set the
position at 4 << 20 + PAGE_SIZE.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/293: Make 'man' hard requirement
Nikolay Borisov [Tue, 23 May 2017 14:16:40 +0000 (17:16 +0300)]
xfs/293: Make 'man' hard requirement

If xfs/293 is run on a system which doesn't have 'man' installed
it will hang the due to $CAT waiting for input indefinitely. Also
create an entry for $MAN_PROG and use the cached $MANPAGE instead
of repeatedy calling $MAN_PROG --page

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/stat_test: Fix stx_attributes check
Richard Weinberger [Sat, 20 May 2017 22:06:13 +0000 (00:06 +0200)]
src/stat_test: Fix stx_attributes check

I found that this test succeeds on UBIFS:
stat_test /mnt/foo attr=+compressed attr=-compressed

Since stx_attributes can hold many flags, check the flags
correctly with the & operator.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc: fix compiler warnings
Theodore Ts'o [Mon, 22 May 2017 00:29:12 +0000 (20:29 -0400)]
src: fix compiler warnings

Most of the fixes are printf format type warnings, but apparently GCC
6 is smart enough to realize is that if you don't do proper error
checking with posix_memalign, the resulting pointer can be undefined,
and whines about it.  So while fixing this in aio-dio-fcntl-race, I
also cleaned up the error checking and reporting.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agofstests: skip AIO-related tests when CONFIG_AIO=n
Eric Biggers [Thu, 18 May 2017 22:49:10 +0000 (15:49 -0700)]
fstests: skip AIO-related tests when CONFIG_AIO=n

When running xfstests on a kernel configured with CONFIG_AIO=n, all
AIO-related tests fail, often due to an error similar to the
following:

    error Function not implemented during io_setup

This affected at least the following tests: generic/036,
generic/112, generic/113, generic/198, generic/207, generic/208,
generic/210, generic/211, generic/239, generic/323, generic/427,
xfs/240, xfs/241.

Fix this by enhancing the 'feature' program to allow testing for
asynchronous I/O support, then skipping all AIO-related tests when
AIO is unsupported.

This change is useful because CONFIG_AIO is sometimes disabled to
reduce the kernel's attack surface (e.g. see
https://android-review.googlesource.com/#/c/292158/).

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agobtrfs: regression test for nocsum buffered read's repair
Liu Bo [Wed, 17 May 2017 22:36:10 +0000 (16:36 -0600)]
btrfs: regression test for nocsum buffered read's repair

This is to test whether buffered read retry-repair code is able to
work in raid1 case as expected.

Please note that without checksum, btrfs doesn't know if the data
used to repair is correct, so repair is more of resync which makes
sure that both of the copy has the same content.

Commit 20a7db8ab3f2 ("btrfs: add dummy callback for
readpage_io_failed and drop checks") introduced the regression.

The upstream fix is commit 9d0d1c8b1c9d ("Btrfs: bring back repair
during read")

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agobtrfs: regression test for nocsum dio read's repair
Liu Bo [Wed, 17 May 2017 22:36:09 +0000 (16:36 -0600)]
btrfs: regression test for nocsum dio read's repair

Commit 2dabb3248453 ("Btrfs: Direct I/O read: Work on sectorsized
blocks") introduced this regression.  It'd cause 'Segmentation
fault' error.

The upstream fix is commit 97bf5a5589aa ("Btrfs: fix segment fault
when doing dio read")

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agobtrfs: regression test for btrfs buffered read's repair
Liu Bo [Wed, 17 May 2017 22:36:08 +0000 (16:36 -0600)]
btrfs: regression test for btrfs buffered read's repair

This case tests whether buffered read can repair the bad copy if we
have a good copy.

Commit 20a7db8ab3f2 ("btrfs: add dummy callback for readpage_io_failed
and drop checks") introduced the regression.

The upstream fix is commit 9d0d1c8b1c9d ("Btrfs: bring back repair
during read")

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agobtrfs: regression test for btrfs dio read repair
Liu Bo [Wed, 17 May 2017 22:36:07 +0000 (16:36 -0600)]
btrfs: regression test for btrfs dio read repair

This case tests whether dio read can repair the bad copy if we have
a good copy.

Commit 2dabb3248453 ("Btrfs: Direct I/O read: Work on sectorsized
blocks") introduced the regression.

The upstream fix is commit 2e949b0a5592 ("Btrfs: fix invalid
dereference in btrfs_retry_endio")

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agocommon/filter: add _filter_filefrag
Liu Bo [Wed, 17 May 2017 22:36:06 +0000 (16:36 -0600)]
common/filter: add _filter_filefrag

_filter_filefrag is a helper function to filter filefrag's output
and it can be used to get a file's file offset and physical offset.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agofsstress: cleanup flist with test directory together
Zorro Lang [Wed, 17 May 2017 15:48:47 +0000 (23:48 +0800)]
fsstress: cleanup flist with test directory together

The "-c" option of fsstress will clean up the test directory after
each run. But it only does "rm -rf $dir". If run fsstress likes:

  fsstress -d $test_dir -n 1000 -p 10 -l 0 -c

fsstress will remove all test directories at the end of each run,
but the flist still save those *deleted* entries. It'll cause
more and more useless ENOENT failures. So we need to release all
entries in flist too.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agogeneric: add regression test for DAX PTE/PMD races
Ross Zwisler [Wed, 17 May 2017 17:17:42 +0000 (11:17 -0600)]
generic: add regression test for DAX PTE/PMD races

This adds a regression test for the following kernel patches:

  mm: avoid spurious 'bad pmd' warning messages
  dax: Fix race between colliding PMD & PTE entries

The above patches fix two related PMD vs PTE races in the DAX code.
These can both be easily triggered by having two threads reading and
writing simultaneously to the same private mapping, with the key
being that private mapping reads can be handled with PMDs but
private mapping writes are always handled with PTEs so that we can
COW.

Without this 2-patch kernel series, the newly added test will result
in the following errors:

  run fstests generic/437 at 2017-05-16 16:53:43
  mm/pgtable-generic.c:39: bad pmd ffff8808daa49b88(84000001006000a5)
   ... a bunch of the bad pmd messages ...
  BUG: Bad rss-counter state mm:ffff8800a8c1b700 idx:1 val:1
  BUG: non-zero nr_ptes on freeing mm: 38
  XFS (pmem0p1): Unmounting Filesystem

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>
5 years agogeneric: Add more SEEK_HOLE tests
Jan Kara [Wed, 17 May 2017 12:04:05 +0000 (14:04 +0200)]
generic: Add more SEEK_HOLE tests

Add tests for bugs found in ext4 & xfs SEEK_HOLE implementations
fixed by following patches:

xfs: Fix missed holes in SEEK_HOLE implementation
ext4: Fix SEEK_HOLE

We add tests to seek_sanity_test as it is easiest to reuse its
infrastructure for seek tests, however not to regress generic/285
which uses seek_sanity_test we don't run new tests by default.
Instead we add options to select a range of tests to run and run new
tests from this new test.

[eguan: add $tmp definition and cleanup $tmp.* on exit]

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agogeneric: test that encrypted filenames are presented without collisions
Eric Biggers [Tue, 16 May 2017 22:46:15 +0000 (15:46 -0700)]
generic: test that encrypted filenames are presented without collisions

Add a test which creates many similarly-named files in an encrypted
directory, then verifies they can be deleted without access to the
encryption key.  This is a regression test for two related bugs which
caused presented names to "collide" and point to the wrong inodes.
These bugs were present in the original versions of ext4 and f2fs
encryption, and they were fixed in v4.12-rc1.

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>
5 years agocommon: cleanup _require_xfs_io_command
Xiao Yang [Wed, 17 May 2017 01:42:33 +0000 (09:42 +0800)]
common: cleanup _require_xfs_io_command

We don't need to check specific flags at the end of this function
if we have checked them before. e.g, generic/071 and generic/422
are marked as notrun unexpectedly because xfs_io doesn't support
long-format help for falloc before xfsprogs v4.9.  Actually, xfs_io
has supported falloc, so these case should not be marked as notrun.

[eguan: declare local vars as local, rename param_check to
param_checked]

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>
5 years agocommon: use _require_xfs_io_command() directly to check fiemap
Xiao Yang [Wed, 17 May 2017 01:42:32 +0000 (09:42 +0800)]
common: use _require_xfs_io_command() directly to check fiemap

1) _require_fiemap and _require_xfs_io_command "fiemap" do the
   same thing, but some test cases use the former and some use
   the latter, so i feel they should be unified.

2) The number of helpers like this is slowly growing, but it's
   easy to simply use _require_xfs_io_command directly and just
   specify the command we want to check.

This is just a cleanup for keeping it simple.

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>
5 years agooverlay/017: test consistent st_ino/d_ino for hardlinks
Amir Goldstein [Thu, 11 May 2017 06:55:09 +0000 (09:55 +0300)]
overlay/017: test consistent st_ino/d_ino for hardlinks

Currently hardlinks do not preserve the inode number across copy up,
so hardlinks did not participate in this test so far.

Stay honest and let the test verify what is was meant to verify and
let it fail because of the fact that hardlinks inode numbers are not
constant across copy up.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agooverlay/017: use t_dir_type to find file by d_ino
Amir Goldstein [Thu, 11 May 2017 06:55:08 +0000 (09:55 +0300)]
overlay/017: use t_dir_type to find file by d_ino

'find -ino' is this test was supposed to filter files by inode
number that was recorded with 'ls -i' to compare st_ino returned by
stat(2) with d_ino returned by getdents64(2).

It turns out that on some systems, 'find -ino' uses stat(2) for
filtering by inode number, which is not what we want.

Use the auxiliary program t_dir_type to filter files by inode number
instead.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agosrc/t_dir_type: support filtering by inode number
Amir Goldstein [Thu, 11 May 2017 06:55:07 +0000 (09:55 +0300)]
src/t_dir_type: support filtering by inode number

usage: t_dir_type <dir> <inode number>

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
5 years agogeneric: Add a copy test for invalid input
Anna Schumaker [Wed, 10 May 2017 17:46:28 +0000 (13:46 -0400)]
generic: Add a copy test for invalid input

This test passes invalid argumnt combinations to the copy_file_range()
system call to test that input is verified before attempting to copy.

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