From: Stefan Behrens <sbehrens@giantdisaster.de>
To: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 3/4] Btrfs-progs: add more subvol fields to btrfs-list
Date: Fri, 12 Apr 2013 10:18:41 +0200 [thread overview]
Message-ID: <5167C361.8030508@giantdisaster.de> (raw)
In-Reply-To: <51676693.8080506@cn.fujitsu.com>
On Fri, 12 Apr 2013 09:42:43 +0800, Wang Shilong wrote:
>> + if (ritem && !is_v0) {
>> + rinfo->cgen = btrfs_root_ctransid(ritem);
>> + rinfo->ogen = btrfs_root_otransid(ritem);
>> + rinfo->sgen = btrfs_root_stransid(ritem);
>> + rinfo->rgen = btrfs_root_rtransid(ritem);
>> + rinfo->ctime = btrfs_stack_timespec_sec(&ritem->ctime);
>> + rinfo->otime = btrfs_stack_timespec_sec(&ritem->otime);
>> + rinfo->stime = btrfs_stack_timespec_sec(&ritem->stime);
>> + rinfo->rtime = btrfs_stack_timespec_sec(&ritem->rtime);
>> + memcpy(rinfo->uuid, ritem->uuid, BTRFS_UUID_SIZE);
>> + memcpy(rinfo->puuid, ritem->parent_uuid, BTRFS_UUID_SIZE);
>> + memcpy(rinfo->ruuid, ritem->received_uuid, BTRFS_UUID_SIZE);
>> + }
>> +
>> + /* TODO: this is copied from the old code, what is it good for? */
>> + if ((!ritem || !btrfs_root_otransid(ritem)) && root_offset)
>> + rinfo->ogen = root_offset;
>
>
> For the older kernel:
> subvolume's original generation is always 0, but
> for snapshot, root_offset equals to its original generation.
> so we set it here.
>
Thanks for this hint! So it's for old style (v0) root_item entries.
My code above is not correct since it accesses a field that is not available
for v0 root items.
I changed it like this:
@@ -502,11 +502,14 @@ static int set_root_info(struct root_info *rinfo, u64 ref_
memcpy(rinfo->uuid, ritem->uuid, BTRFS_UUID_SIZE);
memcpy(rinfo->puuid, ritem->parent_uuid, BTRFS_UUID_SIZE);
memcpy(rinfo->ruuid, ritem->received_uuid, BTRFS_UUID_SIZE);
- }
-
- /* TODO: this is copied from the old code, what is it good for? */
- if ((!ritem || !btrfs_root_otransid(ritem)) && root_offset)
+ } else if (ritem && is_v0 && root_offset) {
+ /*
+ * old style (v0) root items don't contain an otransid field.
+ * But for snapshots, root_offset equals to its original
+ * generation.
+ */
rinfo->ogen = root_offset;
+ }
next prev parent reply other threads:[~2013-04-12 8:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-11 16:22 [PATCH v2 0/4] Btrfs-progs: add --fields option to subvol list Stefan Behrens
2013-04-11 16:22 ` [PATCH v2 1/4] Btrfs-progs: cleanup in btrfs-list.c Stefan Behrens
2013-04-11 16:22 ` [PATCH v2 2/4] Btrfs-progs: make the btrfs-list output more compact Stefan Behrens
2013-04-11 16:22 ` [PATCH v2 3/4] Btrfs-progs: add more subvol fields to btrfs-list Stefan Behrens
2013-04-12 1:34 ` Wang Shilong
2013-04-12 1:42 ` Wang Shilong
2013-04-12 8:18 ` Stefan Behrens [this message]
2013-04-11 16:22 ` [PATCH v2 4/4] Btrfs-progs: enhance 'btrfs subvolume list' Stefan Behrens
2013-04-12 0:58 ` Wang Shilong
2013-04-12 7:44 ` Stefan Behrens
2013-04-18 16:28 ` David Sterba
2013-04-18 16:42 ` David Sterba
2013-04-12 8:26 ` [PATCH v3 3/4] Btrfs-progs: add more subvol fields to btrfs-list Stefan Behrens
2013-04-12 8:39 ` Wang Shilong
2013-04-12 9:05 ` Stefan Behrens
2013-04-12 9:33 ` Wang Shilong
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=5167C361.8030508@giantdisaster.de \
--to=sbehrens@giantdisaster.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=wangsl-fnst@cn.fujitsu.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.