Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373492
b: refs/heads/master
c: 6e584f5
h: refs/heads/master
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent cb1f831 commit b53eaa8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 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: 6087b51b9e7b311353408945bcc48368a54b8bbc
refs/heads/master: 6e584f5244060edc77141700d814a2af7d697685
30 changes: 14 additions & 16 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3427,46 +3427,44 @@ static struct rbd_snap *rbd_snap_create(struct rbd_device *rbd_dev,
u64 snap_features)
{
struct rbd_snap *snap;
int ret;

snap = kzalloc(sizeof (*snap), GFP_KERNEL);
if (!snap)
return ERR_PTR(-ENOMEM);

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

snap->name = snap_name;
snap->id = snap_id;
snap->size = snap_size;
snap->features = snap_features;

return snap;

err:
kfree(snap->name);
kfree(snap);

return ERR_PTR(ret);
}

/*
* Returns a dynamically-allocated snapshot name if successful, or a
* pointer-coded error otherwise.
*/
static char *rbd_dev_v1_snap_info(struct rbd_device *rbd_dev, u32 which,
u64 *snap_size, u64 *snap_features)
{
char *snap_name;
int i;

rbd_assert(which < rbd_dev->header.snapc->num_snaps);

*snap_size = rbd_dev->header.snap_sizes[which];
*snap_features = 0; /* No features for v1 */

/* Skip over names until we find the one we are looking for */

snap_name = rbd_dev->header.snap_names;
while (which--)
for (i = 0; i < which; i++)
snap_name += strlen(snap_name) + 1;

snap_name = kstrdup(snap_name, GFP_KERNEL);
if (!snap_name)
return ERR_PTR(-ENOMEM);

*snap_size = rbd_dev->header.snap_sizes[which];
*snap_features = 0; /* No features for v1 */

return snap_name;
}

Expand Down

0 comments on commit b53eaa8

Please sign in to comment.