aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2013-12-16 11:02:40 -0500
committerIlya Dryomov <ilya.dryomov@inktank.com>2013-12-31 13:32:06 -0500
commitfca270653909404112ea5f6eed274ed5272d5252 (patch)
treefc9a6ce6b4e0575171c71179e48061cfacdb62da /drivers/block/rbd.c
parent527a88b9ef287a5c77f016a0090e0bd5338325b1 (diff)
rbd: introduce rbd_dev_header_unwatch_sync() and switch to it
Rename rbd_dev_header_watch_sync() to __rbd_dev_header_watch_sync() and introduce two helpers: rbd_dev_header_{,un}watch_sync() to make it more clear what is going on. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 11ae4c1238a6..d078d2352c77 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2913,7 +2913,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
2913 * Request sync osd watch/unwatch. The value of "start" determines 2913 * Request sync osd watch/unwatch. The value of "start" determines
2914 * whether a watch request is being initiated or torn down. 2914 * whether a watch request is being initiated or torn down.
2915 */ 2915 */
2916static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, bool start) 2916static int __rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, bool start)
2917{ 2917{
2918 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; 2918 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
2919 struct rbd_obj_request *obj_request; 2919 struct rbd_obj_request *obj_request;
@@ -2988,6 +2988,22 @@ out_cancel:
2988 return ret; 2988 return ret;
2989} 2989}
2990 2990
2991static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev)
2992{
2993 return __rbd_dev_header_watch_sync(rbd_dev, true);
2994}
2995
2996static void rbd_dev_header_unwatch_sync(struct rbd_device *rbd_dev)
2997{
2998 int ret;
2999
3000 ret = __rbd_dev_header_watch_sync(rbd_dev, false);
3001 if (ret) {
3002 rbd_warn(rbd_dev, "unable to tear down watch request: %d\n",
3003 ret);
3004 }
3005}
3006
2991/* 3007/*
2992 * Synchronous osd object method call. Returns the number of bytes 3008 * Synchronous osd object method call. Returns the number of bytes
2993 * returned in the outbound buffer, or a negative error code. 3009 * returned in the outbound buffer, or a negative error code.
@@ -5003,7 +5019,6 @@ static void rbd_dev_image_release(struct rbd_device *rbd_dev)
5003static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) 5019static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping)
5004{ 5020{
5005 int ret; 5021 int ret;
5006 int tmp;
5007 5022
5008 /* 5023 /*
5009 * Get the id from the image id object. Unless there's an 5024 * Get the id from the image id object. Unless there's an
@@ -5022,7 +5037,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping)
5022 goto err_out_format; 5037 goto err_out_format;
5023 5038
5024 if (mapping) { 5039 if (mapping) {
5025 ret = rbd_dev_header_watch_sync(rbd_dev, true); 5040 ret = rbd_dev_header_watch_sync(rbd_dev);
5026 if (ret) 5041 if (ret)
5027 goto out_header_name; 5042 goto out_header_name;
5028 } 5043 }
@@ -5049,12 +5064,8 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping)
5049err_out_probe: 5064err_out_probe:
5050 rbd_dev_unprobe(rbd_dev); 5065 rbd_dev_unprobe(rbd_dev);
5051err_out_watch: 5066err_out_watch:
5052 if (mapping) { 5067 if (mapping)
5053 tmp = rbd_dev_header_watch_sync(rbd_dev, false); 5068 rbd_dev_header_unwatch_sync(rbd_dev);
5054 if (tmp)
5055 rbd_warn(rbd_dev, "unable to tear down "
5056 "watch request (%d)\n", tmp);
5057 }
5058out_header_name: 5069out_header_name:
5059 kfree(rbd_dev->header_name); 5070 kfree(rbd_dev->header_name);
5060 rbd_dev->header_name = NULL; 5071 rbd_dev->header_name = NULL;
@@ -5250,16 +5261,14 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
5250 if (ret < 0 || already) 5261 if (ret < 0 || already)
5251 return ret; 5262 return ret;
5252 5263
5253 ret = rbd_dev_header_watch_sync(rbd_dev, false); 5264 rbd_dev_header_unwatch_sync(rbd_dev);
5254 if (ret)
5255 rbd_warn(rbd_dev, "failed to cancel watch event (%d)\n", ret);
5256
5257 /* 5265 /*
5258 * flush remaining watch callbacks - these must be complete 5266 * flush remaining watch callbacks - these must be complete
5259 * before the osd_client is shutdown 5267 * before the osd_client is shutdown
5260 */ 5268 */
5261 dout("%s: flushing notifies", __func__); 5269 dout("%s: flushing notifies", __func__);
5262 ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc); 5270 ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc);
5271
5263 /* 5272 /*
5264 * Don't free anything from rbd_dev->disk until after all 5273 * Don't free anything from rbd_dev->disk until after all
5265 * notifies are completely processed. Otherwise 5274 * notifies are completely processed. Otherwise