From: Axel Burri <axel@tty0.ch>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Used disk size of a received subvolume?
Date: Thu, 16 May 2019 16:54:42 +0200 [thread overview]
Message-ID: <c79df692-cc5d-5a3a-1123-e376e8c94eb3@tty0.ch> (raw)
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".
Any thoughts? I'm willing to implement such a feature in btrfs-progs if
this sounds reasonable to you.
- Axel
Ref: https://github.com/digint/btrbk/issues/280
next reply other threads:[~2019-05-16 15:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 14:54 Axel Burri [this message]
2019-05-16 17:09 ` Used disk size of a received subvolume? Remi Gauvin
2019-05-17 14:14 ` Axel Burri
2019-05-17 16:22 ` Remi Gauvin
2019-05-16 17:12 ` Hugo Mills
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=c79df692-cc5d-5a3a-1123-e376e8c94eb3@tty0.ch \
--to=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).