From: Josh Durgin <josh.durgin@inktank.com>
To: Alex Elder <elder@inktank.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 4/4] rbd: set snapshot id in rbd_dev_probe_update_spec()
Date: Mon, 29 Apr 2013 08:31:13 -0700 [thread overview]
Message-ID: <517E9241.7070105@inktank.com> (raw)
In-Reply-To: <517A94CE.2050408@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
On 04/26/2013 07:53 AM, Alex Elder wrote:
> Set the rbd spec's snapshot id for an image getting mapped in
> rbd_dev_probe_update_spec() rather than rbd_dev_set_mapping().
> This is the more logical place for that to happen (even though
> it means we might look up the snapshot by name twice).
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
> drivers/block/rbd.c | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 5f97137..5099f44 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -846,7 +846,6 @@ static int rbd_dev_set_mapping(struct rbd_device
> *rbd_dev)
> {
> if (!memcmp(rbd_dev->spec->snap_name, RBD_SNAP_HEAD_NAME,
> sizeof (RBD_SNAP_HEAD_NAME))) {
> - rbd_dev->spec->snap_id = CEPH_NOSNAP;
> rbd_dev->mapping.size = rbd_dev->header.image_size;
> rbd_dev->mapping.features = rbd_dev->header.features;
> } else {
> @@ -855,7 +854,6 @@ static int rbd_dev_set_mapping(struct rbd_device
> *rbd_dev)
> snap = snap_by_name(rbd_dev, rbd_dev->spec->snap_name);
> if (!snap)
> return -ENOENT;
> - rbd_dev->spec->snap_id = snap->id;
> rbd_dev->mapping.size = snap->size;
> rbd_dev->mapping.features = snap->features;
> rbd_dev->mapping.read_only = true;
> @@ -3759,6 +3757,10 @@ out:
> * rbd_dev_snaps_update() has completed because some of the
> * information (in particular, snapshot name) is not available
> * until then.
> + *
> + * When an image being mapped (not a parent) is probed, we have the
> + * pool name and pool id, image name and image id, and the snapshot
> + * name. The only thing we're missing is the snapshot id.
> */
> static int rbd_dev_probe_update_spec(struct rbd_device *rbd_dev)
> {
> @@ -3767,8 +3769,24 @@ static int rbd_dev_probe_update_spec(struct
> rbd_device *rbd_dev)
> void *reply_buf = NULL;
> int ret;
>
> - if (rbd_dev->spec->pool_name)
> - return 0; /* Already have the names */
> + /*
> + * An image being mapped will have the pool name (etc.), but
> + * we need to look up the snapshot id.
> + */
> + if (rbd_dev->spec->pool_name) {
> + if (strcmp(rbd_dev->spec->snap_name, RBD_SNAP_HEAD_NAME)) {
> + struct rbd_snap *snap;
> +
> + snap = snap_by_name(rbd_dev, rbd_dev->spec->snap_name);
> + if (!snap)
> + return -ENOENT;
> + rbd_dev->spec->snap_id = snap->id;
> + } else {
> + rbd_dev->spec->snap_id = CEPH_NOSNAP;
> + }
> +
> + return 0;
> + }
>
> /* Look up the pool name */
>
prev parent reply other threads:[~2013-04-29 15:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 14:51 [PATCH 0/4] rbd: cleanup and leaks #2 Alex Elder
2013-04-26 14:52 ` [PATCH 1/4] rbd: have rbd_dev_image_id() set format 1 image id Alex Elder
2013-04-29 15:26 ` Josh Durgin
2013-04-26 14:52 ` [PATCH 2/4] rbd: fix image id leak in initial probe Alex Elder
2013-04-29 15:27 ` Josh Durgin
2013-04-26 14:52 ` [PATCH 3/4] rbd: have snap_by_name() return a snapshot Alex Elder
2013-04-29 15:28 ` Josh Durgin
2013-04-26 14:53 ` [PATCH 4/4] rbd: set snapshot id in rbd_dev_probe_update_spec() Alex Elder
2013-04-29 15:31 ` Josh Durgin [this message]
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=517E9241.7070105@inktank.com \
--to=josh.durgin@inktank.com \
--cc=ceph-devel@vger.kernel.org \
--cc=elder@inktank.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.