rbd: only reset capacity when pointing to head
authorJosh Durgin <josh.durgin@inktank.com>
Tue, 22 Nov 2011 01:13:54 +0000 (17:13 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 16:51:18 +0000 (08:51 -0800)
Snapshots cannot be resized, and the new capacity of head should not
be reflected by the snapshot.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
(cherry picked from commit 474ef7ce832d471148f63a9d07f67fc5564834f1)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/rbd.c

index 4f7ed7f..52a045b 100644 (file)
@@ -1721,7 +1721,12 @@ static int __rbd_update_snaps(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);