All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
To: Stef Bon <stefbon@gmail.com>
Cc: Chris Murphy <lists@colorremedies.com>,
	Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Subject: Re: Get the diff from a file in two snapshots.
Date: Tue, 27 Jan 2015 22:46:38 -0500	[thread overview]
Message-ID: <20150128034636.GA13452@hungrycats.org> (raw)
In-Reply-To: <CANXojcxps7KPRC2dbfU7hFvUDzkK2CmT4EroDrO6HO56h7j3cg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2168 bytes --]

On Tue, Jan 27, 2015 at 12:43:52AM +0100, Stef Bon wrote:
> 2015-01-26 22:14 GMT+01:00 Chris Murphy <lists@colorremedies.com>:
> >> is there a way to get the difference between these two files by making
> >> use of btrfs?
> >
> > Snapper has this functionality built into it. I'm not sure if it uses
> > diff or something else. But the Snapper GUI in yast2 on opensuse will
> > let you see what files have changed between snapshots, click on the
> > file and it shows a color coded diff.
> 
> Hi Chris,
> 
> I think (I'm not sure) it's using a high level tool like diff/rdiff.
> 
> I will contact the developers of snapper anyway, since my project is
> simular to theirs.
> 
> But what I'm asking is is there a lowlevel tool to give you a list of
> blocks where two versions
> of one file differ. I'm asking since btrfs keeps track of the blocks
> where files differ, and where they
> are the same.
> 
> So a lowlevel call to the btrfs filesystem.

You could try the FIEMAP ioctl, which is not btrfs-specific.  The same
ioctl also works on e.g. ext4; however, since ext4 can't share blocks
between files and btrfs can, it's much more interesting on btrfs.  ;)

FIEMAP will give you a list of physical block ranges (btrfs logical
extent addresses).  Run it on both files and analyse the results.
Any blocks with the same physical addresses are trivially identical,
since they refer to the same physical storage.  If your system is full of
huge lightly modified files (e.g. VM images or large databases) that can
save you an awful lot of I/O because you'd only have to compare blocks
from a pair of files if they had different physical addresses.

You can also look up blocks by logical address (see btrfs-tools 'inspect
logical-resolve') and find out what files they belong to.  This gives
you a "which files are similar to this one" sort of query, especially
after you've run dedup over the files in question.

> Stef
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2015-01-28  3:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 20:52 Get the diff from a file in two snapshots Stef Bon
2015-01-26 21:14 ` Chris Murphy
2015-01-26 23:43   ` Stef Bon
2015-01-28  3:46     ` Zygo Blaxell [this message]
2015-01-28 10:28       ` Stef Bon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150128034636.GA13452@hungrycats.org \
    --to=ce3g8jdj@umail.furryterror.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@colorremedies.com \
    --cc=stefbon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.