Skip to content

Commit

Permalink
rbd: only reset capacity when pointing to head
Browse files Browse the repository at this point in the history
Snapshots cannot be resized, and the new capacity of head should not
be reflected by the snapshot.

Signed-off-by: Josh Durgin <[email protected]>
Reviewed-by: Alex Elder <[email protected]>
  • Loading branch information
jdurgin authored and Sage Weil committed Jul 31, 2012
1 parent e88a36e commit 474ef7c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,12 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev)
return ret;

/* resized? */
set_capacity(rbd_dev->disk, h.image_size / SECTOR_SIZE);
if (rbd_dev->snap_id == CEPH_NOSNAP) {
sector_t size = (sector_t) h.image_size / SECTOR_SIZE;

dout("setting size to %llu sectors", (unsigned long long) size);
set_capacity(rbd_dev->disk, size);
}

down_write(&rbd_dev->header_rwsem);

Expand Down

0 comments on commit 474ef7c

Please sign in to comment.