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 1/6] rbd: update capacity in rbd_dev_refresh()
Date: Tue, 07 May 2013 15:49:24 -0700	[thread overview]
Message-ID: <518984F4.5030509@inktank.com> (raw)
In-Reply-To: <51885AD8.1050105@inktank.com>

On 05/06/2013 06:37 PM, Alex Elder wrote:
> When a mapped image changes size, we change the capacity recorded
> for the Linux disk associated with it, in rbd_update_mapping_size().
> That function is called in two places--the format 1 and format 2
> refresh routines.
>
> There is no need to set the capacity while holding the header
> semaphore.  Instead, do it in the common rbd_dev_refresh(), using
> the logic that's already there to initiate disk revalidation.
>
> Add handling in the request function, just in case a request
> that exceeds the capacity of the device comes in (perhaps one
> that was started before a refresh shrunk the device).
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   drivers/block/rbd.c |   23 +++++++++++++++--------
>   1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 5d5e3f0..a0f1fe5 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -2874,6 +2874,13 @@ static void rbd_request_fn(struct request_queue *q)
>   			goto end_request;	/* Shouldn't happen */
>   		}
>
> +		result = -ENOSPC;

blk-core.c usually uses -EIO for this case. That's more expected from a
read anyway, so I think -EIO would be better.

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

> +		if (offset + length > rbd_dev->mapping.size) {
> +			rbd_warn(rbd_dev, "beyond EOD (%llu~%llu > %llu)\n",
> +				offset, length, rbd_dev->mapping.size);
> +			goto end_request;
> +		}
> +
>   		result = -ENOMEM;
>   		img_request = rbd_img_request_create(rbd_dev, offset, length,
>   							write_request, false);
> @@ -3116,14 +3123,8 @@ static void rbd_update_mapping_size(struct
> rbd_device *rbd_dev)
>   	if (rbd_dev->spec->snap_id != CEPH_NOSNAP)
>   		return;
>
> -	if (rbd_dev->mapping.size != rbd_dev->header.image_size) {
> -		sector_t size;
> -
> +	if (rbd_dev->mapping.size != rbd_dev->header.image_size)
>   		rbd_dev->mapping.size = rbd_dev->header.image_size;
> -		size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE;
> -		dout("setting size to %llu sectors", (unsigned long long)size);
> -		set_capacity(rbd_dev->disk, size);
> -	}
>   }
>
>   /*
> @@ -3200,8 +3201,14 @@ static int rbd_dev_refresh(struct rbd_device
> *rbd_dev)
>
>   	rbd_exists_validate(rbd_dev);
>   	mutex_unlock(&ctl_mutex);
> -	if (mapping_size != rbd_dev->mapping.size)
> +	if (mapping_size != rbd_dev->mapping.size) {
> +		sector_t size;
> +
> +		size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE;
> +		dout("setting size to %llu sectors", (unsigned long long)size);
> +		set_capacity(rbd_dev->disk, size);
>   		revalidate_disk(rbd_dev->disk);
> +	}
>
>   	return ret;
>   }
>


  reply	other threads:[~2013-05-07 22:50 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 [this message]
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
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=518984F4.5030509@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