Debian Bug report logs -
#561225
coreutils: cp --reflink fails with Btrfs file system
Reported by: Jason White <jason@jasonjgw.net>
Date: Tue, 15 Dec 2009 10:33:01 UTC
Severity: normal
Found in version coreutils/8.0-2
Done: Michael Stone <mstone@debian.org>
Bug is archived. No further changes may be made.
Toggle useless messages
Report forwarded
to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#561225; Package coreutils.
(Tue, 15 Dec 2009 10:33:04 GMT) (full text, mbox, link).
Acknowledgement sent
to Jason White <jason@jasonjgw.net>:
New Bug report received and forwarded. Copy sent to Michael Stone <mstone@debian.org>.
(Tue, 15 Dec 2009 10:33:04 GMT) (full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: coreutils
Version: 8.0-2
Severity: normal
jason@vrtl:~$ touch testfile
jason@vrtl:~$ cp --reflink testfile testfile2
cp: failed to clone `testfile2': Invalid argument
I am running kernel 2.6.32 with a Btrfs root file system under KVM, x86-64
architecture.
It was suggested on the Btrfs mailing list that I test file cloning by running
the bcp demonstration script provided as part of btrfs-progs (available from
a Btrfs Git repository). In my test, bcp was able to clone a file,
suggesting that this may be a Coreutils bug rather than a kernel issue.
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (990, 'unstable'), (800, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages coreutils depends on:
ii libacl1 2.2.49-1 Access control list shared library
ii libattr1 1:2.4.44-1 Extended attribute shared library
ii libc6 2.10.2-2 GNU C Library: Shared libraries
ii libselinux1 2.0.89-4 SELinux runtime shared libraries
coreutils recommends no packages.
coreutils suggests no packages.
-- no debconf information
Information forwarded
to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#561225; Package coreutils.
(Tue, 15 Dec 2009 13:12:04 GMT) (full text, mbox, link).
Acknowledgement sent
to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>.
(Tue, 15 Dec 2009 13:12:04 GMT) (full text, mbox, link).
Message #10 received at 561225@bugs.debian.org (full text, mbox, reply):
Jason White wrote:
> Package: coreutils
> Version: 8.0-2
>
> jason@vrtl:~$ touch testfile
> jason@vrtl:~$ cp --reflink testfile testfile2
> cp: failed to clone `testfile2': Invalid argument
>
> I am running kernel 2.6.32 with a Btrfs root file system under KVM, x86-64
> architecture.
>
> It was suggested on the Btrfs mailing list that I test file cloning by running
> the bcp demonstration script provided as part of btrfs-progs (available from
> a Btrfs Git repository). In my test, bcp was able to clone a file,
> suggesting that this may be a Coreutils bug rather than a kernel issue.
Thanks for the report.
Can you rerun that via strace and send the log at least
to the bug-coreutils list (Cc'd)?
strace -o log cp --reflink testfile testfile2
Even better, can you do that using stock upstream coreutils-8.2,
assuming it still fails?
ftp://ftp.gnu.org/gnu/coreutils/coreutils-8.2.tar.xz
ftp://ftp.gnu.org/gnu/coreutils/coreutils-8.2.tar.gz
Information forwarded
to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#561225; Package coreutils.
(Tue, 15 Dec 2009 13:36:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Pádraig Brady <P@draigBrady.com>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>.
(Tue, 15 Dec 2009 13:36:03 GMT) (full text, mbox, link).
Message #15 received at 561225@bugs.debian.org (full text, mbox, reply):
On 15/12/09 13:00, Jim Meyering wrote:
> Jason White wrote:
>> Package: coreutils
>> Version: 8.0-2
>>
>> jason@vrtl:~$ touch testfile
>> jason@vrtl:~$ cp --reflink testfile testfile2
>> cp: failed to clone `testfile2': Invalid argument
>>
>> I am running kernel 2.6.32 with a Btrfs root file system under KVM, x86-64
>> architecture.
>>
>> It was suggested on the Btrfs mailing list that I test file cloning by running
>> the bcp demonstration script provided as part of btrfs-progs (available from
>> a Btrfs Git repository). In my test, bcp was able to clone a file,
>> suggesting that this may be a Coreutils bug rather than a kernel issue.
Note the bcp python script silently falls back to a standard copy,
so may be hiding the issue. Note you can get that behaviour with cp like:
cp --reflink=auto testfile testfile2
cheers,
Pádraig.
Information forwarded
to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#561225; Package coreutils.
(Tue, 15 Dec 2009 23:24:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Jason White <jason@jasonjgw.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>.
(Tue, 15 Dec 2009 23:24:03 GMT) (full text, mbox, link).
Message #20 received at 561225@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
Jim Meyering <jim@meyering.net> wrote:
> Can you rerun that via strace and send the log at least
> to the bug-coreutils list (Cc'd)?
>
> strace -o log cp --reflink testfile testfile2
It opens both files and then performs the ioctl() call:
ioctl(4, 0x40049409, 0x3) = -1 EINVAL (Invalid argument)
>
> Even better, can you do that using stock upstream coreutils-8.2,
> assuming it still fails?
This may not be necessary. If I run strace on bcp, it turns out that its
ioctl() call encounters the same error:
ioctl(3, 0x40049409, 0x4) = -1 EINVAL (Invalid argument)
and thus the suggestion that bcp (by behaving like --reflink=auto) is masking
the issue appears to be exactly on point.
[cp.log (text/plain, attachment)]
Information forwarded
to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#561225; Package coreutils.
(Tue, 15 Dec 2009 23:39:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Jason White <jason@jasonjgw.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>.
(Tue, 15 Dec 2009 23:39:03 GMT) (full text, mbox, link).
Message #25 received at 561225@bugs.debian.org (full text, mbox, reply):
Josef Bacik <josef@redhat.com> wrote:
>On Sun, Dec 13, 2009 at 12:29:03AM +0000, Jason White wrote:
>> I am testing a Btrfs root file system with Debian (kernel 2.6.32) under KVM.
>>
>> jason@vrtl:~$ touch testfile
>> jason@vrtl:~$ cp --reflink testfile /tmp
>> cp: failed to clone `/tmp/testfile': Invalid argument
>>
>> This is with GNU Coreutils 8.0 taken from debian Sid.
>>
>> Is this a Coreutils issue, a Btrfs problem or something in my local
>> configuration?
>>
>
>Try using bcp, if that works then its likely a problem with coreutils.
After reporting this to Debian and engaging on follow-up discussion, it turns
out that bcp copies the data if the ioctl() call to clone the file fails, as
can be seen from the Python code (which I should have read, but didn't...).
Unfortunately the ioctl() call is failing both in bcp and in cp --reflink.
Here's partial strace output from the latter.
cp --reflink testfile testfile2
open("testfile", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
open("testfile2", O_WRONLY|O_CREAT|O_EXCL, 0644) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
ioctl(4, 0x40049409, 0x3) = -1 EINVAL (Invalid argument)
Kernel 2.6.32 (debian Sid), x86-64 architecture.
Suggestions welcome.
Debian bug report:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=561225
Information forwarded
to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#561225; Package coreutils.
(Wed, 16 Dec 2009 08:48:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>.
(Wed, 16 Dec 2009 08:48:03 GMT) (full text, mbox, link).
Message #30 received at 561225@bugs.debian.org (full text, mbox, reply):
Jason White wrote:
> Jim Meyering <jim@meyering.net> wrote:
>> Can you rerun that via strace and send the log at least
>> to the bug-coreutils list (Cc'd)?
>>
>> strace -o log cp --reflink testfile testfile2
>
> It opens both files and then performs the ioctl() call:
> ioctl(4, 0x40049409, 0x3) = -1 EINVAL (Invalid argument)
>
>> Even better, can you do that using stock upstream coreutils-8.2,
>> assuming it still fails?
>
> This may not be necessary. If I run strace on bcp, it turns out that its
> ioctl() call encounters the same error:
>
> ioctl(3, 0x40049409, 0x4) = -1 EINVAL (Invalid argument)
> and thus the suggestion that bcp (by behaving like --reflink=auto) is masking
> the issue appears to be exactly on point.
Good to know it's not a problem with cp.
Thanks!
Information forwarded
to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#561225; Package coreutils.
(Wed, 16 Dec 2009 23:12:08 GMT) (full text, mbox, link).
Acknowledgement sent
to Jason White <jason@jasonjgw.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>.
(Wed, 16 Dec 2009 23:12:08 GMT) (full text, mbox, link).
Message #35 received at 561225@bugs.debian.org (full text, mbox, reply):
From discussion on the Btrfs list, the reason for this behaviour is that, if
the file is empty (thus containing no data extents) the ioctl() call returns
EINVAL.
It has been suggested on the Btrfs list that it should return success instead,
so that the caller doesn't have to check for the empty file case.
The problem originally arose for me when I attempted cp -r --reflink directory
/tmp/destination
where directory contained what turned out, on inspection, to be empty files (I
didn't realize these were all empty files - it was a source code tree from a
project I downloaded.)
Reply sent
to Michael Stone <mstone@debian.org>:
You have taken responsibility.
(Sat, 16 Jan 2010 20:00:07 GMT) (full text, mbox, link).
Notification sent
to Jason White <jason@jasonjgw.net>:
Bug acknowledged by developer.
(Sat, 16 Jan 2010 20:00:07 GMT) (full text, mbox, link).
Message #40 received at 561225-close@bugs.debian.org (full text, mbox, reply):
It seems as though this isn't a coreutils bug, closing.
Mike Stone
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Sun, 14 Feb 2010 07:29:27 GMT) (full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Fri Jul 24 07:29:36 2020;
Machine Name:
buxtehude
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.