xfstests-dev.git
2 years agooverlay: Test invalidate of readdir cache
Amir Goldstein [Sun, 25 Apr 2021 07:14:45 +0000 (10:14 +0300)]
overlay: Test invalidate of readdir cache

This is a regression test for kernel commit 65cd913ec9d9
("ovl: invalidate readdir cache on changes to dir with origin")

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: Test readdir of modified directrory
Amir Goldstein [Sun, 25 Apr 2021 07:14:44 +0000 (10:14 +0300)]
generic: Test readdir of modified directrory

Check that directory modifications to an open dir fd are observed
by a new open fd.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/t_dir_offset2: Add option to create or unlink file
Amir Goldstein [Sun, 25 Apr 2021 07:14:43 +0000 (10:14 +0300)]
src/t_dir_offset2: Add option to create or unlink file

Will be used to test missing/stale entries after modifications to
an open dirfd.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/t_dir_offset2: Add an option to find file by name
Amir Goldstein [Sun, 25 Apr 2021 07:14:42 +0000 (10:14 +0300)]
src/t_dir_offset2: Add an option to find file by name

Will be used to check for missing/stale entries.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/t_dir_offset2: Add an option to limit of buffer size
Amir Goldstein [Sun, 25 Apr 2021 07:14:41 +0000 (10:14 +0300)]
src/t_dir_offset2: Add an option to limit of buffer size

Will be used to force readdir in several getdents calls.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/49[12]: skip pre-lazysbcount filesystems
Darrick J. Wong [Thu, 29 Apr 2021 01:31:54 +0000 (18:31 -0700)]
xfs/49[12]: skip pre-lazysbcount filesystems

Prior to lazysbcount, the xfs mount code blindly trusted the value of
the fdblocks counter in the primary super, which means that the kernel
doesn't detect the fuzzed fdblocks value at all.  V4 is deprecated and
pre-lazysbcount V4 hasn't been the default for ~14 years, so we'll just
skip these two tests on those old filesystems.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/004: don't fail test due to realtime files
Darrick J. Wong [Wed, 28 Apr 2021 04:09:18 +0000 (21:09 -0700)]
xfs/004: don't fail test due to realtime files

This test exercises xfs_db functionality that relates to the free space
btrees on the data device.  Therefore, make sure that the files we
create are not realtime files.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/449: always fill up the data device
Darrick J. Wong [Wed, 28 Apr 2021 04:09:12 +0000 (21:09 -0700)]
generic/449: always fill up the data device

This is yet another one of those tests that looks at what happens when
we run out of space for more metadata (in this case, xattrs).  Make sure
that the 256M we write to the file to try to stimulate ENOSPC gets
written to the same place that xfs puts xattr data -- the data device.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/{094,225}: fix argument to _require_file_block_size_equals_fs_block_size
Darrick J. Wong [Wed, 28 Apr 2021 04:09:06 +0000 (21:09 -0700)]
generic/{094,225}: fix argument to _require_file_block_size_equals_fs_block_size

Fix the incorrect parameter being passed to this new predicate.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/276: remove unnecessary mkfs golden output
Darrick J. Wong [Wed, 28 Apr 2021 04:09:00 +0000 (21:09 -0700)]
xfs/276: remove unnecessary mkfs golden output

A previous update to this test dropped the clause where the mkfs
standard output gets sent to /dev/null.  The filtered mkfs output isn't
needed here and it breaks the test, so fix that.

Fixes: e97f96e5 ("xfs/27[26]: force realtime on or off as needed")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/631: Add a check for extended attributes
Shreeya Patel [Mon, 3 May 2021 10:26:54 +0000 (15:56 +0530)]
generic/631: Add a check for extended attributes

Test case 631 fails for filesystems like exfat or vfat or any other
which does not support extended attributes.

The main reason for failure is not being able to mount overlayfs
with filesystems that do not support extended attributes.
mount -t overlay overlay -o "$l,$u,$w,$i" $mergedir

Above command would return an error as -
/var/mnt/scratch/merged0: wrong fs type, bad option, bad superblock
on overlay, missing codepage or helper program, or other error.

dmesg log reports the following -
overlayfs: filesystem on '/var/mnt/scratch/upperdir1' not supported

As per the overlayfs documentation -
"A wide range of filesystems supported by Linux can be the lower
filesystem, but not all filesystems that are mountable by Linux
have the features needed for OverlayFS to work. The lower filesystem
does not need to be writable. The lower filesystem can even be another
overlayfs. The upper filesystem will normally be writable and if it
is it must support the creation of trusted.* and/or user.* extended
attributes, and must provide valid d_type in readdir responses,
so NFS is not suitable. A read-only overlay of two read-only
filesystems may use any filesystem type."

As per the above statements from the overlayfs documentation,
it is clear that filesystems that do not support extended
attributes or d_type would not work with overlayfs.
This is why we see the error in dmesg log for upperdir1
which had an exfat filesystem.

This test case already checks for d_type but does not check for
extended attributes, hence add a check for it which would avoid
running this tests for filesystems that are not supported.

Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: test what happens when we reset the root dir and it has xattrs
Darrick J. Wong [Wed, 28 Apr 2021 04:08:43 +0000 (21:08 -0700)]
xfs: test what happens when we reset the root dir and it has xattrs

Make sure that we can reset the root directory and the xattrs are erased
properly.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/010: filter out bad finobt levels complaint
Darrick J. Wong [Wed, 28 Apr 2021 04:08:50 +0000 (21:08 -0700)]
xfs/010: filter out bad finobt levels complaint

Since we're adding to xfs_repair the ability to warn about bad finobt
levels, filter that out.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/rc: not run swapfile test for DAX
Xiaoli Feng [Sat, 24 Apr 2021 16:15:23 +0000 (00:15 +0800)]
common/rc: not run swapfile test for DAX

DAX doesn't support swapfile. Without this patch,
_require_scratch_swapfile always returns fail for fsdax. Now
change to notrun.

Fixes: 725feeff ("common/rc: swapon should not fail for given FS in _require_scratch_swapfile()")
Signed-off-by: Xiaoli Feng <xifeng@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/rc: relax xfs swapfile support checks
Darrick J. Wong [Wed, 28 Apr 2021 04:09:47 +0000 (21:09 -0700)]
common/rc: relax xfs swapfile support checks

In commit 725feeff, I forgot that xfs has *not* always supported all
swap file configurations -- the bmap swapfile activation prior to the
introduction of iomap_swapfile_activate did not permit the use of
unwritten extents in the swap file.  Therefore, kick xfs out of the
always-supported list.

Fixes: 725feeff ("common/rc: swapon should not fail for given FS in _require_scratch_swapfile()")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/419: remove irrelevant swapfile test
Darrick J. Wong [Wed, 28 Apr 2021 04:09:35 +0000 (21:09 -0700)]
xfs/419: remove irrelevant swapfile test

Since the advent of iomap_swapfile_activate in XFS, we actually /do/
support having swap files on the realtime device.  Remove this test.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: add test for zone auto reclaim
Johannes Thumshirn [Thu, 29 Apr 2021 12:39:27 +0000 (21:39 +0900)]
btrfs: add test for zone auto reclaim

Add a test for commit 18bb8bbf13c1 ("btrfs: zoned: automatically
reclaim zones").

This test creates a two file on a newly created FS in a way that
when we delete the first one, an auto reclaim process will be
triggered by the FS.

After the reclaim process, it verifies that the data was moved to
another zone and old zone was successfully reset.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/rc: introduce zone check commands
Naohiro Aota [Thu, 29 Apr 2021 12:39:26 +0000 (21:39 +0900)]
common/rc: introduce zone check commands

Introduce some zone related helper functions: _zone_type(),
_require_zoned_device(), and _require_non_zoned_device(). They all
take a device path as an argument.

_zone_type() return the zone type of the device according to the
value returned from "/sys/block/<disk>/queue/zoned". See
Documentation/ABI/testing/sysfs-block for a detail.

_require_zoned_device() checks if the device is zoned. If not, it
skips the current test. _require_non_zoned_device() does the
opposite.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/153: add _require_idmapped_mounts check
Jinhui Huang [Fri, 30 Apr 2021 09:31:21 +0000 (17:31 +0800)]
xfs/153: add _require_idmapped_mounts check

When this case runs on system without mount_setattr syscall support, it
will report errors rather than skip. so we add _require_idmapped_mounts
to check if mount_setattr syscall is supported.

Signed-off-by: Jinhui Huang <huangjh.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: test upgrading filesystem to bigtime
Darrick J. Wong [Wed, 28 Apr 2021 04:08:33 +0000 (21:08 -0700)]
xfs: test upgrading filesystem to bigtime

Test that we can upgrade an existing filesystem to use bigtime.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com> (xfs/908 only)
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: test fsync after rename and link with cow and nocow writes
Filipe Manana [Tue, 27 Apr 2021 10:29:50 +0000 (11:29 +0100)]
btrfs: test fsync after rename and link with cow and nocow writes

Test for fsync data loss after renaming a file or adding a hard link,
with a previous fsync of another file, as well as that mtime and ctime
are correct after a power failure. Test both with COW and NOCOW writes.

This currently fails differently on different kernels:

- For kernels older than 4.19 (<= 4.18) and kernels starting from 5.10,
  the NOCOW tests are expected to fail very often on the mtime and ctime
  checks.

  The data loss check has slim chances of failing on a virtualized
  environment, because the race that leads to the data loss is due to
  the fsync() returning after writeback of the data finishes and
  returning without issuing barriers (sending REQ_PREFLUSH to the
  device), as explained in the test's comments.

  For kernels between 4.19 (inclusive) and 5.9 (inclusive), it is not
  expected to fail.

- For the btrfs integration branch (misc-next), and what is currently in
  Linus' master branch (5.13 merge window changes), in addition to the
  failures mentioned before, the test should fail very often on the data
  loss and mtime/ctime checks for COW writes.

The issues are fixed by a patch for the kernel that has the following
subject:

  "btrfs: fix race leading to unpersisted data and metadata on fsync"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/192: fix instability on exFAT
Pavel Reichl [Tue, 27 Apr 2021 08:59:29 +0000 (10:59 +0200)]
generic/192: fix instability on exFAT

exFAT's access time has 2s granularity and is rounded down.

This can cause problems, e.g.:

if real access times are: time1=2 and time2=7, then 7 - 2 = 5;
but exfat_atime(7) - exfat_atime(2) => 6 - 2 = 4 which is less
than expected delay.

To fix this, even (delay - 1s) should be considered as a valid result
for exFAT.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon: Fix recovery tests for tmpfs
Jan Kara [Mon, 26 Apr 2021 20:50:11 +0000 (22:50 +0200)]
common: Fix recovery tests for tmpfs

Tmpfs doesn't support metadata journalling. Recognize it as such.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay/065: Adapt test to relaxed rules
Amir Goldstein [Mon, 26 Apr 2021 16:01:43 +0000 (19:01 +0300)]
overlay/065: Adapt test to relaxed rules

Kernel commit 708fa01597fa ("ovl: allow upperdir inside lowerdir")
changes the rules w.r.t allowed overlayfs configurations, so the
upperdir/lowerdir test that expects an error fails.

Adapt the test to check the configuration that is still not allowed
(lowerdir inside upperdir), which had no test coverage.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/563: tolerate small reads in "write -> read/write" sub-test
Boyang Xue [Mon, 26 Apr 2021 14:56:20 +0000 (22:56 +0800)]
generic/563: tolerate small reads in "write -> read/write" sub-test

On ext2/ext3, it's expected that several single block metadata reads
can occur when writing to file in the same cgroup (the stack is like
below[1]). The purpose of the "write -> read/write" subtest is to
make sure the larger pwrite is accounted to the correct cgroup, not
necessarily enforce that zero bytes are read in service of the
write. This patch fixes the sub-test in order to tolerate small
reads in 1st cgroup.

[1] Callchain of the read:

@ext3_read_bio[
    submit_bio+1
    submit_bh_wbc+365
    ext4_read_bh+72
    ext4_get_branch+201
    ext4_ind_map_blocks+382
    ext4_map_blocks+295
    _ext4_get_block+170
    __block_write_begin_int+328
    ext4_write_begin+541
    generic_perform_write+213
    ext4_buffered_write_iter+167
    new_sync_write+345
    vfs_write+438
    __x64_sys_pwrite64+140
    do_syscall_64+51
    entry_SYSCALL_64_after_hwframe+68
, 5793, 12]: 3

Signed-off-by: Boyang Xue <bxue@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/631: remove useless nfs_export=off
Yang Xu [Mon, 26 Apr 2021 07:57:03 +0000 (15:57 +0800)]
generic/631: remove useless nfs_export=off

The nfs_export feature was introduced since kernel v4.16-rc1 after
commit f168f1098dd9038 ("ovl: add support for "nfs_export"
configuration").  On old kernel, this case will result in infinite
loop because overlay mount failed because of unrecognized mount
options nfs_export=off.

In kernel documentation, overlay.rst said "the mount options
index=off,nfs_export=on are conflicting for a read-write mount and
will result in an error.".  So using single index=off is also ok in
here.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/idmapped-mounts: Remove useless header file
Yang Xu [Mon, 26 Apr 2021 06:23:07 +0000 (14:23 +0800)]
src/idmapped-mounts: Remove useless header file

When compile xfstest on old kernel, mount-idmapped.c will fail
because of missing linux/bpf.h. But this src file doesn't use bpf
realted functions or macros.

So remove these useless header files in idmapped-mounts.c and
mount-idmapped.c.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/idmapped-mounts: use renameat instead of renameat2
Yang Xu [Sun, 25 Apr 2021 10:02:39 +0000 (18:02 +0800)]
src/idmapped-mounts: use renameat instead of renameat2

We don't add fallback for renameat2, so it build failed on old
kernel.  Also, renameat2() man-pages said as below:

"renameat2() has an additional flags argument.  A renameat2() call
with a zero flags argument is equivalent to renameat()."

In this src file, we use zero flag for all renameat2 call. So we use
renameat directly.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by:Anju T Sudhakar<anju@linux.vnet.ibm.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc: Fix an error for the loop initialization declaration
Yang Xu [Sun, 25 Apr 2021 10:02:38 +0000 (18:02 +0800)]
src: Fix an error for the loop initialization declaration

When compile them old gcc, get the following error
mount-idmapped.c: In function 'parse_map':
mount-idmapped.c:154:2: error: 'for' loop initial declarations are only allowed in C99 mode
  for (int i = 0; i < 2; i++) {

Fix them by declaring them at the beggining instead of in loop.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/144: Use _qsetup instead of qsetup
Yang Xu [Fri, 23 Apr 2021 04:23:58 +0000 (12:23 +0800)]
xfs/144: Use _qsetup instead of qsetup

Since xfstests commit 56908a2eb566c5("common/quota: move _qsetup()
helper to common code"), we have common _qsetup function. Even this
case doesn't use enforce value like xfs/050 and xfs/299, using
_qsetup is more meaningful. So remove useless qsetup.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: add missing checks of fallocate feature
Naohiro Aota [Fri, 23 Apr 2021 11:26:31 +0000 (20:26 +0900)]
fstests: add missing checks of fallocate feature

Many test cases use xfs_io -c 'falloc' but forgot to add
_require_xfs_io_command "falloc". This will fail the test case if we
run the test case on a file system without fallcoate support e.g.
F2FS.

While we believe that normal fallocate(mode = 0) is always supported
on Linux, it is not true. Fallocate is disabled in several
implementations of zoned block support for file systems because the
pre-allocated region will break the sequential writing rule.

Currently, several test cases unconditionally call fallocate().
Let's add _require_xfs_io_command "falloc" to properly check the
feature is supported by a testing file system.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/495: split the test
Pavel Reichl [Fri, 23 Apr 2021 10:07:31 +0000 (12:07 +0200)]
generic/495: split the test

Split each swap-file test into its own test. So on file-systems that
do not support e.g. sparse files (exfat) other swap-file tests can be
executed.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Tested-by: Shreeya Patel <shreeya.patel@collabora.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/145: Remove useless -f option for xfs_quota command
Yang Xu [Thu, 22 Apr 2021 05:05:43 +0000 (13:05 +0800)]
xfs/145: Remove useless -f option for xfs_quota command

Since it is a xfs specifal case, we don't need to use foreign
filesystem mode.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Jinhui Huang <huangjh.jy@fujitsu.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: detect time limits from filesystem
Darrick J. Wong [Wed, 21 Apr 2021 00:23:20 +0000 (17:23 -0700)]
xfs: detect time limits from filesystem

Teach fstests to extract timestamp limits of a filesystem using the new
xfs_db timelimit command.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/122: add legacy timestamps to ondisk checker
Darrick J. Wong [Wed, 21 Apr 2021 00:23:13 +0000 (17:23 -0700)]
xfs/122: add legacy timestamps to ondisk checker

Add these new ondisk structures.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: check userspace handling of extreme timestamps
Darrick J. Wong [Wed, 21 Apr 2021 00:23:07 +0000 (17:23 -0700)]
generic: check userspace handling of extreme timestamps

These two tests ensure we can store and retrieve timestamps on the
extremes of the date ranges supported by userspace, and the common
places where overflows can happen.

They differ from generic/402 in that they don't constrain the dates
tested to the range that the filesystem claims to support; we attempt
various things that /userspace/ can parse, and then check that the vfs
clamps and persists the values correctly.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: test inobtcount upgrade
Darrick J. Wong [Thu, 22 Apr 2021 00:53:24 +0000 (17:53 -0700)]
xfs: test inobtcount upgrade

Make sure we can actually upgrade filesystems to support inode btree
counters.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: functional testing of V5-relevant options
Darrick J. Wong [Thu, 22 Apr 2021 00:51:27 +0000 (17:51 -0700)]
xfs: functional testing of V5-relevant options

Currently, the only functional testing for xfs_admin is xfs/287, which
checks that one can add 32-bit project ids to a V4 filesystem.  This
obviously isn't an exhaustive test of all the CLI arguments, and
historically there have been xfs configurations that don't even work.

Therefore, introduce a couple of new tests -- one that will test the
simple options with the default configuration, and a second test that
steps a bit outside of the test run configuration to make sure that we
do the right thing for external devices.  The second test already caught
a nasty bug in xfsprogs 5.11.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: test that the needsrepair feature works as advertised
Darrick J. Wong [Thu, 22 Apr 2021 00:49:13 +0000 (17:49 -0700)]
xfs: test that the needsrepair feature works as advertised

Make sure that the needsrepair feature flag can be cleared only by
repair and that mounts are prohibited when the feature is set.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/dmthin: make this work with external log devices
Darrick J. Wong [Wed, 21 Apr 2021 00:22:31 +0000 (17:22 -0700)]
common/dmthin: make this work with external log devices

Provide a mkfs helper to format the dm thin device when external devices
are in use, and fix the dmthin mount helper to support them.  This fixes
regressions in generic/347 and generic/500 when external logs are in
use.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/223: make sure all files get created on the data device
Darrick J. Wong [Wed, 21 Apr 2021 00:22:25 +0000 (17:22 -0700)]
generic/223: make sure all files get created on the data device

This test formats filesystems with various stripe alignments, then
checks that data file allocations are actually aligned to those stripe
geometries.  If this test is run on an XFS filesystem with a realtime
volume and RTINHERIT is set on the root dir, the test will fail because
all new files will be created as realtime files, and realtime
allocations are not subject to data device stripe alignments.  Fix this
by clearing rtinherit on the root dir.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/rc: Add _require_{chown,chmod}()
Pavel Reichl [Mon, 19 Apr 2021 22:04:03 +0000 (00:04 +0200)]
common/rc: Add _require_{chown,chmod}()

Add helper functions that ensure that test is only executed on file
systems that implement chown, chmod and symbolic links.

Fixed test are: generic/{87,88,125,126,128,193,314,317,355,597,598}

[Eryu: remove _require_test and declare variable as local]

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/619: a better way to get tot_avail_size
Sun Ke [Mon, 19 Apr 2021 12:34:37 +0000 (08:34 -0400)]
generic/619: a better way to get tot_avail_size

When FSTYP is tmpfs, $DF_PROG --block-size=1 $SCRATCH_DEV is not suitted.

Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/003: Amend the test for exfat
Pavel Reichl [Thu, 15 Apr 2021 09:49:05 +0000 (11:49 +0200)]
generic/003: Amend the test for exfat

Update the test so it can be run even for exfat which has 2 seconds
granularity for access_time and does not have a timestamp for
metadata change.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/554: hide permision warning on exfat
Pavel Reichl [Thu, 15 Apr 2021 09:49:04 +0000 (11:49 +0200)]
generic/554: hide permision warning on exfat

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon: hide permision warning from mkswap for exfat
Pavel Reichl [Thu, 15 Apr 2021 09:49:03 +0000 (11:49 +0200)]
common: hide permision warning from mkswap for exfat

exfat does not support posix file permisions, so warning from mkswap is
inavitable. This patch hides the warning message so the test won't fail.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/305: make sure that fsstress is still running when we quotaoff
Darrick J. Wong [Wed, 14 Apr 2021 01:05:26 +0000 (18:05 -0700)]
xfs/305: make sure that fsstress is still running when we quotaoff

Greatly increase the number of fs ops that fsstress is supposed to run
in in this test so that we can ensure that it's still running when the
quotaoff gets run.  1000 might have been sufficient in 2013, but it
isn't now.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/{094,225}: skip test when the xfs rt extent size is larger than 1 fsb
Darrick J. Wong [Wed, 14 Apr 2021 01:05:20 +0000 (18:05 -0700)]
generic/{094,225}: skip test when the xfs rt extent size is larger than 1 fsb

These two tests call various fallocate modes on a file and compare the
FIEMAP output to some golden output.  Unfortunately, the golden output
doesn't take into account the possibility that (on XFS) the files could be
created on a realtime volume with a large rt extent size set.

Under such a configuration, fpunch operations that are aligned to the fs
block size but not the rt extent size simply result in those blocks
being set to unwritten status.  Unfortunately, the test expects holes
and fails.  Therefore, detect the situation and skip the tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/620: fix order of require_scratch calls
Darrick J. Wong [Wed, 14 Apr 2021 01:05:14 +0000 (18:05 -0700)]
generic/620: fix order of require_scratch calls

_require_scratch_16T_support does not itself check that the scratch
device exists, which means that it depends on someone else to call
_require_scratch.  Document this dependency and fix this test so that we
can run:

./check --exact-order generic/374 generic/620

on an ext4 filesystem without g/620 tripping over the mess left by g/374
when it calls _notrun.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agomisc: replace more open-coded _scratch_xfs_db calls
Darrick J. Wong [Wed, 14 Apr 2021 01:05:07 +0000 (18:05 -0700)]
misc: replace more open-coded _scratch_xfs_db calls

Replace the last remaining open-coded calls to xfs_db for the scratch
device with calls to _scratch_xfs_db.  This fixes these tests when
external logs are enabled.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/dump: filter out xfs_restore messages about fallocate failures
Darrick J. Wong [Wed, 14 Apr 2021 01:04:54 +0000 (18:04 -0700)]
common/dump: filter out xfs_restore messages about fallocate failures

fallocate is not supported on XFS filesystems that are running in
"always COW" mode.  This leads to false test regressions because
xfs_restore complains about EOPNOTSUPP in the golden output.  The
preallocation isn't required for correct xfs_restore operation, so
filter out the EOPNOTSUPP messages.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/521,530: refactor scratch fs check
Darrick J. Wong [Wed, 14 Apr 2021 01:04:48 +0000 (18:04 -0700)]
xfs/521,530: refactor scratch fs check

Use the existing _check_scratch_fs helper to check the (modified)
scratch filesystem in these tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/563: selectively remove the io cgroup controller
Darrick J. Wong [Wed, 14 Apr 2021 01:04:42 +0000 (18:04 -0700)]
generic/563: selectively remove the io cgroup controller

If a system configuration tool such as systemd sets up the io cgroup
controller for its own purposes, it's possible that the last line of
this test will not be able to remove the io controller from the system
configuration.  This causes the test to fail even though the inability
to tear down systemd should not be considered (in this case) a failure.

Change this test to set the "io" component of subtree control back to
whatever it was when the test started.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/506: fix regression on freshly quotachecked filesystem
Darrick J. Wong [Wed, 14 Apr 2021 01:04:36 +0000 (18:04 -0700)]
xfs/506: fix regression on freshly quotachecked filesystem

The first thing this test checks is that the health command reports that
nothing has been checked.  This isn't true if we regenerated the quota
counts when we mounted the filesystem (and hence they're marked healthy
and checked), so cycle the mount to get rid of that state.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: quotas on idmapped mounts
Christian Brauner [Mon, 12 Apr 2021 11:57:08 +0000 (13:57 +0200)]
xfs: quotas on idmapped mounts

This is basically a re-implementation of xfs/050 but each file creation
call is done through an idmapped mount which verifies that the semantics
are identical even when the mount is idmapped.

Cc: Eryu Guan <guan@eryu.me>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: fstests@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: quotas and idmapped mounts
Christian Brauner [Mon, 12 Apr 2021 11:57:07 +0000 (13:57 +0200)]
xfs: quotas and idmapped mounts

Test that xfs quota behave correctly on idmapped mounts.
Mount a scratch device with user and group quota support enabled. Create
directories "unmapped" and "idmapped". Create files in the unampped
mount and verify quota behavior. Create files through the idmapped mount
and verify identical behavior.

Cc: Eryu Guan <guan@eryu.me>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: fstests@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/quota: move _qsetup() helper to common code
Christian Brauner [Mon, 12 Apr 2021 11:57:06 +0000 (13:57 +0200)]
common/quota: move _qsetup() helper to common code

It's already used in two tests and will be used in a third.

Cc: Eryu Guan <guan@eryu.me>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: fstests@vger.kernel.org
Suggested-by: Eryu Guan <guan@eryu.me>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/rc: add _scratch_{u}mount_idmapped() helpers
Christian Brauner [Mon, 12 Apr 2021 11:57:05 +0000 (13:57 +0200)]
common/rc: add _scratch_{u}mount_idmapped() helpers

They will be used in follow-up patches for xfs quota tests but might be
useful for other tests in the future.

Cc: Eryu Guan <guan@eryu.me>
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Howells <dhowells@redhat.com>
Cc: fstests@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: add fstests for idmapped mounts
Christian Brauner [Mon, 12 Apr 2021 11:57:04 +0000 (13:57 +0200)]
generic: add fstests for idmapped mounts

Add a test suite to verify the behavior of idmapped mounts. The test
suite also includes a range of vfs tests to verify that no regressions
are introduced by idmapped mounts. The following tests are currently
available with more to come in the future:

01. posix acls on regular and idmapped mounts
02. create operations in user namespace
03. device node creation in user namespace
04. expected ownership on idmapped mounts
05. fscaps on regular mounts
06. fscaps on idmapped mounts
07. fscaps on idmapped mounts in user namespace
08. fscaps on idmapped mounts in user namespace
    with different id mappings
09. mapped fsids
10. unmapped fsids
11. cross mount hardlink
12. cross idmapped mount hardlink
13. hardlinks from idmapped mounts
14. hardlinks from idmapped mounts in user namespace
15. io_uring
16. io_uring in user namespace
17. io_uring from idmapped mounts
18. io_uring from idmapped mounts in user namespace
19. io_uring from idmapped mounts with unmapped ids
20. io_uring from idmapped mounts with unmapped ids in user namespace
21. following protected symlinks on regular mounts
22. following protected symlinks on idmapped mounts
23. following protected symlinks on idmapped mounts in user namespace
24. cross mount rename
25. cross idmapped mount rename
26. rename from idmapped mounts
27. rename from idmapped mounts in user namespace
28. symlink from regular mounts
29. symlink from idmapped mounts
30. symlink from idmapped mounts in user namespace
31. setid binaries on regular mounts
32. setid binaries on idmapped mounts
33. setid binaries on idmapped mounts in user namespace
34. setid binaries on idmapped mounts in user namespace
    with different id mappings
35. sticky bit unlink operations on regular mounts
36. sticky bit unlink operations on idmapped mounts
37. sticky bit unlink operations on idmapped mounts in user namespace
38. sticky bit rename operations on regular mounts
39. sticky bit rename operations on idmapped mounts
40. sticky bit rename operations on idmapped mounts in user namespace
41. create operations in directories with setgid bit set
42. create operations in directories with setgid bit set
    on idmapped mounts
43. create operations in directories with setgid bit set
    on idmapped mounts in user namespace
44. verify create operations and ownership with racing threads idmapping
    a mount
45. setattr truncate operations on regular mounts
46. setattr truncate operations on idmapped mounts
47. setattr truncate operations on idmapped mounts in user namespace

Here's some sample output when running with DEBUG_TRACE defined:

Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Eryu Guan <guan@eryu.me>
Cc: fstests@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: add test for detached mount propagation
Christian Brauner [Mon, 12 Apr 2021 11:57:03 +0000 (13:57 +0200)]
generic: add test for detached mount propagation

Regression test to verify that creating a series of detached mounts,
attaching them to the filesystem, and unmounting them does not trigger an
integer overflow in ns->mounts causing the kernel to block any new mounts in
count_mounts() and returning ENOSPC because it falsely assumes that the
maximum number of mounts in the mount namespace has been reached, i.e. it
thinks it can't fit the new mounts into the mount namespace anymore.

The test is written in a way that it will leave the host's mount
namespace intact so we are sure to never make the host's mount namespace
unuseable!

Link: https://git.kernel.org/torvalds/c/ee2e3f50629f17b0752b55b2566c15ce8dafb557
Cc: Eryu Guan <guan@eryu.me>
Cc: David Howells <dhowells@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/591: add _require_odirect
Sun Ke [Mon, 12 Apr 2021 07:34:03 +0000 (03:34 -0400)]
generic/591: add _require_odirect

src/splice-test will open a file with O_DIRECT flag, so add
_require_odirect.

Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/xfs: work around a hang-on-stdin bug in xfs_admin 5.11
Darrick J. Wong [Wed, 31 Mar 2021 01:08:15 +0000 (18:08 -0700)]
common/xfs: work around a hang-on-stdin bug in xfs_admin 5.11

xfs_admin in xfsprogs 5.11 has a bug wherein a caller who specifies an
external log device forces xfs_db to be invoked, potentially with zero
command arguments.  When this happens, xfs_db will wait for input on
stdin, which causes fstests to hang.  Since xfs_admin is not an
interactive tool, redirect stdin from /dev/null to prevent this issue.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/xfs: support realtime devices with _scratch_xfs_admin
Darrick J. Wong [Wed, 31 Mar 2021 01:08:10 +0000 (18:08 -0700)]
common/xfs: support realtime devices with _scratch_xfs_admin

Teach _scratch_xfs_admin to support passing the realtime device to
xfs_admin so that we can actually test xfs_admin functionality with
those setups.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/23[12]: abstractify the XFS cow prealloc trimming interval
Darrick J. Wong [Wed, 31 Mar 2021 01:09:05 +0000 (18:09 -0700)]
xfs/23[12]: abstractify the XFS cow prealloc trimming interval

Create a couple of helper functions to get and set the XFS copy on write
preallocation garbage collection interval.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/502: scale file count based on AG count to avoid thrashing
Brian Foster [Fri, 9 Apr 2021 19:08:34 +0000 (15:08 -0400)]
xfs/502: scale file count based on AG count to avoid thrashing

xfs/502 currently creates a default of 30k unlinked files per CPU.
While this completes in a reasonable amount of time on systems with
lesser numbers of CPUs, this scales poorly on high CPU count systems
that are otherwise testing smaller default filesystems. For example,
on an 80xcpu box and a 15GB (4 AG) XFS filesystem, xfs/502 requires
3 hours to complete. The same test on a 4xcpu vm (or the 80xcpu
hardware with an 80AG filesystem instead of the default of 4AGs)
completes in a little over 5 minutes. This is a rather severe
thrashing breakdown that doesn't add much value to the test
coverage.

Address this problem by scaling the file count to the AG count of
the filesystem rather than the CPU count of the test system. Since
the AG count is likely to be less than the CPU count, bump the
default scaling factor a bit from 30k per CPU to 50k per AG. From
there, larger counts can still be exercised via the global load
factor configuration.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/53[238]: Disable realtime inherit flag
Chandan Babu R [Fri, 9 Apr 2021 12:49:03 +0000 (18:19 +0530)]
xfs/53[238]: Disable realtime inherit flag

The minimum length space allocator (i.e.
xfs_bmap_exact_minlen_extent_alloc()) depends on the underlying
filesystem to be fragmented so that there are enough one block sized
extents available to satify space allocation requests.

xfs/{532,533,538} tests issue space allocation requests for metadata
(e.g. for blocks holding directory and xattr information). With
realtime filesystem instances, these tests would end up fragmenting
the space on realtime device. Hence minimum length space allocator
fails since the regular filesystem space is not fragmented and hence
there are no one block sized extents available.

Thus, this commit disables realtime inherit flag (if any) on root
directory so that space on data device gets fragmented rather than
realtime device.

Suggested-by: Darrick J. Wong <djwong@kernel.org>
Reported-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: Fix tests to execute in multi-block directory config
Chandan Babu R [Fri, 2 Apr 2021 02:49:40 +0000 (08:19 +0530)]
fstests: Fix tests to execute in multi-block directory config

xfs/{529,531,532,534,535} attempt to create test files after injecting
reduce_max_iextents error tag. Creation of test files fails when using a
multi-block directory test configuration because,

1. A directory can have a pseudo maximum extent count of 10.
2. In the worst case a directory entry creation operation can consume
   (XFS_DA_NODE_MAXDEPTH + 1 + 1) * (Nr fs blocks in a single directory block)
   extents.
   With 1k fs block size and 4k directory block size, this evaluates to,
   (5 + 1 + 1) * 4
   = 7 * 4
   = 28
   > 10 (Pseudo maximum inode extent count).

This commit fixes the issue by creating test files before injecting
reduce_max_iextents error tag.

Reported-by: Darrick J. Wong <djwong@kernel.org>
Suggested-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/529: Execute chown on an existing directory entry
Chandan Babu R [Fri, 2 Apr 2021 02:49:39 +0000 (08:19 +0530)]
xfs/529: Execute chown on an existing directory entry

chown command is being executed on $testfile which is actually
deleted just before the execution of quota inode extent count
overflow test. Hence the test was not getting exercised at all.

This commit fixes the bug by using $fillerdir as the target of chown
command.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/608: Add new regression test
Xiao Yang [Tue, 30 Mar 2021 02:06:55 +0000 (10:06 +0800)]
generic/608: Add new regression test

Write data into a file and then enable DAX on the file immediately,
the written data which is still in the buffer should be synchronized
to disk instead of discarded when the corresponding inode is evicted.

It's a regression test for commit 88149082bb8e ("fs: Handle
I_DONTCACHE in iput_final() instead of generic_drop_inode()")

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/608: Remove drop cache and umount & mount cycle
Xiao Yang [Tue, 30 Mar 2021 02:06:54 +0000 (10:06 +0800)]
generic/608: Remove drop cache and umount & mount cycle

Since commit 77573fa310d9, toggling FS_XFLAG_DAX on an existing file can make
S_DAX on the file change immediately when all applications close the file.
As a result, we don't need the redundant drop cache and umount & mount cycle.

Signed-off-by: Xiaoli Feng <xifeng@redhat.com>
Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/233,270: unlimit the max locked memory size for io_uring
Zorro Lang [Tue, 30 Mar 2021 00:59:42 +0000 (08:59 +0800)]
generic/233,270: unlimit the max locked memory size for io_uring

The ltp/fsstress always fails on io_uring_queue_init() by returnning
ENOMEM. Due to io_uring accounts memory it needs under the rlimit
memlocked option, which can be quite low on some setups, especially
on 64K pagesize machine. root isn't under this restriction, but
regular users are. So only g/233 and g/270 which use $qa_user to run
fsstress are failed.

To avoid this failure, set max locked memory to unlimited before
doing fsstress, then restore it after test done.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/629: add missing copy_range command check
Chao Yu [Mon, 29 Mar 2021 01:40:13 +0000 (09:40 +0800)]
generic/629: add missing copy_range command check

Otherwise, if xfs_io doesn't support this command, it will report
that filesystem fails on this testcase.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test the xfs_db ls command
Darrick J. Wong [Thu, 25 Mar 2021 16:36:25 +0000 (09:36 -0700)]
xfs: test the xfs_db ls command

Make sure that the xfs_db ls command works the way the author thinks it
does.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test the xfs_db path command
Darrick J. Wong [Tue, 23 Mar 2021 04:20:24 +0000 (21:20 -0700)]
xfs: test the xfs_db path command

Add a new test to make sure the xfs_db path command works the way the
author thinks it should.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: don't rely on /proc/partitions for device size
Johannes Thumshirn [Fri, 26 Mar 2021 15:34:37 +0000 (00:34 +0900)]
common/rc: don't rely on /proc/partitions for device size

Non-partitionable devices, like zoned block devices, aren't showing
up in in /proc/partitions and therefore we cannot rely on it to get
a device's size.

Use blockdev --getsz to get the block device size.

Cc: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: add test for send/receive with file capabilities set
Filipe Manana [Fri, 26 Mar 2021 12:15:32 +0000 (12:15 +0000)]
btrfs: add test for send/receive with file capabilities set

Test that if we set a capability on a file but not on the next files we
create, send/receive operations only apply the capability to the first
file, the one for which we have set a capability.

This is motivated by a regression that started to happen with kernel 5.8,
caused by an incompatibility between kernel commit 89efda52e6b693
("btrfs: send: emit file capabilities after chown") and a workaround for
send/receive added to btrfs-progs several years ago by btrfs-progs
commit 123a2a085027e ("btrfs-progs: receive: restore capabilities after
chown"). That workaround in btrfs-progs was added in btrfs-progs 4.1.

That kernel commit ended up fixing the bugs the btrfs-progs commit
targeted, as well as other bugs around btrfs send and capabilities.
However it did not play nice with the btrfs-progs workaround.
The kernel fix was backported to all stable kernels and the btrfs-progs
workaround was later removed from btrfs-progs by commit 81d8ea9346c6ee
("btrfs-progs: receive: remove workaround for setting capabilities"),
introduced in btrfs-progs 5.11.

The test currently fails on any environment using kernel 5.8+ and a
btrfs-progs version between 4.1 and 5.10. Updating btrfs-progs to
version 5.11 makes the test pass.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test a deadlock in xfs_rename when whiteing out files
Darrick J. Wong [Tue, 23 Mar 2021 04:20:17 +0000 (21:20 -0700)]
generic: test a deadlock in xfs_rename when whiteing out files

wenli xie reported a buffer cache deadlock when an overlayfs is mounted
atop xfs and overlayfs tries to replace a single-nlink file with a
whiteout file.  This test reproduces that deadlock.

Reported-by: wenli xie <wlxie7296@gmail.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: refactor _require_{ext2,tmpfs} helpers
Darrick J. Wong [Tue, 23 Mar 2021 04:20:11 +0000 (21:20 -0700)]
common/rc: refactor _require_{ext2,tmpfs} helpers

Combine these two helpers into a single generic function so that we can
use it in the next patch to test a regression when running overlayfs
atop xfs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test rtalloc alignment and math errors
Darrick J. Wong [Tue, 23 Mar 2021 04:20:06 +0000 (21:20 -0700)]
xfs: test rtalloc alignment and math errors

Add a couple of regression tests for "xfs: make sure the rt allocator
doesn't run off the end" and "xfs: ensure that fpunch, fcollapse, and
finsert operations are aligned to rt extent size".

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/556: Fix rename test
André Almeida [Wed, 24 Mar 2021 22:48:17 +0000 (19:48 -0300)]
generic/556: Fix rename test

Casefold rename test should check if renaming a file to an equivalent
name fails as expect (e.g. renaming from "file.txt" to "FILE.TXT") and
`mv` correctly identifies that those names refers to the same file.
Currently, the test doesn't do what is expected given that it doesn't
have the file to be renamed, and `mv` returns "No such file or
directory". Fix that by creating test files and checking the correct
output.

Fixes: 12b7dddbc265fcb ("generic: Add tests for filename casefolding feature")
Signed-off-by: André Almeida <andrealmeid@collabora.com>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon: Escape SCRATCH_DEV variable
André Almeida [Wed, 24 Mar 2021 22:48:16 +0000 (19:48 -0300)]
common: Escape SCRATCH_DEV variable

Escape SCRATCH_DEV variable so it prints its name, instead of printing
the value. If the value is "", the error message will not be very
informative.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/populate: change how we describe cached populated images
Darrick J. Wong [Wed, 24 Mar 2021 18:17:48 +0000 (11:17 -0700)]
common/populate: change how we describe cached populated images

The device name of a secondary storage device isn't all that important,
but the size is.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/populate: create fifos when pre-populating filesystems
Darrick J. Wong [Tue, 23 Mar 2021 04:19:53 +0000 (21:19 -0700)]
common/populate: create fifos when pre-populating filesystems

Create fifos when populating the scratch filesystem for completeness.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agopopulate: create block devices when pre-populating filesystems
Darrick J. Wong [Tue, 23 Mar 2021 04:19:48 +0000 (21:19 -0700)]
populate: create block devices when pre-populating filesystems

I just noticed that the fs population helper creates a chardev file
"S_IFBLK" on the scratch filesystem.  This seems bogus (particularly
since we actually also create a chardev named S_IFCHR) so fix up the
mknod calls.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/122: embiggen struct xfs_agi size for inobtcount feature
Darrick J. Wong [Tue, 23 Mar 2021 04:20:55 +0000 (21:20 -0700)]
xfs/122: embiggen struct xfs_agi size for inobtcount feature

Make the expected AGI size larger for the inobtcount feature.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/{010,030}: update repair output to deal with inobtcount feature
Darrick J. Wong [Tue, 23 Mar 2021 04:20:50 +0000 (21:20 -0700)]
xfs/{010,030}: update repair output to deal with inobtcount feature

Update both of these tests to filter out the new error messages from
repair when the inode btree counter feature is enabled.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: no excessive warnings about dprecated mount options on remount
Pavel Reichl [Fri, 19 Mar 2021 22:20:19 +0000 (23:20 +0100)]
xfs: no excessive warnings about dprecated mount options on remount

Verify that warnings about deprecated mount options are properly
printed.

Verify that no excessive warnings are printed during remounts.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: Stress test with bmap_alloc_minlen_extent error tag enabled
Chandan Babu R [Tue, 9 Mar 2021 05:01:24 +0000 (10:31 +0530)]
xfs: Stress test with bmap_alloc_minlen_extent error tag enabled

This commit adds a stress test that executes fsstress with
bmap_alloc_minlen_extent error tag enabled.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when swapping extents
Chandan Babu R [Tue, 9 Mar 2021 05:01:23 +0000 (10:31 +0530)]
xfs: Check for extent overflow when swapping extents

This test verifies that XFS does not cause inode fork's extent count to
overflow when swapping forks across two files.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when remapping an extent
Chandan Babu R [Tue, 9 Mar 2021 05:01:22 +0000 (10:31 +0530)]
xfs: Check for extent overflow when remapping an extent

This test verifies that XFS does not cause inode fork's extent count to
overflow when remapping extents from one file's inode fork to another.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when moving extent from cow to data fork
Chandan Babu R [Tue, 9 Mar 2021 05:01:21 +0000 (10:31 +0530)]
xfs: Check for extent overflow when moving extent from cow to data fork

This test verifies that XFS does not cause inode fork's extent count to
overflow when writing to/funshare-ing a shared extent.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when writing to unwritten extent
Chandan Babu R [Tue, 9 Mar 2021 05:01:20 +0000 (10:31 +0530)]
xfs: Check for extent overflow when writing to unwritten extent

This test verifies that XFS does not cause inode fork's extent count to
overflow when writing to an unwritten extent.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when adding/removing dir entries
Chandan Babu R [Tue, 9 Mar 2021 05:01:19 +0000 (10:31 +0530)]
xfs: Check for extent overflow when adding/removing dir entries

This test verifies that XFS does not cause inode fork's extent count to
overflow when adding/removing directory entries.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when adding/removing xattrs
Chandan Babu R [Tue, 9 Mar 2021 05:01:18 +0000 (10:31 +0530)]
xfs: Check for extent overflow when adding/removing xattrs

This test verifies that XFS does not cause inode fork's extent count to
overflow when adding/removing xattrs.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when punching a hole
Chandan Babu R [Tue, 9 Mar 2021 05:01:17 +0000 (10:31 +0530)]
xfs: Check for extent overflow when punching a hole

This test verifies that XFS does not cause inode fork's extent count to
overflow when punching out an extent.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when growing realtime bitmap/summary inodes
Chandan Babu R [Tue, 9 Mar 2021 05:01:16 +0000 (10:31 +0530)]
xfs: Check for extent overflow when growing realtime bitmap/summary inodes

Verify that XFS does not cause realtime bitmap/summary inode fork's
extent count to overflow when growing the realtime volume associated
with a filesystem.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when trivally adding a new extent
Chandan Babu R [Tue, 9 Mar 2021 05:01:15 +0000 (10:31 +0530)]
xfs: Check for extent overflow when trivally adding a new extent

This test verifies that XFS does not cause inode fork's extent count to
overflow when adding a single extent while there's no possibility of splitting
an existing mapping.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agocommon/xfs: Add helper to obtain fsxattr field value
Chandan Babu R [Thu, 11 Mar 2021 08:52:05 +0000 (14:22 +0530)]
common/xfs: Add helper to obtain fsxattr field value

This commit adds a helper function to obtain the value of a particular field
of an inode's fsxattr fields.

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agocommon/xfs: Add a helper to get an inode fork's extent count
Chandan Babu R [Tue, 9 Mar 2021 05:01:13 +0000 (10:31 +0530)]
common/xfs: Add a helper to get an inode fork's extent count

This commit adds the helper _scratch_get_iext_count() which returns an
inode fork's extent count.

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years ago_check_xfs_filesystem: sync fs before running scrub
Chandan Babu R [Tue, 9 Mar 2021 05:01:12 +0000 (10:31 +0530)]
_check_xfs_filesystem: sync fs before running scrub

Tests can create a scenario in which a call to syncfs() issued at the end of
the execution of the test script would return an error code. xfs_scrub
internally calls syncfs() before starting the actual online consistency check
operation. Since this call to syncfs() fails, xfs_scrub ends up returning
without performing consistency checks on the test filesystem. This can mask a
possible on-disk data structure corruption.

To fix the above stated problem, this commit invokes syncfs() prior to
executing xfs_scrub.

Suggested-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>