diff options
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 27 |
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); | |||
201 | static LIST_HEAD(rbd_client_list); /* clients */ | 201 | static LIST_HEAD(rbd_client_list); /* clients */ |
202 | static DEFINE_SPINLOCK(rbd_client_list_lock); | 202 | static DEFINE_SPINLOCK(rbd_client_list_lock); |
203 | 203 | ||
204 | static int __rbd_init_snaps_header(struct rbd_device *rbd_dev); | 204 | static int rbd_dev_snap_devs_update(struct rbd_device *rbd_dev); |
205 | static void rbd_dev_release(struct device *dev); | 205 | static void rbd_dev_release(struct device *dev); |
206 | static ssize_t rbd_snap_add(struct device *dev, | 206 | static 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 | */ |
2187 | static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) | 2187 | static 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 | } |