btrfs: Check snapshot creation and deletion with dm-logwrites
authorQu Wenruo <wqu@suse.com>
Tue, 10 Sep 2019 01:53:11 +0000 (09:53 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 15 Sep 2019 04:23:53 +0000 (12:23 +0800)
commitd0f42706da5094df08bae3cba03c50a79c9d8cfc
tree8578abe7e113f6fd17626f0edf8de1d7b844ec69
parent4f7f6f1cf1b206ab17197e38eb0d732e3f2f43eb
btrfs: Check snapshot creation and deletion with dm-logwrites

We have generic dm-logwrites with fsstress test case (generic/482),
but it doesn't cover fs specific operations like btrfs snapshot
creation and deletion.

Furthermore, that test is not heavy enough to bump btrfs tree height
by its short runtime.

And finally, btrfs check doesn't consider dirty log as an error,
unlike ext*/xfs, that's to say we don't need to mount the fs to
replay the log, but just running btrfs check on the fs is enough.

So introduce a similar test case but for btrfs only.

The test case will stress btrfs by:
- Use small nodesize to bump tree height
- Create a base tree which is already high enough
- Trim tree blocks to find possible trim bugs
- Call snapshot creation and deletion along with fsstress

Also it includes certain workaround for btrfs:
- Allow _log_writes_mkfs to accept extra mkfs options
- Use no-holes feature
  To avoid missing hole file extents.
  Although that behavior doesn't follow the on-disk format spec, it
  doesn't cause data loss. And will follow the new on-disk format spec
  of no-holes feature, so it's better to workaround it.

And an optimization for btrfs only:
- Use replay-log --fsck/--check command
  Since dm-log-writes records bios sequentially, there is no way to
  locate certain entry unless we iterate all entries.
  This is becoming a big performance penalty if we replay certain a
  range, check the fs, then re-execute replay-log to replay another
  range.

  We need to records the previous entry location, or we need to
  re-iterate all previous entries.

  Thankfully, replay-log has already address it by providing --fsck and
  --check command, thus we don't need to break replay-log command.

Please note, for fast storage (e.g. fast NVME or unsafe cache mode),
it's recommended to use log devices larger than 15G, or we can't
record the full log of just 30s fsstress run.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/config
common/dmlogwrites
tests/btrfs/192 [new file with mode: 0755]
tests/btrfs/192.out [new file with mode: 0644]
tests/btrfs/group