CEPH filesystem development
 help / color / mirror / Atom feed
From: Josh Durgin <josh.durgin@inktank.com>
To: Alex Elder <elder@inktank.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 3/8] rbd: remove snap_name arg from rbd_add_parse_args()
Date: Mon, 29 Oct 2012 14:26:05 -0700	[thread overview]
Message-ID: <508EF46D.3090208@inktank.com> (raw)
In-Reply-To: <508B1653.7000709@inktank.com>

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 10/26/2012 04:01 PM, Alex Elder wrote:
> The snapshot name returned by rbd_add_parse_args() just gets saved
> in the rbd_dev eventually.  So just do that inside that function and
> do away with the snap_name argument, both in rbd_add_parse_args()
> and rbd_dev_set_mapping().
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   drivers/block/rbd.c |   23 ++++++++++-------------
>   1 file changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index f900f3b..948a084 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -665,23 +665,22 @@ static int snap_by_name(struct rbd_device
> *rbd_dev, const char *snap_name)
>   	return -ENOENT;
>   }
>
> -static int rbd_dev_set_mapping(struct rbd_device *rbd_dev, char *snap_name)
> +static int rbd_dev_set_mapping(struct rbd_device *rbd_dev)
>   {
>   	int ret;
>
> -	if (!memcmp(snap_name, RBD_SNAP_HEAD_NAME,
> +	if (!memcmp(rbd_dev->snap_name, RBD_SNAP_HEAD_NAME,
>   		    sizeof (RBD_SNAP_HEAD_NAME))) {
>   		rbd_dev->snap_id = CEPH_NOSNAP;
>   		rbd_dev->mapping.size = rbd_dev->header.image_size;
>   		rbd_dev->mapping.features = rbd_dev->header.features;
>   		ret = 0;
>   	} else {
> -		ret = snap_by_name(rbd_dev, snap_name);
> +		ret = snap_by_name(rbd_dev, rbd_dev->snap_name);
>   		if (ret < 0)
>   			goto done;
>   		rbd_dev->mapping.read_only = true;
>   	}
> -	rbd_dev->snap_name = snap_name;
>   	rbd_dev->exists = true;
>   done:
>   	return ret;
> @@ -2843,8 +2842,7 @@ static inline char *dup_token(const char **buf,
> size_t *lenp)
>    * Note: rbd_dev is assumed to have been initially zero-filled.
>    */
>   static struct ceph_options *rbd_add_parse_args(struct rbd_device *rbd_dev,
> -						const char *buf,
> -						char **snap_name)
> +						const char *buf)
>   {
>   	size_t len;
>   	const char *mon_addrs;
> @@ -2893,11 +2891,11 @@ static struct ceph_options
> *rbd_add_parse_args(struct rbd_device *rbd_dev,
>   		err_ptr = ERR_PTR(-ENAMETOOLONG);
>   		goto out_err;
>   	}
> -	*snap_name = kmalloc(len + 1, GFP_KERNEL);
> -	if (!*snap_name)
> +	rbd_dev->snap_name = kmalloc(len + 1, GFP_KERNEL);
> +	if (!rbd_dev->snap_name)
>   		goto out_mem;
> -	memcpy(*snap_name, buf, len);
> -	*(*snap_name + len) = '\0';
> +	memcpy(rbd_dev->snap_name, buf, len);
> +	*(rbd_dev->snap_name + len) = '\0';
>
>   	/* Initialize all rbd options to the defaults */
>
> @@ -3132,7 +3130,6 @@ static ssize_t rbd_add(struct bus_type *bus,
>   		       size_t count)
>   {
>   	struct rbd_device *rbd_dev = NULL;
> -	char *snap_name;
>   	struct ceph_options *ceph_opts;
>   	struct ceph_osd_client *osdc;
>   	int rc = -ENOMEM;
> @@ -3151,7 +3148,7 @@ static ssize_t rbd_add(struct bus_type *bus,
>   	init_rwsem(&rbd_dev->header_rwsem);
>
>   	/* parse add command */
> -	ceph_opts = rbd_add_parse_args(rbd_dev, buf, &snap_name);
> +	ceph_opts = rbd_add_parse_args(rbd_dev, buf);
>   	if (IS_ERR(ceph_opts)) {
>   		rc = PTR_ERR(ceph_opts);
>   		goto err_out_mem;
> @@ -3178,7 +3175,7 @@ static ssize_t rbd_add(struct bus_type *bus,
>   	if (rc)
>   		goto err_out_probe;
>
> -	rc = rbd_dev_set_mapping(rbd_dev, snap_name);
> +	rc = rbd_dev_set_mapping(rbd_dev);
>   	if (rc)
>   		goto err_out_snaps;
>


  reply	other threads:[~2012-10-29 21:26 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26 22:42 Another pile of patches Alex Elder
2012-10-26 22:44 ` [PATCH, resend] rbd: simplify rbd_rq_fn() Alex Elder
2012-10-29 20:29   ` Josh Durgin
2012-10-30 12:01     ` Alex Elder
2012-10-26 22:45 ` [PATCH] rbd: remove snapshots on error in rbd_add() Alex Elder
2012-10-29 20:36   ` Josh Durgin
2012-10-26 22:45 ` [PATCH] rbd: make pool_id a 64 bit value Alex Elder
2012-10-29 20:40   ` Josh Durgin
2012-10-26 22:48 ` [PATCH 0/2] rbd: mapping structure changes Alex Elder
2012-10-26 22:51   ` [PATCH 1/2] rbd: move snap info out of rbd_mapping struct Alex Elder
2012-10-29 20:43     ` Josh Durgin
2012-10-26 22:51   ` [PATCH 2/2] rbd: rename snap_exists field Alex Elder
2012-10-29 20:46     ` Josh Durgin
2012-10-26 22:52 ` [PATCH 0/2] rbd: consolidate argument parsing Alex Elder
2012-10-26 22:55   ` [PATCH 1/2] rbd: move ceph_parse_options() call up Alex Elder
2012-10-29 21:08     ` Josh Durgin
2012-10-26 22:55   ` [PATCH 2/2] rbd: do all argument parsing in one place Alex Elder
2012-10-29 21:13     ` Josh Durgin
2012-10-26 22:56 ` [PATCH 0/8] rbd: have rbd_add_parse_args() only parse args Alex Elder
2012-10-26 23:00   ` [PATCH 1/8] rbd: get rid of snap_name_len Alex Elder
2012-10-29 21:14     ` Josh Durgin
2012-10-26 23:00   ` [PATCH 2/8] rbd: remove options args from rbd_add_parse_args() Alex Elder
2012-10-29 21:17     ` Josh Durgin
2012-10-26 23:01   ` [PATCH 3/8] rbd: remove snap_name arg " Alex Elder
2012-10-29 21:26     ` Josh Durgin [this message]
2012-10-26 23:02   ` [PATCH 4/8] rbd: pass and populate rbd_options structure Alex Elder
2012-10-29 21:27     ` Josh Durgin
2012-10-26 23:02   ` [PATCH 5/8] rbd: have rbd_add_parse_args() return error Alex Elder
2012-10-29 21:28     ` Josh Durgin
2012-10-26 23:03   ` [PATCH 6/8] rbd: define image specification structure Alex Elder
2012-10-29 22:13     ` Josh Durgin
2012-10-30 12:40       ` Alex Elder
2012-10-30 20:13         ` Josh Durgin
2012-10-26 23:03   ` [PATCH 7/8] rbd: add reference counting to rbd_spec Alex Elder
2012-10-29 22:20     ` Josh Durgin
2012-10-30 12:59       ` Alex Elder
2012-10-30 20:17         ` Josh Durgin
2012-10-26 23:03   ` [PATCH 8/8] rbd: fill rbd_spec in rbd_add_parse_args() Alex Elder
2012-10-29 22:30     ` Josh Durgin
2012-10-30 13:09       ` Alex Elder
2012-10-30 20:18         ` Josh Durgin

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=508EF46D.3090208@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