GNU bug report logs - #48833
reflink copying does not check/set No_COW attribute and fail

Previous Next

Package: coreutils;

Reported by: Tom Yan <tom.ty89 <at> gmail.com>

Date: Fri, 4 Jun 2021 14:38:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Tom Yan <tom.ty89 <at> gmail.com>
To: linux-btrfs <at> vger.kernel.org
Cc: 48833 <at> debbugs.gnu.org
Subject: bug#48833: reflink copying does not check/set No_COW attribute and fail
Date: Fri, 4 Jun 2021 22:37:35 +0800
Also cc'ing bug-coreutils <at> gnu.org.

On Fri, 4 Jun 2021 at 22:33, Tom Yan <tom.ty89 <at> gmail.com> wrote:
>
> 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 <at> 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 <at> archlinux mnt]$ lsattr
> ---------------------- ./a
> ---------------C------ ./b
> [tom <at> archlinux mnt]$ lsattr b/
> ---------------C------ b/test
> [tom <at> archlinux mnt]$ du -h b/test
> 512M    b/test
> [tom <at> archlinux mnt]$ lsattr a/
> [tom <at> archlinux mnt]$ cp --reflink=always b/test a/
> cp: failed to clone 'a/test' from 'b/test': Invalid argument
> [tom <at> archlinux mnt]$ lsattr a/
> ---------------------- a/test
> [tom <at> archlinux mnt]$ du a/test
> 0    a/test
> [tom <at> archlinux mnt]$ du --apparent-size a/test
> 0    a/test
> [tom <at> archlinux mnt]$ rm a/test
> [tom <at> archlinux mnt]$ sudo chattr +C a/
> [tom <at> archlinux mnt]$ cp --reflink=always b/test a/
> [tom <at> archlinux mnt]$ lsattr a/
> ---------------C------ a/test
> [tom <at> archlinux mnt]$ cmp b/test a/test
> [tom <at> 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




This bug report was last modified 2 years and 263 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.