aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-10-09 16:50:17 -0400
committerAlex Elder <elder@inktank.com>2012-10-10 10:43:28 -0400
commit9478554ae5d21d65e948a3eff4ee2a8ad30d70e9 (patch)
tree727eec21db56d5972e38ed488c43e0681058b7ab /drivers/block
parent802c6d967fbdcd2cbc91b917425661bb8bbfaade (diff)
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>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index bb3d9be3b1b4..b64125d1d7bd 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1716,6 +1716,19 @@ static void __rbd_remove_all_snaps(struct rbd_device *rbd_dev)
1716 __rbd_remove_snap_dev(snap); 1716 __rbd_remove_snap_dev(snap);
1717} 1717}
1718 1718
1719static void rbd_update_mapping_size(struct rbd_device *rbd_dev)
1720{
1721 sector_t size;
1722
1723 if (rbd_dev->mapping.snap_id != CEPH_NOSNAP)
1724 return;
1725
1726 size = (sector_t) rbd_dev->header.image_size / SECTOR_SIZE;
1727 dout("setting size to %llu sectors", (unsigned long long) size);
1728 rbd_dev->mapping.size = (u64) size;
1729 set_capacity(rbd_dev->disk, size);
1730}
1731
1719/* 1732/*
1720 * only read the first part of the ondisk header, without the snaps info 1733 * only read the first part of the ondisk header, without the snaps info
1721 */ 1734 */
@@ -1730,17 +1743,9 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
1730 1743
1731 down_write(&rbd_dev->header_rwsem); 1744 down_write(&rbd_dev->header_rwsem);
1732 1745
1733 /* resized? */ 1746 /* Update image size, and check for resize of mapped image */
1734 if (rbd_dev->mapping.snap_id == CEPH_NOSNAP) { 1747 rbd_dev->header.image_size = h.image_size;
1735 sector_t size = (sector_t) h.image_size / SECTOR_SIZE; 1748 rbd_update_mapping_size(rbd_dev);
1736
1737 if (size != (sector_t) rbd_dev->mapping.size) {
1738 dout("setting size to %llu sectors",
1739 (unsigned long long) size);
1740 rbd_dev->mapping.size = (u64) size;
1741 set_capacity(rbd_dev->disk, size);
1742 }
1743 }
1744 1749
1745 /* rbd_dev->header.object_prefix shouldn't change */ 1750 /* rbd_dev->header.object_prefix shouldn't change */
1746 kfree(rbd_dev->header.snap_sizes); 1751 kfree(rbd_dev->header.snap_sizes);