提交 e28626a0 编写于 作者: A Alex Elder 提交者: Sage Weil

rbd: fix a bug in resizing a mapping

When a snapshot context update occurs, rbd_update_mapping_size() is
called to set the capacity of the disk to record the updated
size of the image in case it has changed.

There's a bug though.  The mapping size is in units of *bytes*.  The
code that updates the mapping size field is assigning a value that
has been scaled down to *sectors*.

Fix that.  Also, check to see if the size has actually changed, and
don't bother updating things (specifically, calling set_capacity())
if it has not.

This resolves:
    http://tracker.ceph.com/issues/4833Signed-off-by: NAlex Elder <elder@inktank.com>
Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
上级 2e9f7f1c
...@@ -3034,15 +3034,17 @@ static void rbd_remove_all_snaps(struct rbd_device *rbd_dev) ...@@ -3034,15 +3034,17 @@ static void rbd_remove_all_snaps(struct rbd_device *rbd_dev)
static void rbd_update_mapping_size(struct rbd_device *rbd_dev) static void rbd_update_mapping_size(struct rbd_device *rbd_dev)
{ {
sector_t size;
if (rbd_dev->spec->snap_id != CEPH_NOSNAP) if (rbd_dev->spec->snap_id != CEPH_NOSNAP)
return; return;
size = (sector_t) rbd_dev->header.image_size / SECTOR_SIZE; if (rbd_dev->mapping.size != rbd_dev->header.image_size) {
dout("setting size to %llu sectors", (unsigned long long) size); sector_t size;
rbd_dev->mapping.size = (u64) size;
rbd_dev->mapping.size = rbd_dev->header.image_size;
size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE;
dout("setting size to %llu sectors", (unsigned long long)size);
set_capacity(rbd_dev->disk, size); set_capacity(rbd_dev->disk, size);
}
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册