From: Josh Durgin <josh.durgin@inktank.com>
To: Alex Elder <elder@inktank.com>
Cc: ceph-devel <ceph-devel@vger.kernel.org>
Subject: Re: [PATCH 6/6] rbd: probe the parent of an image if present
Date: Wed, 31 Oct 2012 19:07:16 -0700 [thread overview]
Message-ID: <5091D954.70708@inktank.com> (raw)
In-Reply-To: <509083D0.1060003@inktank.com>
This all makes sense, but it reminds me of another issue we'll need to
address:
http://www.tracker.newdream.net/issues/2533
We don't need to watch the header of a parent snapshot, since it's
immutable and guaranteed not to be deleted out from under us.
This avoids the bug referenced above. So I guess rbd_dev_probe{_finish}
can take a parameter telling them whether to watch the header or not.
We should check whether multiple mapped rbds (without layering) hit
this issue as well, and if so, default to not sharing the ceph_client
until the bug is fixed.
On 10/30/2012 06:50 PM, Alex Elder wrote:
> Call the probe function for the parent device.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
> drivers/block/rbd.c | 79
> +++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 76 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 04062c1..8ef13f72 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -222,6 +222,7 @@ struct rbd_device {
>
> struct rbd_spec *parent_spec;
> u64 parent_overlap;
> + struct rbd_device *parent;
>
> /* protects updating the header */
> struct rw_semaphore header_rwsem;
> @@ -255,6 +256,7 @@ static ssize_t rbd_add(struct bus_type *bus, const
> char *buf,
> size_t count);
> static ssize_t rbd_remove(struct bus_type *bus, const char *buf,
> size_t count);
> +static int rbd_dev_probe(struct rbd_device *rbd_dev);
>
> static struct bus_attribute rbd_bus_attrs[] = {
> __ATTR(add, S_IWUSR, NULL, rbd_add),
> @@ -378,6 +380,13 @@ out_opt:
> return ERR_PTR(ret);
> }
>
> +static struct rbd_client *__rbd_get_client(struct rbd_client *rbdc)
> +{
> + kref_get(&rbdc->kref);
> +
> + return rbdc;
> +}
> +
> /*
> * Find a ceph client with specific addr and configuration. If
> * found, bump its reference count.
> @@ -393,7 +402,8 @@ static struct rbd_client *rbd_client_find(struct
> ceph_options *ceph_opts)
> spin_lock(&rbd_client_list_lock);
> list_for_each_entry(client_node, &rbd_client_list, node) {
> if (!ceph_compare_options(ceph_opts, client_node->client)) {
> - kref_get(&client_node->kref);
> + __rbd_get_client(client_node);
> +
> found = true;
> break;
> }
> @@ -3311,6 +3321,11 @@ static int rbd_dev_image_id(struct rbd_device
> *rbd_dev)
> void *response;
> void *p;
>
> + /* If we already have it we don't need to look it up */
> +
> + if (rbd_dev->spec->image_id)
> + return 0;
> +
> /*
> * When probing a parent image, the image id is already
> * known (and the image name likely is not). There's no
> @@ -3492,6 +3507,9 @@ out_err:
>
> static int rbd_dev_probe_finish(struct rbd_device *rbd_dev)
> {
> + struct rbd_device *parent = NULL;
> + struct rbd_spec *parent_spec = NULL;
> + struct rbd_client *rbdc = NULL;
> int ret;
>
> /* no need to lock here, as rbd_dev is not registered yet */
> @@ -3536,6 +3554,31 @@ static int rbd_dev_probe_finish(struct rbd_device
> *rbd_dev)
> * At this point cleanup in the event of an error is the job
> * of the sysfs code (initiated by rbd_bus_del_dev()).
> */
> + /* Probe the parent if there is one */
> +
> + if (rbd_dev->parent_spec) {
> + /*
> + * We need to pass a reference to the client and the
> + * parent spec when creating the parent rbd_dev.
> + * Images related by parent/child relationships
> + * always share both.
> + */
> + parent_spec = rbd_spec_get(rbd_dev->parent_spec);
> + rbdc = __rbd_get_client(rbd_dev->rbd_client);
> +
> + parent = rbd_dev_create(rbdc, parent_spec);
> + if (!parent) {
> + ret = -ENOMEM;
> + goto err_out_spec;
> + }
> + rbdc = NULL; /* parent now owns reference */
> + parent_spec = NULL; /* parent now owns reference */
> + ret = rbd_dev_probe(parent);
> + if (ret < 0)
> + goto err_out_parent;
> + rbd_dev->parent = parent;
> + }
> +
> down_write(&rbd_dev->header_rwsem);
> ret = rbd_dev_snaps_register(rbd_dev);
> up_write(&rbd_dev->header_rwsem);
> @@ -3554,6 +3597,12 @@ static int rbd_dev_probe_finish(struct rbd_device
> *rbd_dev)
> (unsigned long long) rbd_dev->mapping.size);
>
> return ret;
> +
> +err_out_parent:
> + rbd_dev_destroy(parent);
> +err_out_spec:
> + rbd_spec_put(parent_spec);
> + rbd_put_client(rbdc);
> err_out_bus:
> /* this will also clean up rest of rbd_dev stuff */
>
> @@ -3717,6 +3766,12 @@ static void rbd_dev_release(struct device *dev)
> module_put(THIS_MODULE);
> }
>
> +static void __rbd_remove(struct rbd_device *rbd_dev)
> +{
> + rbd_remove_all_snaps(rbd_dev);
> + rbd_bus_del_dev(rbd_dev);
> +}
> +
> static ssize_t rbd_remove(struct bus_type *bus,
> const char *buf,
> size_t count)
> @@ -3743,8 +3798,26 @@ static ssize_t rbd_remove(struct bus_type *bus,
> goto done;
> }
>
> - rbd_remove_all_snaps(rbd_dev);
> - rbd_bus_del_dev(rbd_dev);
> + while (rbd_dev->parent_spec) {
> + struct rbd_device *first = rbd_dev;
> + struct rbd_device *second = first->parent;
> + struct rbd_device *third;
> +
> + /*
> + * Follow to the parent with no grandparent and
> + * remove it.
> + */
> + while (second && (third = second->parent)) {
> + first = second;
> + second = third;
> + }
> + __rbd_remove(second);
> + rbd_spec_put(first->parent_spec);
> + first->parent_spec = NULL;
> + first->parent_overlap = 0;
> + first->parent = NULL;
> + }
> + __rbd_remove(rbd_dev);
>
> done:
> mutex_unlock(&ctl_mutex);
>
next prev parent reply other threads:[~2012-11-01 2:07 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 1:41 [PATCH 0/6] rbd: version 2 parent probing Alex Elder
2012-10-31 1:49 ` [PATCH 1/6] rbd: skip getting image id if known Alex Elder
2012-10-31 21:05 ` Josh Durgin
2012-10-31 1:49 ` [PATCH 2/6] rbd: allow null image name Alex Elder
2012-10-31 21:07 ` Josh Durgin
2012-10-31 1:49 ` [PATCH 3/6] rbd: get parent spec for version 2 images Alex Elder
2012-11-01 1:33 ` Josh Durgin
2012-10-31 1:49 ` [PATCH 4/6] libceph: define ceph_pg_pool_name_by_id() Alex Elder
2012-11-01 1:34 ` Josh Durgin
2012-10-31 1:49 ` [PATCH 5/6] rbd: get additional info in parent spec Alex Elder
2012-10-31 14:11 ` Alex Elder
2012-11-01 1:49 ` Josh Durgin
2012-11-01 12:18 ` Alex Elder
2012-10-31 1:50 ` [PATCH 6/6] rbd: probe the parent of an image if present Alex Elder
2012-10-31 11:59 ` slow fio random read benchmark, need help Alexandre DERUMIER
2012-10-31 15:57 ` Sage Weil
2012-10-31 16:29 ` Alexandre DERUMIER
2012-10-31 16:50 ` Alexandre DERUMIER
2012-10-31 17:08 ` Marcus Sorensen
2012-10-31 17:27 ` Alexandre DERUMIER
2012-10-31 17:38 ` Marcus Sorensen
2012-10-31 18:56 ` Alexandre DERUMIER
2012-10-31 19:50 ` Marcus Sorensen
2012-11-01 5:11 ` Alexandre DERUMIER
2012-11-01 5:41 ` Stefan Priebe - Profihost AG
2012-10-31 20:22 ` Josh Durgin
2012-11-01 7:38 ` Dietmar Maurer
2012-11-01 8:08 ` Stefan Priebe - Profihost AG
2012-11-01 10:40 ` Gregory Farnum
2012-11-01 10:54 ` Stefan Priebe - Profihost AG
2012-11-02 9:38 ` Alexandre DERUMIER
2012-11-03 10:01 ` slow fio random read benchmark: last librbd git : 20000iops ! Alexandre DERUMIER
2012-11-03 12:09 ` Alexandre DERUMIER
2012-11-01 15:46 ` slow fio random read benchmark, need help Marcus Sorensen
2012-11-01 16:28 ` Marcus Sorensen
2012-11-01 17:00 ` Dietmar Maurer
2012-11-03 17:09 ` Gregory Farnum
2012-11-04 14:54 ` Alexandre DERUMIER
2012-11-01 2:07 ` Josh Durgin [this message]
2012-11-01 12:26 ` [PATCH 6/6] rbd: probe the parent of an image if present Alex Elder
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=5091D954.70708@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.