aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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,
540 header->comp_type = ondisk->options.comp_type; 540 header->comp_type = ondisk->options.comp_type;
541 header->total_snaps = snap_count; 541 header->total_snaps = snap_count;
542 542
543 /* Set up the snapshot context */ 543 /*
544 * If the number of snapshot ids provided by the caller
545 * doesn't match the number in the entire context there's
546 * no point in going further. Caller will try again after
547 * getting an updated snapshot context from the server.
548 */
549 if (allocated_snaps != snap_count)
550 return 0;
544 551
545 size = sizeof (struct ceph_snap_context); 552 size = sizeof (struct ceph_snap_context);
546 size += snap_count * sizeof (header->snapc->snaps[0]); 553 size += snap_count * sizeof (header->snapc->snaps[0]);
@@ -552,8 +559,10 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
552 header->snapc->seq = le64_to_cpu(ondisk->snap_seq); 559 header->snapc->seq = le64_to_cpu(ondisk->snap_seq);
553 header->snapc->num_snaps = snap_count; 560 header->snapc->num_snaps = snap_count;
554 561
555 if (snap_count && allocated_snaps == snap_count) { 562 /* Fill in the snapshot information */
556 int i; 563
564 if (snap_count) {
565 u32 i;
557 566
558 for (i = 0; i < snap_count; i++) { 567 for (i = 0; i < snap_count; i++) {
559 header->snapc->snaps[i] = 568 header->snapc->snaps[i] =