Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373498
b: refs/heads/master
c: e1d4213
h: refs/heads/master
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent f207303 commit c087c8d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8b0241f85ab11c87075f9de0191acd8b546c6f6a
refs/heads/master: e1d4213f090644b06aab6ea70e307ecf16182148
26 changes: 22 additions & 4 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,6 @@ static int rbd_dev_set_mapping(struct rbd_device *rbd_dev)
{
if (!memcmp(rbd_dev->spec->snap_name, RBD_SNAP_HEAD_NAME,
sizeof (RBD_SNAP_HEAD_NAME))) {
rbd_dev->spec->snap_id = CEPH_NOSNAP;
rbd_dev->mapping.size = rbd_dev->header.image_size;
rbd_dev->mapping.features = rbd_dev->header.features;
} else {
Expand All @@ -855,7 +854,6 @@ static int rbd_dev_set_mapping(struct rbd_device *rbd_dev)
snap = snap_by_name(rbd_dev, rbd_dev->spec->snap_name);
if (!snap)
return -ENOENT;
rbd_dev->spec->snap_id = snap->id;
rbd_dev->mapping.size = snap->size;
rbd_dev->mapping.features = snap->features;
rbd_dev->mapping.read_only = true;
Expand Down Expand Up @@ -3760,6 +3758,10 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
* rbd_dev_snaps_update() has completed because some of the
* information (in particular, snapshot name) is not available
* until then.
*
* When an image being mapped (not a parent) is probed, we have the
* pool name and pool id, image name and image id, and the snapshot
* name. The only thing we're missing is the snapshot id.
*/
static int rbd_dev_probe_update_spec(struct rbd_device *rbd_dev)
{
Expand All @@ -3768,8 +3770,24 @@ static int rbd_dev_probe_update_spec(struct rbd_device *rbd_dev)
void *reply_buf = NULL;
int ret;

if (rbd_dev->spec->pool_name)
return 0; /* Already have the names */
/*
* An image being mapped will have the pool name (etc.), but
* we need to look up the snapshot id.
*/
if (rbd_dev->spec->pool_name) {
if (strcmp(rbd_dev->spec->snap_name, RBD_SNAP_HEAD_NAME)) {
struct rbd_snap *snap;

snap = snap_by_name(rbd_dev, rbd_dev->spec->snap_name);
if (!snap)
return -ENOENT;
rbd_dev->spec->snap_id = snap->id;
} else {
rbd_dev->spec->snap_id = CEPH_NOSNAP;
}

return 0;
}

/* Look up the pool name */

Expand Down

0 comments on commit c087c8d

Please sign in to comment.