From: Josh Durgin <josh.durgin@inktank.com>
To: Alex Elder <elder@inktank.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 6/6] rbd: always set read-only flag in rbd_add()
Date: Tue, 07 May 2013 15:51:35 -0700 [thread overview]
Message-ID: <51898577.7040509@inktank.com> (raw)
In-Reply-To: <51885B13.4070900@inktank.com>
On 05/06/2013 06:38 PM, Alex Elder wrote:
> Hold off setting the read-only flag in rbd_add() for an image being
> mapped until we have successfully probed the image. At that point
> we know whether it's a snapshot mapping or not, so we can set the
> read-only flag in that one place rather than doing so (for
> snapshots) in rbd_dev_mapping_set(). To do this, pass a flag to the
> image probe routine indicating whether we want a read-only mapping.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
> drivers/block/rbd.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 530793a..0c72643 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -359,7 +359,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_image_probe(struct rbd_device *rbd_dev);
> +static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only);
>
> static struct bus_attribute rbd_bus_attrs[] = {
> __ATTR(add, S_IWUSR, NULL, rbd_add),
> @@ -951,11 +951,6 @@ static int rbd_dev_mapping_set(struct rbd_device
> *rbd_dev)
> rbd_dev->mapping.size = size;
> rbd_dev->mapping.features = features;
>
> - /* If we are mapping a snapshot it must be marked read-only */
> -
> - if (snap_id != CEPH_NOSNAP)
> - rbd_dev->mapping.read_only = true;
> -
> return 0;
> }
>
> @@ -963,7 +958,6 @@ static void rbd_dev_mapping_clear(struct rbd_device
> *rbd_dev)
> {
> rbd_dev->mapping.size = 0;
> rbd_dev->mapping.features = 0;
> - rbd_dev->mapping.read_only = true;
> }
>
> static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
> @@ -4620,7 +4614,7 @@ static int rbd_dev_probe_parent(struct rbd_device
> *rbd_dev)
> if (!parent)
> goto out_err;
>
> - ret = rbd_dev_image_probe(parent);
> + ret = rbd_dev_image_probe(parent, true);
> if (ret < 0)
> goto out_err;
> rbd_dev->parent = parent;
> @@ -4743,7 +4737,7 @@ static void rbd_dev_image_release(struct
> rbd_device *rbd_dev)
> * device. For format 2 images this includes determining the image
> * id.
> */
> -static int rbd_dev_image_probe(struct rbd_device *rbd_dev)
> +static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only)
> {
> int ret;
> int tmp;
> @@ -4778,6 +4772,12 @@ static int rbd_dev_image_probe(struct rbd_device
> *rbd_dev)
> if (ret)
> goto err_out_probe;
>
> + /* If we are mapping a snapshot it must be marked read-only */
> +
> + if (rbd_dev->spec->snap_id != CEPH_NOSNAP)
> + read_only = true;
> + rbd_dev->mapping.read_only = read_only;
> +
> ret = rbd_dev_probe_parent(rbd_dev);
> if (!ret)
> return 0;
> @@ -4811,6 +4811,7 @@ static ssize_t rbd_add(struct bus_type *bus,
> struct rbd_spec *spec = NULL;
> struct rbd_client *rbdc;
> struct ceph_osd_client *osdc;
> + bool read_only;
> int rc = -ENOMEM;
>
> if (!try_module_get(THIS_MODULE))
> @@ -4820,6 +4821,9 @@ static ssize_t rbd_add(struct bus_type *bus,
> rc = rbd_add_parse_args(buf, &ceph_opts, &rbd_opts, &spec);
> if (rc < 0)
> goto err_out_module;
> + read_only = rbd_opts->read_only;
> + kfree(rbd_opts);
> + rbd_opts = NULL; /* done with this */
>
> rbdc = rbd_get_client(ceph_opts);
> if (IS_ERR(rbdc)) {
> @@ -4850,11 +4854,7 @@ static ssize_t rbd_add(struct bus_type *bus,
> rbdc = NULL; /* rbd_dev now owns this */
> spec = NULL; /* rbd_dev now owns this */
>
> - rbd_dev->mapping.read_only = rbd_opts->read_only;
> - kfree(rbd_opts);
> - rbd_opts = NULL; /* done with this */
It looks like this was moved accidentally? Maybe needed
by a later patch?
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
> -
> - rc = rbd_dev_image_probe(rbd_dev);
> + rc = rbd_dev_image_probe(rbd_dev, read_only);
> if (rc < 0)
> goto err_out_rbd_dev;
>
next prev parent reply other threads:[~2013-05-07 22:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-07 1:36 [PATCH 0/6] rbd: miscellaneous cleanups Alex Elder
2013-05-07 1:37 ` [PATCH 1/6] rbd: update capacity in rbd_dev_refresh() Alex Elder
2013-05-07 22:49 ` Josh Durgin
2013-05-07 1:37 ` [PATCH 2/6] rbd: kill rbd_update_mapping_size() Alex Elder
2013-05-07 14:56 ` Josh Durgin
2013-05-07 15:41 ` Alex Elder
2013-05-07 1:37 ` [PATCH 3/6] rbd: don't print warning if not mapping a parent Alex Elder
2013-05-07 14:21 ` Josh Durgin
2013-05-07 1:38 ` [PATCH 4/6] rbd: don't look up snapshot id in rbd_dev_mapping_set() Alex Elder
2013-05-07 14:26 ` Josh Durgin
2013-05-07 1:38 ` [PATCH 5/6] rbd: kill rbd_dev_clear_mapping() Alex Elder
2013-05-07 14:26 ` Josh Durgin
2013-05-07 1:38 ` [PATCH 6/6] rbd: always set read-only flag in rbd_add() Alex Elder
2013-05-07 22:51 ` Josh Durgin [this message]
2013-05-08 12:50 ` 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=51898577.7040509@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox