From: Alex Elder <elder@inktank.com>
To: Josh Durgin <josh.durgin@inktank.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 1/4] rbd: define rbd_update_size()
Date: Tue, 09 Oct 2012 16:46:11 -0700 [thread overview]
Message-ID: <5074B743.6040601@inktank.com> (raw)
In-Reply-To: <5074B2F0.50008@inktank.com>
On 10/09/2012 04:27 PM, Josh Durgin wrote:
> On 10/09/2012 02:00 PM, Alex Elder wrote:
>> Encapsulate the code that handles the case where an image's size has
>> been found to have changed. This is done in anticipation of the
>> next patch, which will make this common code for format 1 and 2
>> images.
>>
>> Signed-off-by: Alex Elder <elder@inktank.com>
>> ---
>> drivers/block/rbd.c | 22 +++++++++++++---------
>> 1 file changed, 13 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
>> index bb3d9be..d36e6d7 100644
>> --- a/drivers/block/rbd.c
>> +++ b/drivers/block/rbd.c
>> @@ -1716,6 +1716,16 @@ static void __rbd_remove_all_snaps(struct
>> rbd_device *rbd_dev)
>> __rbd_remove_snap_dev(snap);
>> }
>>
>> +static void rbd_update_size(struct rbd_device *rbd_dev)
>> +{
>> + sector_t size = (sector_t) rbd_dev->header.image_size / SECTOR_SIZE;
>> +
>> + rbd_assert(rbd_dev->mapping.snap_id == CEPH_NOSNAP);
>
> I might be confused since it's been a while since I looked at these
> refactorings, but I think this should still be a conditional block
> instead of an assert.
>
> Even if we've only mapped a snapshot, the non-snapshot version could
> still be resized.
This function now only gets called if we find that the size
has changed as a result of a refresh. The assertion is to
verify that won't happen for a snapshot.
Since I'm returning a value here I may be able to be a little
less hardcore and return -EIO instead.
-Alex
>> + dout("setting size to %llu sectors", (unsigned long long) size);
>> + rbd_dev->mapping.size = (u64) size;
>> + set_capacity(rbd_dev->disk, size);
>> +}
>> +
>> /*
>> * only read the first part of the ondisk header, without the snaps
>> info
>> */
>> @@ -1731,15 +1741,9 @@ static int __rbd_refresh_header(struct rbd_device
>> *rbd_dev, u64 *hver)
>> down_write(&rbd_dev->header_rwsem);
>>
>> /* resized? */
>> - if (rbd_dev->mapping.snap_id == CEPH_NOSNAP) {
>> - sector_t size = (sector_t) h.image_size / SECTOR_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);
>> - }
>> + if (rbd_dev->header.image_size != h.image_size) {
>> + rbd_dev->header.image_size = h.image_size;
>> + rbd_update_size(rbd_dev);
>> }
>>
>> /* rbd_dev->header.object_prefix shouldn't change */
>
next prev parent reply other threads:[~2012-10-09 23:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-09 20:57 [PATCH 0/4] rbd: finish up basic format 2 support Alex Elder
2012-10-09 21:00 ` [PATCH 1/4] rbd: define rbd_update_size() Alex Elder
2012-10-09 23:27 ` Josh Durgin
2012-10-09 23:46 ` Alex Elder [this message]
2012-10-10 1:14 ` [PATCH 1/4, v2] rbd: define rbd_update_mapping_size() Alex Elder
2012-10-10 1:17 ` Josh Durgin
2012-10-09 21:00 ` [PATCH 2/4, v2] rbd: define rbd_dev_v2_refresh() Alex Elder
2012-10-09 23:30 ` Josh Durgin
2012-10-09 21:01 ` [PATCH 3/4] rbd: implement feature checks Alex Elder
2012-10-09 23:31 ` Josh Durgin
2012-10-09 21:01 ` [PATCH 4/4] rbd: activate v2 image support Alex Elder
2012-10-09 23:32 ` Josh Durgin
2012-10-10 15:55 ` [PATCH 0/4] rbd: finish up basic format 2 support Cláudio Martins
2012-10-10 16:29 ` Josh Durgin
2013-08-15 11:42 ` rbd: format 2 support in rbd.ko ? Kasper Dieter
2013-08-15 12:30 ` Damien Churchill
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=5074B743.6040601@inktank.com \
--to=elder@inktank.com \
--cc=ceph-devel@vger.kernel.org \
--cc=josh.durgin@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