summaryrefslogtreecommitdiff
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index c9de0f8e808e..aff4e8a01ea5 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -540,7 +540,14 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
header->comp_type = ondisk->options.comp_type;
header->total_snaps = snap_count;
- /* Set up the snapshot context */
+ /*
+ * If the number of snapshot ids provided by the caller
+ * doesn't match the number in the entire context there's
+ * no point in going further. Caller will try again after
+ * getting an updated snapshot context from the server.
+ */
+ if (allocated_snaps != snap_count)
+ return 0;
size = sizeof (struct ceph_snap_context);
size += snap_count * sizeof (header->snapc->snaps[0]);
@@ -552,8 +559,10 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
header->snapc->seq = le64_to_cpu(ondisk->snap_seq);
header->snapc->num_snaps = snap_count;
- if (snap_count && allocated_snaps == snap_count) {
- int i;
+ /* Fill in the snapshot information */
+
+ if (snap_count) {
+ u32 i;
for (i = 0; i < snap_count; i++) {
header->snapc->snaps[i] =