Commit Graph

266 Commits

Author SHA1 Message Date
Filipe Manana 2605c135e1 btrfs: add test for multiple fsync with adjacent preallocated extents
Test a scenario where we do several partial writes into multiple
preallocated extents across two transactions and with several fsyncs
in between. The goal is to check that the fsyncs succeed.

Currently the last fsync fails with an -EIO error, and it aborts the
current transaction. This issue is fixed by a patch with the following
subject:

  "btrfs: fix fsync failure and transaction abort after writes to prealloc extents"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-05-30 20:16:50 +08:00
Filipe Manana 33bcdb836a btrfs: test log replay after directory fsync and moving a child directory
Test a particular scenario where we fsync a directory, then move one of
its children directories into another directory and then finally sync the
log trees by fsyncing any other inode. We want to check that after a power
failure we are able to mount the filesystem and that the moved directory
exists only as a child of the directory we moved it into.

This currently fails on a 5.12 kernel (and 5.13-rc1) but is fixed by a
patch with the following subject:

  "btrfs: fix removed dentries still existing after log is synced"

The failure is due to ending up with a directory that has 2 hard links
(two parent directories) as soon as the log replay procedure finishes,
which causes the tree checker to detect the issue and cause the mount
operation to fail with -EIO.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-05-17 00:02:42 +08:00
Anand Jain fcd74c405b btrfs: add fstrim test case on the sprout device
Add fstrim test case on the sprout device, verify seed device
integrity. Targeting kernel commit 5e753a817b2d ("btrfs: fix
unmountable seed device after fstrim")

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-05-16 22:42:09 +08:00
Johannes Thumshirn 0a095db5ef 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>
2021-05-09 22:56:56 +08:00
Filipe Manana 05dc922771 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>
2021-05-09 21:59:17 +08:00
Filipe Manana 175bb55960 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>
2021-03-29 00:50:41 +08:00
Filipe Manana 4a2683ce3e btrfs: add test for cases when a dio write has to fallback to a buffered write
Test cases where a direct IO write, with O_DSYNC, can not be done and has
to fallback to a buffered write.

This is motivated by the fact we don't have existing tests for these cases
and in fact we had a regression for one case in the 5.10 kernel. This was
the case when doing a direct IO write, with O_DSYNC, against a file offset
that is not aligned to the filesystem's block size, which resulted in
triggering an assertion failure when btrfs is built with assertions enabled
(CONFIG_BTRFS_ASSERT=y). One openSUSE Tumbleweed user hit this frequently
when using Docker and DB2.

The kernel commit in 5.10 that introduced the regression was commit
0eb79294dbe328 ("btrfs: dio iomap DSYNC workaround")). In kernel 5.11 the
regression fixed, by pure chance, by commit ecfdc08b8cc65d ("btrfs: remove
dio iomap DSYNC workaround"). Since the commit that fixed the bug in 5.11
was dependent on a large patchset, a special and simple fix was added to
the stable kernel 5.10.18 by commit a6703c71153438 ("btrfs: fix crash after
non-aligned direct IO write with O_DSYNC").

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-03-18 01:40:01 +08:00
Filipe Manana 40f8dc416a btrfs: test delayed subvolume deletion on mount and remount
Test that subvolume deletion is resumed on RW mounts, that it is not
performed on RO mounts and that after remounting a filesystem from RO
to RW mode, it is also performed.

This triggers a regression introduced in kernel 5.11 which is fixed
by a patch that has the following subject:

   "btrfs: fix subvolume/snapshot deletion not triggered on mount"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-03-18 01:39:26 +08:00
Nikolay Borisov 52a3700b26 btrfs: Add simple stress test when qgroup limits are reached
This test uncovered 2 deadlocks with qgroups when their limit was
reached.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-03-08 01:15:27 +08:00
Filipe Manana bdad282d47 btrfs: clone a hole post eof when using NO_HOLES feature
Test that when using the NO_HOLES feature, if we truncate down a
file, clone a file range covering only a hole into an offset beyond
the current file size, and then fsync the file, after a power
failure we get the expected file content and we do not get stale
data corresponding to file extents that existed before truncating
the file.

This currently fails on btrfs and is fixed by commit 3660d0bcdb82
("btrfs: fix stale data exposure after cloning a hole with NO_HOLES
enabled")

[Eryu: add the commit id of the patch fixing the bug]

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-03-07 22:40:31 +08:00
Qu Wenruo 0e195a4ca9 btrfs: check qgroup doesn't crash when beyond limit
There is a bug that, when btrfs is beyond qgroup limit, touching a file
could crash btrfs.

Such beyond limit situation needs to be intentionally created, e.g.
writing 1GiB file, then limit the subvolume to 512 MiB.
As current qgroup works pretty well at preventing us from reaching the
limit.

This makes existing qgroup test cases unable to detect it.

The regression is introduced by commit c53e9653605d ("btrfs: qgroup:
try to flush qgroup space when we get -EDQUOT"), and the fix is
commit 6f23277a49e6 ("btrfs: qgroup: don't commit transaction when
we already hold the handle")

Link: https://bugzilla.suse.com/show_bug.cgi?id=1178634
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-01-17 23:11:16 +08:00
Filipe Manana c1537fc9f2 btrfs: test incremental send after cloning extents from the same file
Test that an incremental send operation correctly issues clone operations
for a file that had different parts of one of its extents cloned into
itself, at different offsets, and a large part of that extent was
overwritten, so all the reflinks only point to subranges of the extent.

This currently fails on btrfs but is fixed by a patch for the kernel that
has the following subject:

 "btrfs: send, fix invalid clone operations when cloning from the same file and root"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-01-17 22:14:36 +08:00
Nikolay Borisov 3334128e4f btrfs: test correct operation of free objectid related functionality
This test verifies btrfs' free objectid management. I.e it ensures that
the first objectid is always 256 in an fs tree.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-01-17 22:10:50 +08:00
Filipe Manana eabfcdfe90 btrfs: test incremental send after removing a directory and all its files
Test that an incremental send operation succeeds, and produces the
correct results, after removing a directory and all its files, unmounting
the filesystem, mounting the filesystem again and creating a new file (or
directory).

This currently fails on btrfs, but is fixed by a patch that has the
following subject:

  btrfs: send, fix wrong file path when there is an inode with a pending rmdir

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-12-21 00:18:43 +08:00
ethanwu 9f0744b169 btrfs: test if rename handles dir item collision correctly
This is a regression test for the issue fixed by the kernel commit titled
"btrfs: correctly calculate item size used when item key collision happens"

In this case, we'll simply rename many forged filename that cause collision
under a directory to see if rename failed and filesystem is forced readonly.

Signed-off-by: ethanwu <ethanwu@synology.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-12-21 00:18:43 +08:00
Filipe Manana a7fdd2e1b1 btrfs: add test case for rwf_nowait writes
Test several scenarios for RWF_NOWAIT writes, to verify we don't regress
on btrfs specific behaviour (snapshots, cow files, reflinks, holes,
prealloc extent beyond eof).

We had some bugs in the past related to RWF_NOWAIT writes not failing on
btrfs when they should or failing when they shouldn't, these were fixed by
the following kernel commits:

  4b1946284dd6 ("btrfs: fix failure of RWF_NOWAIT write into prealloc extent beyond eof")
  260a63395f90 ("btrfs: fix RWF_NOWAIT write not failling when we need to cow")

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-10-25 14:29:29 +08:00
Anand Jain 0cea5f97ef btrfs: add a test case for btrfs seed device delete
This is a regression test for the issue fixed by the kernel commit
b5ddcffa3777 (btrfs: fix put of uninitialized kobject after seed device
delete).

In this test case, we verify the seed device delete on a sprouted
filesystem.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-10-25 14:25:29 +08:00
Sidong Yang e82cfa7081 btrfs: Add new test for qgroup assign functionality
This new test will test btrfs's qgroup assign functionality. The
test has 3 cases.

 - assign, no shared extents
 - assign, shared extents
 - snapshot -i, shared extents

Each cases create subvolumes and assign qgroup in their own way
and check with the command "btrfs check".

Cc: Qu Wenruo <wqu@suse.com>
Cc: Eryu Guan <guan@eryu.me>
Signed-off-by: Sidong Yang <realwakka@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-10-18 19:10:48 +08:00
Filipe Manana 353bfccf5c btrfs: test fstrim after doing a device replace
Test that after replacing a device, if we run fstrim against the filesystem
we do not trim/discard allocated chunks in the new device. We verify that
allocated chunks in the new device were not trim/discarded by mounting the
new device only in degraded mode, as this is the easiest way to verify it.

This currently fails on btrfs (since kernel 5.2) and is fixed by a patch
that has the following subject:

  "btrfs: fix filesystem corruption after a device replace"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-09-27 17:44:38 +08:00
Johannes Thumshirn 6e723496c1 btrfs/125: remove constantly failing test from auto group
The test-case btrfs/125 is often failing due to a design deficiency in
btrfs' RAID5 code.

The details for this can be seen here:
https://lore.kernel.org/linux-btrfs/CAL3q7H4oa70DUhOFE7kot62KjxcbvvZKxu62VfLpAcmgsinBFw@mail.gmail.com/

Remove the test from the auto group until we have a replacement for the
current RAID5/6 code.

Cc: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-09-27 17:42:19 +08:00
Johannes Thumshirn 63aee278f7 btrfs: remove stale test for alien devices from auto group
btrfs/198 is supposed to be a test for the patch
"btrfs: remove identified alien device in open_fs_devices" but this patch
was never merged in btrfs.

Remove the test from fstests' auto group, as it is constantly failing.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-09-27 17:41:19 +08:00
Filipe Manana e240c4a965 btrfs: test incremental send after swapping same file with two directories
Test an incremental send operation after doing a series of changes in a
tree such that one inode gets two hardlinks with names and locations
swapped with two other inodes that correspond to different directories,
and one of these directories is the parent of the other directory.

This currently fails on btrfs, the receive of the incremental send stream
fails. This is fixed by a patchset for btrfs which has two patches with the
following subjects:

  "btrfs: send, orphanize first all conflicting inodes when processing references"
  "btrfs: send, recompute reference path after orphanization of a directory"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-09-27 17:35:26 +08:00
Filipe Manana 03abb09075 btrfs: test incremental send after a succession of rename and link operations
Test that an incremental send operation emits the correct path for link
and rename operation after swapping the names and locations of several
inodes in a way that creates a nasty dependency of rename and link
operations. Notably one file has its name and location swapped with a
directory for which it used to have a directory entry in it.

This test currently fails but a kernel patch for it exists and has the
following subject:

  "btrfs: send, orphanize first all conflicting inodes when processing references"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-09-27 17:35:08 +08:00
Marcos Paulo de Souza 85de6a5e53 btrfs: check if mount opts are applied
This new test will apply different mount points and check if they
were applied by reading /proc/self/mounts. Almost all available
btrfs options are tested here, leaving only device=, which is tested
in btrfs/125 and space_cache, tested in btrfs/131.

This test does not apply any workload after the fs is mounted, just
checks is the option was set/unset correctly.

Kernel with the following patch should pass the test:
  btrfs: reset compression level for lzo on remount

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-09-13 23:10:09 +08:00
Johannes Thumshirn 43fbe02d87 btrfs/154: remove test for fix that never landed
The btrfs/154 testcase fails if the kernel patch "btrfs: handle
dynamically reappearing missing device" isn't applied, but this patch was
never merged into the upstream kernel.

Delete the test so we have one less testcase that will always fail.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-09-13 23:07:34 +08:00