* check for reflink capability and for shared data
@ 2013-08-24 16:09 Thomas Koch
2013-08-24 16:20 ` Hugo Mills
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Thomas Koch @ 2013-08-24 16:09 UTC (permalink / raw)
To: linux-btrfs
Hi,
how can I do the following in a shell script:
- check whether my file system supports cp --reflink?
- check whether two files share the same data on disk, i.e. one has been
created by cp --reflink of the other?
Thank you!
Thomas Koch
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: check for reflink capability and for shared data
2013-08-24 16:09 check for reflink capability and for shared data Thomas Koch
@ 2013-08-24 16:20 ` Hugo Mills
2013-08-26 6:42 ` Jan Schmidt
2013-08-26 9:30 ` Liu Bo
2013-08-27 1:37 ` Marios Titas
2 siblings, 1 reply; 5+ messages in thread
From: Hugo Mills @ 2013-08-24 16:20 UTC (permalink / raw)
To: Thomas Koch; +Cc: linux-btrfs
[-- Attachment #1: Type: text/plain, Size: 810 bytes --]
On Sat, Aug 24, 2013 at 06:09:58PM +0200, Thomas Koch wrote:
> Hi,
>
> how can I do the following in a shell script:
>
> - check whether my file system supports cp --reflink?
touch foo; if cp --reflink=always foo bar; then ...; fi; rm -f foo bar
> - check whether two files share the same data on disk, i.e. one has been
> created by cp --reflink of the other?
You can't, using simple userspace tools. I think the only way would
be to use the tree search ioctl to inspect the extents for each file,
and see whether any of them overlap. Why do you need to know this?
Hugo.
--
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- Someone's been throwing dead sheep down my Fun Well ---
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: check for reflink capability and for shared data
2013-08-24 16:20 ` Hugo Mills
@ 2013-08-26 6:42 ` Jan Schmidt
0 siblings, 0 replies; 5+ messages in thread
From: Jan Schmidt @ 2013-08-26 6:42 UTC (permalink / raw)
To: Thomas Koch; +Cc: Hugo Mills, linux-btrfs
On Sat, August 24, 2013 at 18:20 (+0200), Hugo Mills wrote:
> On Sat, Aug 24, 2013 at 06:09:58PM +0200, Thomas Koch wrote:
>> Hi,
>>
>> how can I do the following in a shell script:
>>
>> - check whether my file system supports cp --reflink?
>
> touch foo; if cp --reflink=always foo bar; then ...; fi; rm -f foo bar
>
>> - check whether two files share the same data on disk, i.e. one has been
>> created by cp --reflink of the other?
>
> You can't, using simple userspace tools. I think the only way would
> be to use the tree search ioctl to inspect the extents for each file,
> and see whether any of them overlap. Why do you need to know this?
It should work with fiemap to a file in question and btrfs inspect logical to
what ever extents fiemap reported as "physical".
-Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: check for reflink capability and for shared data
2013-08-24 16:09 check for reflink capability and for shared data Thomas Koch
2013-08-24 16:20 ` Hugo Mills
@ 2013-08-26 9:30 ` Liu Bo
2013-08-27 1:37 ` Marios Titas
2 siblings, 0 replies; 5+ messages in thread
From: Liu Bo @ 2013-08-26 9:30 UTC (permalink / raw)
To: Thomas Koch; +Cc: linux-btrfs
On Sat, Aug 24, 2013 at 06:09:58PM +0200, Thomas Koch wrote:
> Hi,
>
> how can I do the following in a shell script:
>
> - check whether my file system supports cp --reflink?
> - check whether two files share the same data on disk, i.e. one has been
> created by cp --reflink of the other?
Someone has proposed to teach 'du(1)' to show this, ie. 'du --shared'[1].
It's written for ocfs2 originally, besides btrfs, ocfs2 also can share
data between two files.
[1]: https://oss.oracle.com/pipermail/ocfs2-devel/2010-September/007287.html
-liubo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: check for reflink capability and for shared data
2013-08-24 16:09 check for reflink capability and for shared data Thomas Koch
2013-08-24 16:20 ` Hugo Mills
2013-08-26 9:30 ` Liu Bo
@ 2013-08-27 1:37 ` Marios Titas
2 siblings, 0 replies; 5+ messages in thread
From: Marios Titas @ 2013-08-27 1:37 UTC (permalink / raw)
To: btrfs
On Sat, Aug 24, 2013 at 12:09 PM, Thomas Koch <thomas@koch.ro> wrote:
> - check whether two files share the same data on disk, i.e. one has been
> created by cp --reflink of the other?
How about inspecting the output of filefrag -v $filename?
For example, you could filter out with grep all lines except the ones
that contain information about the extents.
Then you could hash the lines left and use that single hash to compare
the two files.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-27 1:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-24 16:09 check for reflink capability and for shared data Thomas Koch
2013-08-24 16:20 ` Hugo Mills
2013-08-26 6:42 ` Jan Schmidt
2013-08-26 9:30 ` Liu Bo
2013-08-27 1:37 ` Marios Titas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).