On Sun, Jan 17, 2021 at 2:07 PM Damian Höster <damian.hoes...@posteo.de> wrote: > > The nodatacow mount option seems to have no effect when mounting a > subvolume into the same filesystem. > > I did some testing: > > sudo mount -o compress=zstd /dev/sda /mnt -> compression enabled > sudo mount -o compress=zstd,nodatacow /dev/sda /mnt -> compression disabled > sudo mount -o nodatacow,compress=zstd /dev/sda /mnt -> compression enabled > All as I would expect, setting compress or nodatacow disables the other. > > Compression gets enabled without problems when mounting a subvolume into > the same filesystem: > sudo mount /dev/sda /mnt; sudo mount -o subvol=@test,compress=zstd > /dev/sda /mnt/test -> compression enabled > sudo mount /dev/sda /mnt; sudo mount -o subvol=@/testsub,compress=zstd > /dev/sda /mnt/testsub -> compression enabled > > But nodatacow apparently doesn't: > sudo mount -o compress=zstd /dev/sda /mnt; sudo mount -o > subvol=@test,nodatacow /dev/sda /mnt/test -> compression enabled > sudo mount -o compress=zstd /dev/sda /mnt; sudo mount -o > subvol=@/testsub,nodatacow /dev/sda /mnt/testsub -> compression enabled > > And I don't think it's because of the compress mount option, some > benchmarks I did indicate that nodatacow never gets set when mounting a > subvolume into the same filesystem. >
Most btrfs mount options are file system wide, they're not per subvolume options. In case of conflict, the most recent option is what's used. i.e. the mount options have an order and are followed in order, with the latest one having precedence in a conflict: compress,nodatacow means nodatacow nodatacow,compress means compress nodatacow implies nodatasum and no compress. If you want per subvolume options then you need to use 'chattr +C' per subvolume or directory for nodatacow. And for compression you can use +c (small c) which implies zlib, or use 'btrfs property set /path/to/sub-dir-file compression zstd' -- Chris Murphy