CEPH filesystem development
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 1/4] rbd: define rbd_update_size()
Date: Tue, 09 Oct 2012 14:00:36 -0700	[thread overview]
Message-ID: <50749074.5030603@inktank.com> (raw)
In-Reply-To: <50748FA5.4030508@inktank.com>

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);
+	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 */
-- 
1.7.9.5


  reply	other threads:[~2012-10-09 21:00 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 ` Alex Elder [this message]
2012-10-09 23:27   ` [PATCH 1/4] rbd: define rbd_update_size() Josh Durgin
2012-10-09 23:46     ` Alex Elder
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=50749074.5030603@inktank.com \
    --to=elder@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    /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