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 2/7] rbd: record mapped size
Date: Fri, 07 Sep 2012 12:10:22 -0700	[thread overview]
Message-ID: <504A469E.2030203@inktank.com> (raw)
In-Reply-To: <5049FA71.1020809@inktank.com>

On 09/07/2012 06:45 AM, Alex Elder wrote:
> Add the size of the mapped image to the set of mapping-specific
> fields in an rbd_device, and use it when setting the capacity of the
> disk.
>
> Rename the "seq" argument to snap_by_name() to be "snap_id" to be
> consistent with other usage.

This doesn't seem to be part of this commit anymore.
Assuming the commit message is fixed,

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

>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   drivers/block/rbd.c |   27 ++++++++++++++-------------
>   1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index dff6210..4377a83 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -151,6 +151,7 @@ struct rbd_snap {
>   struct rbd_mapping {
>   	char                    *snap_name;
>   	u64                     snap_id;
> +	u64                     size;
>   	bool                    snap_exists;
>   	bool			read_only;
>   };
> @@ -643,7 +644,7 @@ static int snap_by_name(struct rbd_image_header
> *header, const char *snap_name,
>   	return -ENOENT;
>   }
>
> -static int rbd_header_set_snap(struct rbd_device *rbd_dev, u64 *size)
> +static int rbd_header_set_snap(struct rbd_device *rbd_dev)
>   {
>   	int ret;
>
> @@ -652,19 +653,16 @@ static int rbd_header_set_snap(struct rbd_device
> *rbd_dev, u64 *size)
>   	if (!memcmp(rbd_dev->mapping.snap_name, RBD_SNAP_HEAD_NAME,
>   		    sizeof (RBD_SNAP_HEAD_NAME))) {
>   		rbd_dev->mapping.snap_id = CEPH_NOSNAP;
> +		rbd_dev->mapping.size = rbd_dev->header.image_size;
>   		rbd_dev->mapping.snap_exists = false;
>   		rbd_dev->mapping.read_only = rbd_dev->rbd_opts.read_only;
> -		if (size)
> -			*size = rbd_dev->header.image_size;
>   	} else {
> -		u64 snap_id = 0;
> -
>   		ret = snap_by_name(&rbd_dev->header,
>   					rbd_dev->mapping.snap_name,
> -					&snap_id, size);
> +					&rbd_dev->mapping.snap_id,
> +					&rbd_dev->mapping.size);
>   		if (ret < 0)
>   			goto done;
> -		rbd_dev->mapping.snap_id = snap_id;
>   		rbd_dev->mapping.snap_exists = true;
>   		rbd_dev->mapping.read_only = true;
>   	}
> @@ -1830,8 +1828,12 @@ static int __rbd_refresh_header(struct rbd_device
> *rbd_dev, u64 *hver)
>   	if (rbd_dev->mapping.snap_id == CEPH_NOSNAP) {
>   		sector_t size = (sector_t) h.image_size / SECTOR_SIZE;
>
> -		dout("setting size to %llu sectors", (unsigned long long) size);
> -		set_capacity(rbd_dev->disk, size);
> +		if (size != (sector_t) rbd_dev->mapping.size) {
> +			dout("setting size to %llu sectors",
> +				(unsigned long long) size);
> +			rbd_dev->mapping.size = (u64) size;
> +			set_capacity(rbd_dev->disk, size);
> +		}
>   	}
>
>   	/* rbd_dev->header.object_prefix shouldn't change */
> @@ -1875,7 +1877,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
>   	struct request_queue *q;
>   	int rc;
>   	u64 segment_size;
> -	u64 total_size = 0;
>
>   	/* contact OSD, request size info about the object being mapped */
>   	rc = rbd_read_header(rbd_dev, &rbd_dev->header);
> @@ -1887,7 +1888,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
>   	if (rc)
>   		return rc;
>
> -	rc = rbd_header_set_snap(rbd_dev, &total_size);
> +	rc = rbd_header_set_snap(rbd_dev);
>   	if (rc)
>   		return rc;
>
> @@ -1928,11 +1929,11 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
>   	rbd_dev->disk = disk;
>
>   	/* finally, announce the disk to the world */
> -	set_capacity(disk, total_size / SECTOR_SIZE);
> +	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)total_size);
> +		disk->disk_name, (unsigned long long) rbd_dev->mapping.size);
>   	return 0;
>
>   out_disk:
>


  reply	other threads:[~2012-09-07 19:10 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 [this message]
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
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=504A469E.2030203@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