coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

'cp -a' does not preserve nocow xattrs on btrfs


From: A L
Subject: 'cp -a' does not preserve nocow xattrs on btrfs
Date: Sat, 16 May 2020 13:31:50 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

Hi,

Normally, 'cp -a' should preserve xattrs when copying files and folders.

From the man page(*):
-a, --archive
              same as -dR --preserve=all
--preserve[=ATTR_LIST]
              preserve  the  specified  attributes  (default: mode,ownership,timestamps),  if  possible  additional
              attributes: context, links, xattr, all


There are two important xattrs(*) on the Btrfs filesystem; 'no copy-on-writes' ('+C') and 'compression' (+c). They have specific conditions to work.

The nocow '+C' attribute can only be set on empty files.
The compression '+c' can be set on any file, but only newly written data will be compressed.

The problem is that 'cp -a' seems to set the xattrs after creating the file and writing the data to it, which means that the nocow '+C' flags can't be set and that files would not be fully compressed, even though the flag is set.

I think that these xattrs should be preserved when doing 'cp -a'.



* http://man7.org/linux/man-pages/man1/cp.1.html
* http://man7.org/linux/man-pages/man1/chattr.1.html





reply via email to

[Prev in Thread] Current Thread [Next in Thread]