summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-05-06 08:40:30 -0400
committerAlex Elder <elder@inktank.com>2013-05-08 08:40:48 -0400
commite627db085e0dab7744b68f3c927be6ed6df2f7f9 (patch)
treea84b1ae0d0217ebb66ebb1b6d7ca29b7909df8e1 /drivers/block
parent49ece554288caf1a8ea9e546ab1ff5bc4b175456 (diff)
rbd: revalidate only for mapping size changes
This commit: d98df63e rbd: revalidate_disk upon rbd resize instituted a call to revalidate_disk() to notify interested parties that a mapped image has changed size. This works well, as long as the the rbd device doesn't map a snapshot. A snapshot will never change size. However, the base image the snapshot is associated with can, and it can do so while the snapshot is mapped. The problem is that the test for the size is looking at the size of the base image, not the size of the mapped snapshot. This patch corrects that. Update the warning message shown in the event of error, and move it into the callers. This resolves: http://tracker.ceph.com/issues/4911 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.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 426374321d75..5d5e3f0b5fb4 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2628,6 +2628,7 @@ out:
2628static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) 2628static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
2629{ 2629{
2630 struct rbd_device *rbd_dev = (struct rbd_device *)data; 2630 struct rbd_device *rbd_dev = (struct rbd_device *)data;
2631 int ret;
2631 2632
2632 if (!rbd_dev) 2633 if (!rbd_dev)
2633 return; 2634 return;
@@ -2635,7 +2636,9 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
2635 dout("%s: \"%s\" notify_id %llu opcode %u\n", __func__, 2636 dout("%s: \"%s\" notify_id %llu opcode %u\n", __func__,
2636 rbd_dev->header_name, (unsigned long long)notify_id, 2637 rbd_dev->header_name, (unsigned long long)notify_id,
2637 (unsigned int)opcode); 2638 (unsigned int)opcode);
2638 (void)rbd_dev_refresh(rbd_dev); 2639 ret = rbd_dev_refresh(rbd_dev);
2640 if (ret)
2641 rbd_warn(rbd_dev, ": header refresh error (%d)\n", ret);
2639 2642
2640 rbd_obj_notify_ack(rbd_dev, notify_id); 2643 rbd_obj_notify_ack(rbd_dev, notify_id);
2641} 2644}
@@ -3182,11 +3185,11 @@ static void rbd_exists_validate(struct rbd_device *rbd_dev)
3182 3185
3183static int rbd_dev_refresh(struct rbd_device *rbd_dev) 3186static int rbd_dev_refresh(struct rbd_device *rbd_dev)
3184{ 3187{
3185 u64 image_size; 3188 u64 mapping_size;
3186 int ret; 3189 int ret;
3187 3190
3188 rbd_assert(rbd_image_format_valid(rbd_dev->image_format)); 3191 rbd_assert(rbd_image_format_valid(rbd_dev->image_format));
3189 image_size = rbd_dev->header.image_size; 3192 mapping_size = rbd_dev->mapping.size;
3190 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 3193 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
3191 if (rbd_dev->image_format == 1) 3194 if (rbd_dev->image_format == 1)
3192 ret = rbd_dev_v1_refresh(rbd_dev); 3195 ret = rbd_dev_v1_refresh(rbd_dev);
@@ -3197,10 +3200,7 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev)
3197 3200
3198 rbd_exists_validate(rbd_dev); 3201 rbd_exists_validate(rbd_dev);
3199 mutex_unlock(&ctl_mutex); 3202 mutex_unlock(&ctl_mutex);
3200 if (ret) 3203 if (mapping_size != rbd_dev->mapping.size)
3201 rbd_warn(rbd_dev, "got notification but failed to "
3202 " update snaps: %d\n", ret);
3203 if (image_size != rbd_dev->header.image_size)
3204 revalidate_disk(rbd_dev->disk); 3204 revalidate_disk(rbd_dev->disk);
3205 3205
3206 return ret; 3206 return ret;
@@ -3405,6 +3405,8 @@ static ssize_t rbd_image_refresh(struct device *dev,
3405 int ret; 3405 int ret;
3406 3406
3407 ret = rbd_dev_refresh(rbd_dev); 3407 ret = rbd_dev_refresh(rbd_dev);
3408 if (ret)
3409 rbd_warn(rbd_dev, ": manual header refresh error (%d)\n", ret);
3408 3410
3409 return ret < 0 ? ret : size; 3411 return ret < 0 ? ret : size;
3410} 3412}