xfs
[Top] [All Lists]

Re: seeking advice on sparse files on xfs

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: seeking advice on sparse files on xfs
From: Joe Landman <joe.landman@xxxxxxxxx>
Date: Wed, 19 Dec 2012 22:06:56 -0500
Cc: "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=OKBVKo3Bbhb5a8sTIiBbHT7iAO5Cqnob8NWRHmBrQFA=; b=Usmu2m02S3FLr5MSrOXbq9sNetkFfkxsnrOuj8Wac1eLwDloy/qJVLPb8JOaFdXdam vUBdHIqbmDNOSIDDTMRmIoNrbIHWDefLV83LEUBcP0LAJNNqTl30Pxs/ptK7YYvfevxb QIIv0jUGeOViJcQPlV7+Z6A9ZAfv2srZ2pqHjhSvJ1MPoRQOLoq6O8GcVXuwU3hxyvMf oIYvpA5Kp4vQsCrKTkKVQDxix8GWaEkJrqZ8o5J77c0U3+3OcICSkKXXkoVO+ZNNZ2qV 0C9KcJwk8Aze2hd1jow1jd9mK4PEmrQl9O5rOxWALktMg6gexDXmf+7b6FLWFbgvhGLv cnUA==
In-reply-to: <20121220030034.GR15182@dastard>
References: <50D23D09.3080708@xxxxxxxxx> <20121219225406.GO15182@dastard> <50D26A52.8030700@xxxxxxxxx> <20121220030034.GR15182@dastard>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0
On 12/19/2012 10:00 PM, Dave Chinner wrote:

[...]

I git cloned the coreutils to look at current state of the code, and
saw exactly what is represented on slide 14.

"Brute force – read each sector in full, before
skipping while writing the copy"

http://code.metager.de/source/xref/coreutils/src/extent-scan.c

It uses FIEMAP.

Indeed, take a 1TB sparse file (empty) and copy it:

$ cp --version
cp (GNU coreutils) 8.13
$ ls -lh blah
-rw-r--r-- 1 root root 1.0T Nov 30 06:42 blah
$ xfs_bmap -v blah
blah: no extents
$ strace cp --sparse=always blah fred
.....
stat("fred", 0x7fff98d7ded0)            = -1 ENOENT (No such file or directory)
stat("blah", {st_mode=S_IFREG|0600, st_size=1099511627776, ...}) = 0
stat("fred", 0x7fff98d7dc50)            = -1 ENOENT (No such file or directory)
open("blah", O_RDONLY)                  = 3
fstat(3, {st_mode=S_IFREG|0600, st_size=1099511627776, ...}) = 0
open("fred", O_WRONLY|O_CREAT|O_EXCL, 0600) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
ioctl(3, FS_IOC_FIEMAP, 0x7fff98d7c9d0) = 0
ftruncate(4, 1099511627776)             = 0
close(4)                                = 0
close(3)                                = 0
...
$ xfs_bmap -v fred
fred: no extents
$

Looks like cp already does what you want - it didn't copy a TB Of
zeros..... ;)

I have much older coreutils by default on CentOS 6.x. Will recheck this with newer version, and pull down the extent-scan. My strace had lots of zeros ...


And what you really want is a version of cp that supports these:


[...]

Was thinking of hacking something up at a much higher level
(cheating by parsing bmap data and stuff like that).

Don't. You'll only get it wrong, just like the initial attempts to
use FIEMAP in cp did. There's a reason coreutils is moving to
SEEK_HOLE/SEEK_DATA instead of FIEMAP for efficient sparse file
handling....

Thanks.  This isn't what I wanted to do if I could avoid it.


Cheers,

Dave.



--
Joe

<Prev in Thread] Current Thread [Next in Thread>