]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
btrfs/173: make the test work when mounting with nodatacow
authorFilipe Manana <fdmanana@suse.com>
Thu, 1 Feb 2024 18:03:48 +0000 (18:03 +0000)
committerZorro Lang <zlang@kernel.org>
Fri, 1 Mar 2024 11:24:16 +0000 (19:24 +0800)
Currently btrfs/173 fails when passing "-o nodatacow" to MOUNT_OPTIONS
because it assumes that when creating a file it does not have the
nodatacow flag set, which is obviously not true if the fs is mounted with
"-o nodatacow". To allow the test to run successfully with nodatacow,
just make sure it clears the nodatacow flag from the file if the fs was
mounted with "-o nodatacow".

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/173

index 6e78a826478c35ef0ce50dae3fcbfa1cfbb8d43d..42af2d2663e81d332f55ac936f5dd35b6c73f1c2 100755 (executable)
@@ -23,6 +23,11 @@ echo "COW file"
 # unset it after the swap file has been created.
 rm -f "$SCRATCH_MNT/swap"
 touch "$SCRATCH_MNT/swap"
+# Make sure we have a COW file if we were mounted with "-o nodatacow".
+if _normalize_mount_options "$MOUNT_OPTIONS" | grep -q "nodatacow"; then
+       _require_chattr C
+       $CHATTR_PROG -C "$SCRATCH_MNT/swap"
+fi
 chmod 0600 "$SCRATCH_MNT/swap"
 _pwrite_byte 0x61 0 $(($(_get_page_size) * 10)) "$SCRATCH_MNT/swap" >> $seqres.full
 $MKSWAP_PROG "$SCRATCH_MNT/swap" >> $seqres.full