Message ID | 50487FD8.1000804@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> - if(ri->generation == ri->generation_v2) { > + if(sh->len == sizeof(struct btrfs_root_item)) { > t = ri->otime.sec; This looks fine now but should this work when we move to v3 and still have access to v2 introduced members.? ker cli v3 v2 v2 introduced members are unnecessarily blocked v2 v3 --as above-- Thanks, Anand -- 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
On Tue, 18 Sep 2012 13:56:44 +0800, Anand Jain wrote: > > >> - if(ri->generation == ri->generation_v2) { >> + if(sh->len == sizeof(struct btrfs_root_item)) { >> t = ri->otime.sec; > > This looks fine now but should this work when we > move to v3 and still have access to v2 introduced > members.? > > ker cli > v3 v2 v2 introduced members are unnecessarily blocked > v2 v3 --as above-- No. I will update my patch to fix this problem. Thanks Miao -- 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
diff --git a/btrfs-list.c b/btrfs-list.c index ef621f0..2101695 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -737,7 +737,7 @@ again: } else if (get_gen && sh->type == BTRFS_ROOT_ITEM_KEY) { ri = (struct btrfs_root_item *)(args.buf + off); gen = btrfs_root_generation(ri); - if(ri->generation == ri->generation_v2) { + if(sh->len == sizeof(struct btrfs_root_item)) { t = ri->otime.sec; memcpy(uuid, ri->uuid, BTRFS_UUID_SIZE); } else { @@ -844,7 +844,7 @@ static int __list_snapshot_search(int fd, struct root_lookup *root_lookup) off += sizeof(*sh); if (sh->type == BTRFS_ROOT_ITEM_KEY && sh->offset) { item = (struct btrfs_root_item *)(args.buf + off); - if(item->generation == item->generation_v2) { + if(sh->len == sizeof(struct btrfs_root_item)) { t = item->otime.sec; memcpy(uuid, item->uuid, BTRFS_UUID_SIZE); } else {
Now we check if the root item contains otime and uuid or not by comparing ->generation_v2 and ->generation of the btrfs_root_item structure, it is wrong because it is possbile that ->generation may equal to the first variant of the next item. We fix this problem by comparing the size of btrfs_root_item because the size is different between the old and new ones. we needn't worry the case that the new filesystem is mounted on the old kernel. because the otime and uuid are not changed on the old kernel, we can get the correct result even on the kernel. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> --- Changelog v1 -> v3: - new patch --- btrfs-list.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)