All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 1/3] rbd: don't use index in __rbd_add_snap_dev()
Date: Fri, 07 Sep 2012 14:24:54 -0500	[thread overview]
Message-ID: <504A4A06.8050101@inktank.com> (raw)
In-Reply-To: <504A498D.30708@inktank.com>

Pass the snapshot id and snapshot size rather than an index
to __rbd_add_snap_dev() to specify values for a new snapshot.

Signed-off-by: Alex Elder <elder@inktank.com>
---
 drivers/block/rbd.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index d73edb1..2b048e3 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2031,7 +2031,8 @@ static int rbd_register_snap_dev(struct rbd_snap
*snap,
 }

 static struct rbd_snap *__rbd_add_snap_dev(struct rbd_device *rbd_dev,
-					      int i, const char *name)
+						const char *snap_name,
+						u64 snap_id, u64 snap_size)
 {
 	struct rbd_snap *snap;
 	int ret;
@@ -2041,12 +2042,12 @@ static struct rbd_snap
*__rbd_add_snap_dev(struct rbd_device *rbd_dev,
 		return ERR_PTR(-ENOMEM);

 	ret = -ENOMEM;
-	snap->name = kstrdup(name, GFP_KERNEL);
+	snap->name = kstrdup(snap_name, GFP_KERNEL);
 	if (!snap->name)
 		goto err;

-	snap->size = rbd_dev->header.snap_sizes[i];
-	snap->id = rbd_dev->header.snapc->snaps[i];
+	snap->id = snap_id;
+	snap->size = snap_size;

 	return snap;

@@ -2111,12 +2112,13 @@ static int rbd_dev_snaps_update(struct
rbd_device *rbd_dev)
 		dout("entry %u: snap_id = %llu\n", (unsigned int) snap_count,
 			(unsigned long long) snap_id);
 		if (!snap || (snap_id != CEPH_NOSNAP && snap->id < snap_id)) {
+			struct rbd_image_header	*header = &rbd_dev->header;
 			struct rbd_snap *new_snap;

 			/* We haven't seen this snapshot before */

-			new_snap = __rbd_add_snap_dev(rbd_dev, index,
-							snap_name);
+			new_snap = __rbd_add_snap_dev(rbd_dev, snap_name,
+					snap_id, header->snap_sizes[index]);
 			if (IS_ERR(new_snap)) {
 				int err = PTR_ERR(new_snap);

-- 
1.7.9.5


  reply	other threads:[~2012-09-07 19:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07 19:22 [PATCH 0/3] rbd: hide some snapshot info details Alex Elder
2012-09-07 19:24 ` Alex Elder [this message]
2012-09-11 22:49   ` [PATCH 1/3] rbd: don't use index in __rbd_add_snap_dev() Josh Durgin
2012-09-07 19:25 ` [PATCH 2/3] rbd: add an rbd features field Alex Elder
2012-09-11 22:58   ` Josh Durgin
2012-09-07 19:25 ` [PATCH 3/3] rbd: encapsulate code that gets snapshot info Alex Elder
2012-09-11 23:14   ` 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=504A4A06.8050101@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 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.