All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fstests: btrfs: test setting compression via xattr on nodatacow files
@ 2022-04-18  7:54 Chung-Chiang Cheng
  2022-04-19 12:47 ` Nikolay Borisov
  2022-04-19 14:52 ` Filipe Manana
  0 siblings, 2 replies; 7+ messages in thread
From: Chung-Chiang Cheng @ 2022-04-18  7:54 UTC (permalink / raw)
  To: fstests, linux-btrfs, nborisov, fdmanana, dsterba
  Cc: shepjeng, kernel, Chung-Chiang Cheng

Compression and nodatacow are mutually exclusive. Besides ioctl, there
is another way to setting compression via xattrs, and shouldn't produce
invalid combinations.

Signed-off-by: Chung-Chiang Cheng <cccheng@synology.com>
---
 tests/btrfs/264     | 76 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/264.out | 15 +++++++++
 2 files changed, 91 insertions(+)
 create mode 100755 tests/btrfs/264
 create mode 100644 tests/btrfs/264.out

diff --git a/tests/btrfs/264 b/tests/btrfs/264
new file mode 100755
index 000000000000..42bfcd4f93a0
--- /dev/null
+++ b/tests/btrfs/264
@@ -0,0 +1,76 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Synology Inc. All Rights Reserved.
+#
+# FS QA Test No. 264
+#
+# Compression and nodatacow are mutually exclusive. Besides ioctl, there
+# is another way to setting compression via xattrs, and shouldn't produce
+# invalid combinations.
+#
+# To prevent mix any compression-related options with nodatacow, FS_NOCOMP_FL
+# is also rejected by ioctl as well as FS_COMPR_FL on nodatacow files. To
+# align with it, no and none are also unacceptable in this test.
+#
+# The regression is fixed by a patch with the following subject:
+#   btrfs: do not allow compression on nodatacow files
+#
+. ./common/preamble
+_begin_fstest auto quick compress attr
+
+# Import common functions.
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+
+_supported_fs btrfs
+_require_scratch
+_require_chattr C
+_require_chattr c
+
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
+#
+# DATACOW
+#
+test_file="$SCRATCH_MNT/foo"
+touch "$test_file"
+$CHATTR_PROG -C "$test_file"
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+
+$SETFATTR_PROG -n "btrfs.compression" -v zlib "$test_file" |& _filter_scratch
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+$SETFATTR_PROG -n "btrfs.compression" -v no   "$test_file" |& _filter_scratch
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+$SETFATTR_PROG -n "btrfs.compression" -v lzo  "$test_file" |& _filter_scratch
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+$SETFATTR_PROG -n "btrfs.compression" -v none "$test_file" |& _filter_scratch
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+$SETFATTR_PROG -n "btrfs.compression" -v zstd "$test_file" |& _filter_scratch
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+
+
+#
+# NODATACOW
+#
+test_file="$SCRATCH_MNT/bar"
+touch "$test_file"
+$CHATTR_PROG +C "$test_file"
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+
+# all valid compression type are not allowed on nodatacow files
+$SETFATTR_PROG -n "btrfs.compression" -v zlib "$test_file" |& _filter_scratch
+$SETFATTR_PROG -n "btrfs.compression" -v lzo  "$test_file" |& _filter_scratch
+$SETFATTR_PROG -n "btrfs.compression" -v zstd "$test_file" |& _filter_scratch
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+
+# no/none are also not allowed on nodatacow files
+$SETFATTR_PROG -n "btrfs.compression" -v no   "$test_file" |& _filter_scratch
+$SETFATTR_PROG -n "btrfs.compression" -v none "$test_file" |& _filter_scratch
+$LSATTR_PROG -l "$test_file" | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/264.out b/tests/btrfs/264.out
new file mode 100644
index 000000000000..82c551411411
--- /dev/null
+++ b/tests/btrfs/264.out
@@ -0,0 +1,15 @@
+QA output created by 264
+SCRATCH_MNT/foo ---
+SCRATCH_MNT/foo Compression_Requested
+SCRATCH_MNT/foo ---
+SCRATCH_MNT/foo Compression_Requested
+SCRATCH_MNT/foo ---
+SCRATCH_MNT/foo Compression_Requested
+SCRATCH_MNT/bar No_COW
+setfattr: SCRATCH_MNT/bar: Invalid argument
+setfattr: SCRATCH_MNT/bar: Invalid argument
+setfattr: SCRATCH_MNT/bar: Invalid argument
+SCRATCH_MNT/bar No_COW
+setfattr: SCRATCH_MNT/bar: Invalid argument
+setfattr: SCRATCH_MNT/bar: Invalid argument
+SCRATCH_MNT/bar No_COW
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-22 14:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-18  7:54 [PATCH] fstests: btrfs: test setting compression via xattr on nodatacow files Chung-Chiang Cheng
2022-04-19 12:47 ` Nikolay Borisov
2022-04-19 13:01   ` Nikolay Borisov
2022-04-22 11:30   ` Chung-Chiang Cheng
2022-04-19 14:52 ` Filipe Manana
2022-04-22 11:11   ` Chung-Chiang Cheng
2022-04-22 14:31     ` Filipe Manana

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.