Skip to content

Commit

Permalink
rbd: update mapping size only on refresh
Browse files Browse the repository at this point in the history
There is no sense in trying to update the mapping size before it's even
been set.

Signed-off-by: Ilya Dryomov <[email protected]>
Reviewed-by: Alex Elder <[email protected]>
  • Loading branch information
idryomov committed Jul 25, 2014
1 parent 52bb1f9 commit 5ff1108
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,6 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
header->snap_names = snap_names;
header->snap_sizes = snap_sizes;

/* Make sure mapping size is consistent with header info */

if (rbd_dev->spec->snap_id == CEPH_NOSNAP || first_time)
if (rbd_dev->mapping.size != header->image_size)
rbd_dev->mapping.size = header->image_size;

return 0;
out_2big:
ret = -EIO;
Expand Down Expand Up @@ -3522,9 +3516,14 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev)
if (ret)
return ret;

/* If it's a mapped snapshot, validate its EXISTS flag */
if (rbd_dev->spec->snap_id == CEPH_NOSNAP) {
if (rbd_dev->mapping.size != rbd_dev->header.image_size)
rbd_dev->mapping.size = rbd_dev->header.image_size;
} else {
/* validate mapped snapshot's EXISTS flag */
rbd_exists_validate(rbd_dev);
}

rbd_exists_validate(rbd_dev);
up_write(&rbd_dev->header_rwsem);

if (mapping_size != rbd_dev->mapping.size) {
Expand Down Expand Up @@ -4507,10 +4506,6 @@ static int rbd_dev_v2_header_info(struct rbd_device *rbd_dev)
"is EXPERIMENTAL!");
}

if (rbd_dev->spec->snap_id == CEPH_NOSNAP)
if (rbd_dev->mapping.size != rbd_dev->header.image_size)
rbd_dev->mapping.size = rbd_dev->header.image_size;

ret = rbd_dev_v2_snap_context(rbd_dev);
dout("rbd_dev_v2_snap_context returned %d\n", ret);

Expand Down

0 comments on commit 5ff1108

Please sign in to comment.