From: Miao Xie <miaox@cn.fujitsu.com>
To: Linux Btrfs <linux-btrfs@vger.kernel.org>
Subject: [PATCH V3 4/7] Btrfs-progs: fix wrong way to check if the root item contains otime and uuid
Date: Thu, 06 Sep 2012 18:50:00 +0800 [thread overview]
Message-ID: <50487FD8.1000804@cn.fujitsu.com> (raw)
In-Reply-To: <50487F6E.6060001@cn.fujitsu.com>
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(-)
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 {
--
1.7.6.5
next prev parent reply other threads:[~2012-09-06 10:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-06 10:48 [PATCH V3 0/7 ] Btrfs-progs: enhance btrfs subvol list only to show read-only snapshots Miao Xie
2012-09-06 10:48 ` [PATCH V3 1/7] Btrfs-progs: move the function declarations to a new head file Miao Xie
2012-09-06 10:49 ` [PATCH V3 2/7] Btrfs-progs: fix compile warning of implicit declaration, of "list_snapshots" Miao Xie
2012-09-06 10:49 ` [PATCH V3 3/7] Btrfs-progs: fix wrong usage of btrfs subvolume list command Miao Xie
2012-09-06 10:50 ` Miao Xie [this message]
2012-09-18 5:56 ` [PATCH V3 4/7] Btrfs-progs: fix wrong way to check if the root item contains otime and uuid Anand Jain
2012-09-18 6:11 ` Miao Xie
2012-09-06 10:50 ` [PATCH V3 5/7] Btrfs-progs: restructure list_subvolumes Miao Xie
2012-09-06 10:50 ` [PATCH V3 6/7] Btrfs-progs: enhance btrfs subvol list only to show read-only snapshots Miao Xie
2012-09-06 10:50 ` [PATCH V3 7/7] Btrfs-progs: update the manpage entries for the btrfs, subvolume list Miao Xie
2012-09-06 10:57 ` [PATCH V3 1/7] Btrfs-progs: move the function declarations to a new head file Miao Xie
2012-09-06 10:59 ` [PATCH V3 7/7] Btrfs-progs: update the manpage entries for the btrfs subvolume list Miao Xie
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=50487FD8.1000804@cn.fujitsu.com \
--to=miaox@cn.fujitsu.com \
--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).