From: David Sterba <dsterba@suse.cz>
To: Stefan Behrens <sbehrens@giantdisaster.de>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/5] Btrfs: support printing UUID tree elements
Date: Mon, 29 Apr 2013 16:31:53 +0200 [thread overview]
Message-ID: <20130429143153.GP16427@twin.jikos.cz> (raw)
In-Reply-To: <85b4a097a36353848383d0ac0339cb644a1cf2bb.1366384796.git.sbehrens@giantdisaster.de>
On Fri, Apr 19, 2013 at 05:41:03PM +0200, Stefan Behrens wrote:
> --- a/fs/btrfs/print-tree.c
> +++ b/fs/btrfs/print-tree.c
> +static void print_uuid_item(struct extent_buffer *l,
> + struct btrfs_uuid_item *ptr,
> + u64 item_size)
> +{
> + do {
> + u64 sub_item_type;
> + u64 sub_item_len;
> + u64 subvol_id;
> +
> + if (item_size < sizeof(*ptr)) {
> + printk(KERN_INFO "btrfs: uuid item too short!\n");
please print the expected and found sizes (also in (2) below)
> + return;
> + }
> + sub_item_type = btrfs_uuid_type(l, ptr);
> + sub_item_len = btrfs_uuid_len(l, ptr);
> + ptr++;
> + item_size -= sizeof(*ptr);
> + if (sub_item_len * 8 > item_size) {
For documentation purposes, I think using sizeof(u64) instead of 8.
> + printk(KERN_INFO "btrfs: uuid item too short (2)!\n");
> + return;
> + }
> +
> + item_size -= sub_item_len * 8;
> + switch (sub_item_type) {
> + case BTRFS_UUID_ITEM_TYPE_SUBVOL:
> + while (sub_item_len) {
> + read_extent_buffer(l, &subvol_id,
> + (unsigned long)ptr, 8);
> + printk(KERN_INFO "\t\tsubvol_id %llu\n",
> + (unsigned long long)
> + le64_to_cpu(subvol_id));
> + sub_item_len--;
> + ptr = (struct btrfs_uuid_item *)
> + (((char *)ptr) + 8);
and this could be wrapped in a macro or function, it's repeated several
times in that function.
> + }
> + break;
> + case BTRFS_UUID_ITEM_TYPE_RECEIVED_SUBVOL:
> + while (sub_item_len) {
> + read_extent_buffer(l, &subvol_id,
> + (unsigned long)ptr, 8);
> + printk(KERN_INFO "\t\treceived_subvol_id %llu\n",
> + (unsigned long long)
> + le64_to_cpu(subvol_id));
> + sub_item_len--;
> + ptr = (struct btrfs_uuid_item *)
> + (((char *)ptr) + 8);
> + }
> + break;
> + default:
> + printk(KERN_INFO "\t\tunknown type=%llu, len=8*%llu\n",
> + (unsigned long long)sub_item_type,
> + (unsigned long long)sub_item_len);
> + while (sub_item_len) {
> + read_extent_buffer(l, &subvol_id,
> + (unsigned long)ptr, 8);
> + printk(KERN_INFO "\t\tid %llu\n",
> + (unsigned long long)
> + le64_to_cpu(subvol_id));
> + sub_item_len--;
> + ptr = (struct btrfs_uuid_item *)
> + (((char *)ptr) + 8);
> + }
> + break;
> + }
> + } while (item_size);
> +}
next prev parent reply other threads:[~2013-04-29 14:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-19 15:41 [PATCH 0/5] Btrfs: introduce a tree for UUID to subvol ID mapping Stefan Behrens
2013-04-19 15:41 ` [PATCH 1/5] Btrfs: introduce a tree for items that map UUIDs to something Stefan Behrens
2013-04-29 19:27 ` Josef Bacik
2013-04-19 15:41 ` [PATCH 2/5] Btrfs: support printing UUID tree elements Stefan Behrens
2013-04-29 14:31 ` David Sterba [this message]
2013-04-19 15:41 ` [PATCH 3/5] Btrfs: create UUID tree if required Stefan Behrens
2013-04-29 14:35 ` David Sterba
2013-04-19 15:41 ` [PATCH 4/5] Btrfs: maintain subvolume items in the UUID tree Stefan Behrens
2013-04-29 14:50 ` David Sterba
2013-04-19 15:41 ` [PATCH 5/5] Btrfs: fill UUID tree initially Stefan Behrens
2013-04-29 15:12 ` David Sterba
2013-04-29 17:31 ` Stefan Behrens
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=20130429143153.GP16427@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=sbehrens@giantdisaster.de \
/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