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 6/7] rbd: do some header initialization earlier
Date: Fri, 07 Sep 2012 13:32:00 -0700	[thread overview]
Message-ID: <504A59C0.1080707@inktank.com> (raw)
In-Reply-To: <5049FA9D.5050504@inktank.com>

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

On 09/07/2012 06:46 AM, Alex Elder wrote:
> Move some of the code that initializes an rbd header out of
> rbd_init_disk() and into its caller.
>
> Move the code at the end of rbd_init_disk() that sets the device
> capacity and activates the Linux device out of that function and
> into the caller, ensuring we still have the disk size available
> where we need it.
>
> Update rbd_free_disk() so it still aligns well as an inverse of
> rbd_init_disk(), moving the rbd_header_free() call out to its
> caller.
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   drivers/block/rbd.c |   51
> +++++++++++++++++++++++++++------------------------
>   1 file changed, 27 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 46b8f8e..6e735a7 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -1652,8 +1652,6 @@ static void rbd_free_disk(struct rbd_device *rbd_dev)
>   	if (!disk)
>   		return;
>
> -	rbd_header_free(&rbd_dev->header);
> -
>   	if (disk->flags & GENHD_FL_UP)
>   		del_gendisk(disk);
>   	if (disk->queue)
> @@ -1875,20 +1873,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
>   	int rc;
>   	u64 segment_size;
>
> -	/* contact OSD, request size info about the object being mapped */
> -	rc = rbd_read_header(rbd_dev, &rbd_dev->header);
> -	if (rc)
> -		return rc;
> -
> -	/* no need to lock here, as rbd_dev is not registered yet */
> -	rc = rbd_dev_snap_devs_update(rbd_dev);
> -	if (rc)
> -		return rc;
> -
> -	rc = rbd_header_set_snap(rbd_dev, snap_name);
> -	if (rc)
> -		return rc;
> -
>   	/* create gendisk info */
>   	rc = -ENOMEM;
>   	disk = alloc_disk(RBD_MINORS_PER_MAJOR);
> @@ -1925,12 +1909,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
>
>   	rbd_dev->disk = disk;
>
> -	/* finally, announce the disk to the world */
> -	set_capacity(disk, (sector_t) rbd_dev->mapping.size / SECTOR_SIZE);
> -	add_disk(disk);
> -
> -	pr_info("%s: added with size 0x%llx\n",
> -		disk->disk_name, (unsigned long long) rbd_dev->mapping.size);
>   	return 0;
>
>   out_disk:
> @@ -2622,13 +2600,35 @@ static ssize_t rbd_add(struct bus_type *bus,
>   	/*
>   	 * At this point cleanup in the event of an error is the job
>   	 * of the sysfs code (initiated by rbd_bus_del_dev()).
> -	 *
> -	 * Set up and announce blkdev mapping.
>   	 */
> +
> +	/* contact OSD, request size info about the object being mapped */
> +	rc = rbd_read_header(rbd_dev, &rbd_dev->header);
> +	if (rc)
> +		goto err_out_bus;
> +
> +	/* no need to lock here, as rbd_dev is not registered yet */
> +	rc = rbd_dev_snap_devs_update(rbd_dev);
> +	if (rc)
> +		goto err_out_bus;
> +
> +	rc = rbd_header_set_snap(rbd_dev, snap_name);
> +	if (rc)
> +		goto err_out_bus;
> +
> +	/* Set up the blkdev mapping. */
> +
>   	rc = rbd_init_disk(rbd_dev);
>   	if (rc)
>   		goto err_out_bus;
>
> +	/* Everything's ready.  Announce the disk to the world. */
> +
> +	set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
> +	add_disk(rbd_dev->disk);
> +	pr_info("%s: added with size 0x%llx\n", rbd_dev->disk->disk_name,
> +		(unsigned long long) rbd_dev->mapping.size);
> +
>   	rc = rbd_init_watch_dev(rbd_dev);
>   	if (rc)
>   		goto err_out_bus;
> @@ -2700,6 +2700,9 @@ static void rbd_dev_release(struct device *dev)
>   	rbd_free_disk(rbd_dev);
>   	unregister_blkdev(rbd_dev->major, rbd_dev->name);
>
> +	/* release allocated disk header fields */
> +	rbd_header_free(&rbd_dev->header);
> +
>   	/* done with the id, and with the rbd_dev */
>   	kfree(rbd_dev->mapping.snap_name);
>   	kfree(rbd_dev->header_name);
>


  reply	other threads:[~2012-09-07 20:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07 13:40 [PATCH 0/7] rbd: isolate mapping info, rearrange init Alex Elder
2012-09-07 13:45 ` [PATCH 1/7] rbd: separate mapping info in rbd_dev Alex Elder
2012-09-07 18:58   ` Josh Durgin
2012-09-07 21:51     ` Alex Elder
2012-09-07 13:45 ` [PATCH 2/7] rbd: record mapped size Alex Elder
2012-09-07 19:10   ` Josh Durgin
2012-09-07 21:52     ` Alex Elder
2012-09-07 13:45 ` [PATCH 3/7] rbd: return snap name from rbd_add_parse_args() Alex Elder
2012-09-07 19:32   ` Josh Durgin
2012-09-07 13:45 ` [PATCH 4/7] rbd: set mapping name with the rest Alex Elder
2012-09-07 19:39   ` Josh Durgin
2012-09-07 13:45 ` [PATCH 5/7] rbd: simplify snap_by_name() interface Alex Elder
2012-09-07 19:41   ` Josh Durgin
2012-09-07 13:46 ` [PATCH 6/7] rbd: do some header initialization earlier Alex Elder
2012-09-07 20:32   ` Josh Durgin [this message]
2012-09-07 13:46 ` [PATCH 7/7] rbd: simplify rbd_init_disk() a bit Alex Elder
2012-09-07 20:32   ` 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=504A59C0.1080707@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