rbd: define rbd_update_mapping_size()
Encapsulate the code that handles updating the size of a mapping after an rbd image has been refreshed. This is done in anticipation of the next patch, which will make this common code for format 1 and 2 images. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
parent
802c6d967f
commit
9478554ae5
1 changed files with 16 additions and 11 deletions
|
@ -1716,6 +1716,19 @@ static void __rbd_remove_all_snaps(struct rbd_device *rbd_dev)
|
||||||
__rbd_remove_snap_dev(snap);
|
__rbd_remove_snap_dev(snap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rbd_update_mapping_size(struct rbd_device *rbd_dev)
|
||||||
|
{
|
||||||
|
sector_t size;
|
||||||
|
|
||||||
|
if (rbd_dev->mapping.snap_id != CEPH_NOSNAP)
|
||||||
|
return;
|
||||||
|
|
||||||
|
size = (sector_t) rbd_dev->header.image_size / SECTOR_SIZE;
|
||||||
|
dout("setting size to %llu sectors", (unsigned long long) size);
|
||||||
|
rbd_dev->mapping.size = (u64) size;
|
||||||
|
set_capacity(rbd_dev->disk, size);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* only read the first part of the ondisk header, without the snaps info
|
* only read the first part of the ondisk header, without the snaps info
|
||||||
*/
|
*/
|
||||||
|
@ -1730,17 +1743,9 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
|
||||||
|
|
||||||
down_write(&rbd_dev->header_rwsem);
|
down_write(&rbd_dev->header_rwsem);
|
||||||
|
|
||||||
/* resized? */
|
/* Update image size, and check for resize of mapped image */
|
||||||
if (rbd_dev->mapping.snap_id == CEPH_NOSNAP) {
|
rbd_dev->header.image_size = h.image_size;
|
||||||
sector_t size = (sector_t) h.image_size / SECTOR_SIZE;
|
rbd_update_mapping_size(rbd_dev);
|
||||||
|
|
||||||
if (size != (sector_t) rbd_dev->mapping.size) {
|
|
||||||
dout("setting size to %llu sectors",
|
|
||||||
(unsigned long long) size);
|
|
||||||
rbd_dev->mapping.size = (u64) size;
|
|
||||||
set_capacity(rbd_dev->disk, size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* rbd_dev->header.object_prefix shouldn't change */
|
/* rbd_dev->header.object_prefix shouldn't change */
|
||||||
kfree(rbd_dev->header.snap_sizes);
|
kfree(rbd_dev->header.snap_sizes);
|
||||||
|
|
Loading…
Add table
Reference in a new issue