From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
To: Stefan Behrens <sbehrens@giantdisaster.de>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 08/17] Btrfs-progs: Set the root-id for received subvols in btrfs receive
Date: Wed, 10 Apr 2013 09:04:15 +0800 [thread overview]
Message-ID: <5164BA8F.7040802@cn.fujitsu.com> (raw)
In-Reply-To: <68d8e4735895de4f99a49484a14d34b69962ae17.1365524492.git.sbehrens@giantdisaster.de>
Hello,
> When an entry was added to the subvol search tree, the root_id was
> always 0 (not set at all) and therefore only the first one was
> added, all the others had been ignored. This commit adds a function
> to retrieve the root_id for a given fd, and this function is used
> to set the root_id before the entry is added.
>
> Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
> ---
> cmds-receive.c | 3 +++
> send-utils.c | 20 ++++++++++++++++++++
> send-utils.h | 1 +
> 3 files changed, 24 insertions(+)
>
> diff --git a/cmds-receive.c b/cmds-receive.c
> index dc72e9e..eedff13 100644
> --- a/cmds-receive.c
> +++ b/cmds-receive.c
> @@ -125,6 +125,9 @@ static int finish_subvol(struct btrfs_receive *r)
> goto out;
> }
>
> + ret = btrfs_get_root_id(subvol_fd, &r->cur_subvol->root_id);
There has been a function in btrfs-list.c named 'btrfs_list_get_path_rootid'
which does the same things as 'btrfs_get_root_id'.I think you can reuse it.
Thanks,
Wang
> + if (ret < 0)
> + goto out;
> subvol_uuid_search_add(&r->sus, r->cur_subvol);
> r->cur_subvol = NULL;
> ret = 0;
> diff --git a/send-utils.c b/send-utils.c
> index 182778a..b2d544c 100644
> --- a/send-utils.c
> +++ b/send-utils.c
> @@ -23,6 +23,26 @@
> #include "ioctl.h"
> #include "btrfs-list.h"
>
> +int btrfs_get_root_id(int fd, u64 *root_id)
> +{
> + struct btrfs_ioctl_ino_lookup_args ino_args;
> + int ret;
> +
> + memset(&ino_args, 0, sizeof(ino_args));
> + ino_args.objectid = BTRFS_FIRST_FREE_OBJECTID;
> +
> + /* this ioctl fills in ino_args->treeid */
> + ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args);
> + if (ret) {
> + fprintf(stderr, "ERROR: Failed to lookup root_id - %s\n",
> + strerror(errno));
> + return ret;
> + }
> +
> + *root_id = ino_args.treeid;
> + return 0;
> +}
> +
> static struct rb_node *tree_insert(struct rb_root *root,
> struct subvol_info *si,
> enum subvol_search_type type)
> diff --git a/send-utils.h b/send-utils.h
> index 78abf94..3c8b7b7 100644
> --- a/send-utils.h
> +++ b/send-utils.h
> @@ -61,6 +61,7 @@ struct subvol_uuid_search {
> struct rb_root path_subvols;
> };
>
> +int btrfs_get_root_id(int fd, u64 *root_id);
> int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s);
> void subvol_uuid_search_finit(struct subvol_uuid_search *s);
> struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s,
next prev parent reply other threads:[~2013-04-10 1:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 17:08 [PATCH 00/17] Btrfs-progs: some receive related patches Stefan Behrens
2013-04-09 17:08 ` [PATCH 01/17] Btrfs-progs: Use /proc/mounts instead of /etc/mtab Stefan Behrens
2013-04-09 17:08 ` [PATCH 02/17] Btrfs-progs: ignore subvols above BTRFS_LAST_FREE_OBJECTID Stefan Behrens
2013-04-09 17:08 ` [PATCH 03/17] Btrfs-progs: close file descriptor in cmds-send.c Stefan Behrens
2013-04-09 17:08 ` [PATCH 04/17] Btrfs-progs: fix a small memory leak in btrfs-list.c Stefan Behrens
2013-04-09 17:08 ` [PATCH 05/17] Btrfs-progs: add a function to free subvol_uuid_search memory Stefan Behrens
2013-04-09 17:08 ` [PATCH 06/17] Btrfs-progs: cleanup subvol_uuid_search memory in btrfs send/receive Stefan Behrens
2013-04-09 17:08 ` [PATCH 07/17] Btrfs-progs: free memory and close file descriptor in btrfs receive Stefan Behrens
2013-04-09 17:08 ` [PATCH 08/17] Btrfs-progs: Set the root-id for received subvols " Stefan Behrens
2013-04-10 1:04 ` Wang Shilong [this message]
2013-04-09 17:08 ` [PATCH 09/17] Btrfs-progs: btrfs-receive: different levels (amount) of debug output Stefan Behrens
2013-04-09 17:08 ` [PATCH 10/17] Btrfs-progs: small parent_subvol cleanup for cmds-receive.c Stefan Behrens
2013-04-09 17:08 ` [PATCH 11/17] Btrfs-progs: fix bug in find_root_gen Stefan Behrens
2013-04-09 17:08 ` [PATCH 12/17] Btrfs-progs: btrfs-receive optionally honors the end-cmd Stefan Behrens
2013-04-09 17:08 ` [PATCH 13/17] Btrfs-progs: don't allocate one byte too much each time Stefan Behrens
2013-04-09 17:08 ` [PATCH 14/17] Btrfs-progs: Fix that BTRFS_FSID_SIZE is used instead of BTRFS_UUID_SIZE Stefan Behrens
2013-04-09 17:08 ` [PATCH 15/17] Btrfs-progs: remove some unused code Stefan Behrens
2013-04-09 17:08 ` [PATCH 16/17] Btrfs-progs: allow to receive to relative directories Stefan Behrens
2013-04-09 17:08 ` [PATCH 17/17] btrfs-progs: Fix the receive code pathing Stefan Behrens
2013-04-10 10:08 ` [PATCH 08/17 v2] Btrfs-progs: Set the root-id for received subvols in btrfs receive Stefan Behrens
2013-04-16 12:33 ` [PATCH 00/17] Btrfs-progs: some receive related patches David Sterba
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=5164BA8F.7040802@cn.fujitsu.com \
--to=wangsl-fnst@cn.fujitsu.com \
--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 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.