All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: Josh Durgin <josh.durgin@inktank.com>,
	ceph-devel <ceph-devel@vger.kernel.org>
Subject: [PATCH 1/4, v2] rbd: define rbd_update_mapping_size()
Date: Tue, 09 Oct 2012 18:14:56 -0700	[thread overview]
Message-ID: <5074CC10.2010103@inktank.com> (raw)
In-Reply-To: <5074B2F0.50008@inktank.com>

Encapsulate the code that handles updating the size of a mapping
after an rbd image has been refreshed.  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>
---
Changed since v1:
- renamed renamed the function to include "mapping"
- now call the function unconditionally--whether or not
   the size has changed, and only update the mapping if
   the mapping is to the base image.

  drivers/block/rbd.c |   27 ++++++++++++++++-----------
  1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index bb3d9be..b64125d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1716,6 +1716,19 @@ static void __rbd_remove_all_snaps(struct 
rbd_device *rbd_dev)
  		__rbd_remove_snap_dev(snap);
  }

+static void rbd_update_mapping_size(struct rbd_device *rbd_dev)
+{
+	sector_t size;
+
+	if (rbd_dev->mapping.snap_id != CEPH_NOSNAP)
+		return;
+
+	size = (sector_t) rbd_dev->header.image_size / SECTOR_SIZE;
+	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
   */
@@ -1730,17 +1743,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);
-		}
-	}
+	/* Update image size, and check for resize of mapped image */
+	rbd_dev->header.image_size = h.image_size;
+	rbd_update_mapping_size(rbd_dev);

  	/* rbd_dev->header.object_prefix shouldn't change */
  	kfree(rbd_dev->header.snap_sizes);
-- 
1.7.9.5


  parent reply	other threads:[~2012-10-10  1:14 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
2012-10-10  1:14     ` Alex Elder [this message]
2012-10-10  1:17       ` [PATCH 1/4, v2] rbd: define rbd_update_mapping_size() 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=5074CC10.2010103@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.