summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2026-11-02 18:55:35 +0000
committerDavid Sterba <dsterba@suse.com>2026-11-23 18:29:43 +0100
commit356217202a30e58b02c49c1027874a13e011c822 (patch)
treea6081eba7db39175e5cc5fe15302d722f954305a /tools/perf/scripts/python
parent5588a3dd3c651824507ff57522718ea53360d1df (diff)
btrfs: don't propagate nodatacow mount option on files with inherited compression
If we set the compression property on a directory and the filesystem was mounted with the nodatacow option, then when creating a file under that directory we get both the compression and nodatacow attributes set on the file. These are incompatible attributes as compression requires COW. This has a couple unexpected behaviours: 1) If later a user sets another attribute on the file, like immutability or append writing mode for example, the chattr command will fail with -EINVAL since we in the setattr callback (btrfs_fileattr_set()) we do some validation, through a call to check_fsflags(), that rejects having both the nodatacow and compression flags set. I.e, doing a simple: $ chattr +i file /usr/bin/chattr: Invalid argument while setting flags on file 2) The file ends up not being compressed, which is unexpected since the compression attribute set on a directory/file should have precedence over the global nodatacow mount option. Example reproducer: $ cat test.sh #!/bin/bash DEV=/dev/sdi MNT=/mnt/sdi mkfs.btrfs -f $DEV mount -o nodatacow $DEV $MNT # Create a directory with the compression attribute, so that all files # created under it inherit the compression attribute. mkdir $MNT/dir chattr +c $MNT/dir # Now create a file with some data inside the directory. xfs_io -f -c "pwrite 0 128K" $MNT/dir/foo # Now try to make the file immutable, it should work. chattr +i $MNT/dir/foo umount $MNT # Check the file has a compressed extent. It should have since # despite the fs being mounted with nodatacow, the directory has # the compression flag set and so that should take priority and # it's what makes sense. btrfs inspect-internal dump-tree -t 5 $DEV | grep -A 5 'EXTENT_DATA 0' Running it: $ ./test.sh (...) chattr: Invalid argument while setting flags on /mnt/sdi/dir/foo item 11 key (258 EXTENT_DATA 0) itemoff 15529 itemsize 53 generation 9 type 1 (regular) extent data disk byte 13631488 nr 131072 extent data offset 0 nr 131072 ram 131072 extent compression 0 (none) extent encryption 0 Fix this by updating btrfs_create_new_inode() to not apply the mount options nodatacow and nodatasum on a file that has inherited compression from its parent directory. A test case will follow soon for fstests. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions