linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugo Mills <hugo@carfax.org.uk>
To: Axel Burri <axel@tty0.ch>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Used disk size of a received subvolume?
Date: Thu, 16 May 2019 17:12:25 +0000	[thread overview]
Message-ID: <20190516171225.GH1667@carfax.org.uk> (raw)
In-Reply-To: <c79df692-cc5d-5a3a-1123-e376e8c94eb3@tty0.ch>

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

On Thu, May 16, 2019 at 04:54:42PM +0200, Axel Burri wrote:
> Trying to get the size of a subvolume created using "btrfs receive",
> I've come with a cute little script:
> 
>    SUBVOL=/path/to/subvolume
>    CGEN=$(btrfs subvolume show "$SUBVOL" \
>      | sed -n 's/\s*Gen at creation:\s*//p')
>    btrfs subvolume find-new "$SUBVOL" $((CGEN+1)) \
>      | cut -d' ' -f7 \
>      | tr '\n' '+' \
>      | sed 's/\+\+$/\n/' \
>      | bc
> 
> This simply sums up the "len" field from all modified files since the
> creation of the subvolume. Works fine, as btrfs-receive first makes a
> snapshot of the parent subvolume, then adds the files according to the
> send-stream.
> 
> Now this rises some questions:
> 
> 1. How accurate is this? AFAIK "btrfs find-new" prints real length, not
> compressed length.
> 
> 2. If there are clone-sources in the send-stream, the cloned files
> probably also appear in the list.
> 
> 3. Is there a better way? It would be nice to have a btrfs command for
> this. It would be straight-forward to have a "--summary" option in
> "btrfs find-new", another approach would be to calculate and dump the
> size in either "btrfs send" or "btrfs receive".

   btrfs find-new also doesn't tell you about deleted files (fairly
obviously), so if anything's been removed, you'll be overestimating
the overall change in size.

> Any thoughts? I'm willing to implement such a feature in btrfs-progs if
> this sounds reasonable to you.

   If you're looking for the incremental usage of the subvolume, why
not just use the "exclusive" value from btrfs fi du? That's exactly
that information. (And note that it changes over time, as other
subvols it shares with are deleted).

   Hugo.

-- 
Hugo Mills             | Your problem is that you've got too much taste to be
hugo@... carfax.org.uk | a web developer.
http://carfax.org.uk/  |
PGP: E2AB1DE4          |                                          Steve Harris

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

  parent reply	other threads:[~2019-05-16 17:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 14:54 Used disk size of a received subvolume? Axel Burri
2019-05-16 17:09 ` Remi Gauvin
2019-05-17 14:14   ` Axel Burri
2019-05-17 16:22     ` Remi Gauvin
2019-05-16 17:12 ` Hugo Mills [this message]
2019-05-17 13:57   ` Axel Burri
2019-05-17 15:28     ` Graham Cobb
2019-05-17 16:39       ` Steven Davies
2019-05-17 23:15         ` Graham Cobb
2019-05-23 16:06       ` Axel Burri

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=20190516171225.GH1667@carfax.org.uk \
    --to=hugo@carfax.org.uk \
    --cc=axel@tty0.ch \
    --cc=linux-btrfs@vger.kernel.org \
    /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 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).