Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 331643
b: refs/heads/master
c: 621901d
h: refs/heads/master
i:
  331641: 4947fec
  331639: afe8ab0
v: v3
  • Loading branch information
Alex Elder committed Oct 1, 2012
1 parent 6c2d91e commit da6c607
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f785cc1dbe90b561b8ded92df4fe9732bdc54859
refs/heads/master: 621901d652db10ad8ceddd25dd4b883978a873e1
26 changes: 13 additions & 13 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
u32 snap_count;
size_t len;
size_t size;
u32 i;

memset(header, 0, sizeof (*header));

Expand All @@ -535,6 +536,8 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
if (snap_count) {
u64 snap_names_len = le64_to_cpu(ondisk->snap_names_len);

/* Save a copy of the snapshot names */

if (snap_names_len > (u64) SIZE_MAX)
return -EIO;
header->snap_names = kmalloc(snap_names_len, GFP_KERNEL);
Expand All @@ -549,10 +552,15 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
memcpy(header->snap_names, &ondisk->snaps[snap_count],
snap_names_len);

/* Record each snapshot's size */

size = snap_count * sizeof (*header->snap_sizes);
header->snap_sizes = kmalloc(size, GFP_KERNEL);
if (!header->snap_sizes)
goto out_err;
for (i = 0; i < snap_count; i++)
header->snap_sizes[i] =
le64_to_cpu(ondisk->snaps[i].image_size);
} else {
WARN_ON(ondisk->snap_names_len);
header->snap_names = NULL;
Expand All @@ -565,6 +573,8 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
header->comp_type = ondisk->options.comp_type;
header->total_snaps = snap_count;

/* Allocate and fill in the snapshot context */

size = sizeof (struct ceph_snap_context);
size += snap_count * sizeof (header->snapc->snaps[0]);
header->snapc = kzalloc(size, GFP_KERNEL);
Expand All @@ -574,19 +584,9 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
atomic_set(&header->snapc->nref, 1);
header->snapc->seq = le64_to_cpu(ondisk->snap_seq);
header->snapc->num_snaps = snap_count;

/* Fill in the snapshot information */

if (snap_count) {
u32 i;

for (i = 0; i < snap_count; i++) {
header->snapc->snaps[i] =
le64_to_cpu(ondisk->snaps[i].id);
header->snap_sizes[i] =
le64_to_cpu(ondisk->snaps[i].image_size);
}
}
for (i = 0; i < snap_count; i++)
header->snapc->snaps[i] =
le64_to_cpu(ondisk->snaps[i].id);

return 0;

Expand Down

0 comments on commit da6c607

Please sign in to comment.