aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-08-24 00:48:49 -0400
committerAlex Elder <elder@inktank.com>2012-10-01 15:30:50 -0400
commit9fcbb80024795dc1a282f11af593ae5aa3d1b67e (patch)
tree2d13303313f687016b43e90491b73db43994b0e0 /drivers/block/rbd.c
parente28393082dd3991156d12a9e64b9584cef28fe25 (diff)
rbd: rename __rbd_init_snaps_header()
The name __rbd_init_snaps_header() doesn't really convey what that function does very well. Its purpose is to scan a new snapshot context and either create or destroy snapshot device entries so that local host's view is consistent with the reality maintained on the OSDs. This patch just changes the name of this function, to be rbd_dev_snap_devs_update(). Still not perfect, but I think better. Also add some dynamic debug statements to this function. 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.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 8cb8e0abfb33..77263681dde2 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -201,7 +201,7 @@ static DEFINE_SPINLOCK(rbd_dev_list_lock);
201static LIST_HEAD(rbd_client_list); /* clients */ 201static LIST_HEAD(rbd_client_list); /* clients */
202static DEFINE_SPINLOCK(rbd_client_list_lock); 202static DEFINE_SPINLOCK(rbd_client_list_lock);
203 203
204static int __rbd_init_snaps_header(struct rbd_device *rbd_dev); 204static int rbd_dev_snap_devs_update(struct rbd_device *rbd_dev);
205static void rbd_dev_release(struct device *dev); 205static void rbd_dev_release(struct device *dev);
206static ssize_t rbd_snap_add(struct device *dev, 206static ssize_t rbd_snap_add(struct device *dev,
207 struct device_attribute *attr, 207 struct device_attribute *attr,
@@ -1848,7 +1848,7 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
1848 WARN_ON(strcmp(rbd_dev->header.object_prefix, h.object_prefix)); 1848 WARN_ON(strcmp(rbd_dev->header.object_prefix, h.object_prefix));
1849 kfree(h.object_prefix); 1849 kfree(h.object_prefix);
1850 1850
1851 ret = __rbd_init_snaps_header(rbd_dev); 1851 ret = rbd_dev_snap_devs_update(rbd_dev);
1852 1852
1853 up_write(&rbd_dev->header_rwsem); 1853 up_write(&rbd_dev->header_rwsem);
1854 1854
@@ -1880,7 +1880,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
1880 return rc; 1880 return rc;
1881 1881
1882 /* no need to lock here, as rbd_dev is not registered yet */ 1882 /* no need to lock here, as rbd_dev is not registered yet */
1883 rc = __rbd_init_snaps_header(rbd_dev); 1883 rc = rbd_dev_snap_devs_update(rbd_dev);
1884 if (rc) 1884 if (rc)
1885 return rc; 1885 return rc;
1886 1886
@@ -2184,7 +2184,7 @@ err:
2184 * snapshot id, highest id first. (Snapshots in the rbd_dev's list 2184 * snapshot id, highest id first. (Snapshots in the rbd_dev's list
2185 * are also maintained in that order.) 2185 * are also maintained in that order.)
2186 */ 2186 */
2187static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) 2187static int rbd_dev_snap_devs_update(struct rbd_device *rbd_dev)
2188{ 2188{
2189 struct ceph_snap_context *snapc = rbd_dev->header.snapc; 2189 struct ceph_snap_context *snapc = rbd_dev->header.snapc;
2190 const u32 snap_count = snapc->num_snaps; 2190 const u32 snap_count = snapc->num_snaps;
@@ -2193,6 +2193,7 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev)
2193 struct list_head *links = head->next; 2193 struct list_head *links = head->next;
2194 u32 index = 0; 2194 u32 index = 0;
2195 2195
2196 dout("%s: snap count is %u\n", __func__, (unsigned int) snap_count);
2196 while (index < snap_count || links != head) { 2197 while (index < snap_count || links != head) {
2197 u64 snap_id; 2198 u64 snap_id;
2198 struct rbd_snap *snap; 2199 struct rbd_snap *snap;
@@ -2211,6 +2212,9 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev)
2211 if (rbd_dev->snap_id == snap->id) 2212 if (rbd_dev->snap_id == snap->id)
2212 rbd_dev->snap_exists = false; 2213 rbd_dev->snap_exists = false;
2213 __rbd_remove_snap_dev(snap); 2214 __rbd_remove_snap_dev(snap);
2215 dout("%ssnap id %llu has been removed\n",
2216 rbd_dev->snap_id == snap->id ? "mapped " : "",
2217 (unsigned long long) snap->id);
2214 2218
2215 /* Done with this list entry; advance */ 2219 /* Done with this list entry; advance */
2216 2220
@@ -2218,6 +2222,8 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev)
2218 continue; 2222 continue;
2219 } 2223 }
2220 2224
2225 dout("entry %u: snap_id = %llu\n", (unsigned int) snap_count,
2226 (unsigned long long) snap_id);
2221 if (!snap || (snap_id != CEPH_NOSNAP && snap->id < snap_id)) { 2227 if (!snap || (snap_id != CEPH_NOSNAP && snap->id < snap_id)) {
2222 struct rbd_snap *new_snap; 2228 struct rbd_snap *new_snap;
2223 2229
@@ -2225,11 +2231,17 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev)
2225 2231
2226 new_snap = __rbd_add_snap_dev(rbd_dev, index, 2232 new_snap = __rbd_add_snap_dev(rbd_dev, index,
2227 snap_name); 2233 snap_name);
2228 if (IS_ERR(new_snap)) 2234 if (IS_ERR(new_snap)) {
2229 return PTR_ERR(new_snap); 2235 int err = PTR_ERR(new_snap);
2236
2237 dout(" failed to add dev, error %d\n", err);
2238
2239 return err;
2240 }
2230 2241
2231 /* New goes before existing, or at end of list */ 2242 /* New goes before existing, or at end of list */
2232 2243
2244 dout(" added dev%s\n", snap ? "" : " at end\n");
2233 if (snap) 2245 if (snap)
2234 list_add_tail(&new_snap->node, &snap->node); 2246 list_add_tail(&new_snap->node, &snap->node);
2235 else 2247 else
@@ -2237,6 +2249,8 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev)
2237 } else { 2249 } else {
2238 /* Already have this one */ 2250 /* Already have this one */
2239 2251
2252 dout(" already present\n");
2253
2240 rbd_assert(snap->size == 2254 rbd_assert(snap->size ==
2241 rbd_dev->header.snap_sizes[index]); 2255 rbd_dev->header.snap_sizes[index]);
2242 rbd_assert(!strcmp(snap->name, snap_name)); 2256 rbd_assert(!strcmp(snap->name, snap_name));
@@ -2251,6 +2265,7 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev)
2251 index++; 2265 index++;
2252 snap_name += strlen(snap_name) + 1; 2266 snap_name += strlen(snap_name) + 1;
2253 } 2267 }
2268 dout("%s: done\n", __func__);
2254 2269
2255 return 0; 2270 return 0;
2256} 2271}