aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-07-10 21:30:11 -0400
committerAlex Elder <elder@inktank.com>2012-10-01 15:30:53 -0400
commitc8d184250d8a47b1a958affcffe3ffdd85644301 (patch)
tree9ee8e260c00a8e798d6daef6d00001dd0793a0bb /drivers/block/rbd.c
parent02cdb02ceab1f3dd9ac2bc899fc51f0e0e744782 (diff)
rbd: don't use index in __rbd_add_snap_dev()
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> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e453f8cc8949..8ac193ff4849 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2036,7 +2036,8 @@ static int rbd_register_snap_dev(struct rbd_snap *snap,
2036} 2036}
2037 2037
2038static struct rbd_snap *__rbd_add_snap_dev(struct rbd_device *rbd_dev, 2038static struct rbd_snap *__rbd_add_snap_dev(struct rbd_device *rbd_dev,
2039 int i, const char *name) 2039 const char *snap_name,
2040 u64 snap_id, u64 snap_size)
2040{ 2041{
2041 struct rbd_snap *snap; 2042 struct rbd_snap *snap;
2042 int ret; 2043 int ret;
@@ -2046,12 +2047,12 @@ static struct rbd_snap *__rbd_add_snap_dev(struct rbd_device *rbd_dev,
2046 return ERR_PTR(-ENOMEM); 2047 return ERR_PTR(-ENOMEM);
2047 2048
2048 ret = -ENOMEM; 2049 ret = -ENOMEM;
2049 snap->name = kstrdup(name, GFP_KERNEL); 2050 snap->name = kstrdup(snap_name, GFP_KERNEL);
2050 if (!snap->name) 2051 if (!snap->name)
2051 goto err; 2052 goto err;
2052 2053
2053 snap->size = rbd_dev->header.snap_sizes[i]; 2054 snap->id = snap_id;
2054 snap->id = rbd_dev->header.snapc->snaps[i]; 2055 snap->size = snap_size;
2055 2056
2056 return snap; 2057 return snap;
2057 2058
@@ -2116,12 +2117,13 @@ static int rbd_dev_snaps_update(struct rbd_device *rbd_dev)
2116 dout("entry %u: snap_id = %llu\n", (unsigned int) snap_count, 2117 dout("entry %u: snap_id = %llu\n", (unsigned int) snap_count,
2117 (unsigned long long) snap_id); 2118 (unsigned long long) snap_id);
2118 if (!snap || (snap_id != CEPH_NOSNAP && snap->id < snap_id)) { 2119 if (!snap || (snap_id != CEPH_NOSNAP && snap->id < snap_id)) {
2120 struct rbd_image_header *header = &rbd_dev->header;
2119 struct rbd_snap *new_snap; 2121 struct rbd_snap *new_snap;
2120 2122
2121 /* We haven't seen this snapshot before */ 2123 /* We haven't seen this snapshot before */
2122 2124
2123 new_snap = __rbd_add_snap_dev(rbd_dev, index, 2125 new_snap = __rbd_add_snap_dev(rbd_dev, snap_name,
2124 snap_name); 2126 snap_id, header->snap_sizes[index]);
2125 if (IS_ERR(new_snap)) { 2127 if (IS_ERR(new_snap)) {
2126 int err = PTR_ERR(new_snap); 2128 int err = PTR_ERR(new_snap);
2127 2129