All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* reflink copying does not check/set No_COW attribute and fail
@ 2021-06-04 14:33 Tom Yan
  2021-06-04 14:37 ` Tom Yan
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Yan @ 2021-06-04 14:33 UTC (permalink / raw)
  To: linux-btrfs

Hi all,

I've just bumped into a problem that I am not sure what the expected
behavior should be, but there seems to be something flawed.

Say I have a file that was created with the No_COW attributed
(inherited from the directory / subvolume / mount option). Then if I
try to do a reflink copy, the copying will fail with "Invalid
argument" if the copy has no one to inherit the No_COW attribute from.

For example:
[tom@archlinux mnt]$ sudo btrfs subvol list .
ID 256 gen 11 top level 5 path a
ID 257 gen 9 top level 5 path b
[tom@archlinux mnt]$ lsattr
---------------------- ./a
---------------C------ ./b
[tom@archlinux mnt]$ lsattr b/
---------------C------ b/test
[tom@archlinux mnt]$ du -h b/test
512M    b/test
[tom@archlinux mnt]$ lsattr a/
[tom@archlinux mnt]$ cp --reflink=always b/test a/
cp: failed to clone 'a/test' from 'b/test': Invalid argument
[tom@archlinux mnt]$ lsattr a/
---------------------- a/test
[tom@archlinux mnt]$ du a/test
0    a/test
[tom@archlinux mnt]$ du --apparent-size a/test
0    a/test
[tom@archlinux mnt]$ rm a/test
[tom@archlinux mnt]$ sudo chattr +C a/
[tom@archlinux mnt]$ cp --reflink=always b/test a/
[tom@archlinux mnt]$ lsattr a/
---------------C------ a/test
[tom@archlinux mnt]$ cmp b/test a/test
[tom@archlinux mnt]$

I'm not entirely sure if a reflink copy is supposed to work for a
source file that was created with No_COW, but apparently it is. The
problem is just that the reflink copy also needs to have the attribute
set, yet it cannot inherit from the source automatically.

I wonder if this is a kernel-side problem or something that coreutils
missed? It also seems wrong that when it fails there will be an empty
destination file created.

Kernel version: Linux archlinux 5.12.8-arch1-1 #1 SMP PREEMPT Fri, 28
May 2021 15:10:20 +0000 x86_64 GNU/Linux
Coreutils version: 8.32

Regards,
Tom

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

end of thread, other threads:[~2021-06-27 10:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04 14:33 reflink copying does not check/set No_COW attribute and fail Tom Yan
2021-06-04 14:37 ` Tom Yan
2021-06-04 20:16   ` Zygo Blaxell
2021-06-05  5:56     ` Tom Yan
2021-06-05 10:35       ` Forza
2021-06-06  5:42       ` Zygo Blaxell
2021-06-07  5:47         ` bug#48833: " Paul Eggert
2021-06-08  2:41           ` Zygo Blaxell
2021-06-27 10:56             ` A L

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.