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>
This commit is contained in:
parent
527a88b9ef
commit
fca2706539
1 changed files with 22 additions and 13 deletions
|
@ -2913,7 +2913,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
|
||||||
* Request sync osd watch/unwatch. The value of "start" determines
|
* Request sync osd watch/unwatch. The value of "start" determines
|
||||||
* whether a watch request is being initiated or torn down.
|
* whether a watch request is being initiated or torn down.
|
||||||
*/
|
*/
|
||||||
static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, bool start)
|
static int __rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, bool start)
|
||||||
{
|
{
|
||||||
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
|
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
|
||||||
struct rbd_obj_request *obj_request;
|
struct rbd_obj_request *obj_request;
|
||||||
|
@ -2988,6 +2988,22 @@ out_cancel:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev)
|
||||||
|
{
|
||||||
|
return __rbd_dev_header_watch_sync(rbd_dev, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rbd_dev_header_unwatch_sync(struct rbd_device *rbd_dev)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = __rbd_dev_header_watch_sync(rbd_dev, false);
|
||||||
|
if (ret) {
|
||||||
|
rbd_warn(rbd_dev, "unable to tear down watch request: %d\n",
|
||||||
|
ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Synchronous osd object method call. Returns the number of bytes
|
* Synchronous osd object method call. Returns the number of bytes
|
||||||
* returned in the outbound buffer, or a negative error code.
|
* 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)
|
||||||
static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping)
|
static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int tmp;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the id from the image id object. Unless there's an
|
* 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)
|
||||||
goto err_out_format;
|
goto err_out_format;
|
||||||
|
|
||||||
if (mapping) {
|
if (mapping) {
|
||||||
ret = rbd_dev_header_watch_sync(rbd_dev, true);
|
ret = rbd_dev_header_watch_sync(rbd_dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_header_name;
|
goto out_header_name;
|
||||||
}
|
}
|
||||||
|
@ -5049,12 +5064,8 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping)
|
||||||
err_out_probe:
|
err_out_probe:
|
||||||
rbd_dev_unprobe(rbd_dev);
|
rbd_dev_unprobe(rbd_dev);
|
||||||
err_out_watch:
|
err_out_watch:
|
||||||
if (mapping) {
|
if (mapping)
|
||||||
tmp = rbd_dev_header_watch_sync(rbd_dev, false);
|
rbd_dev_header_unwatch_sync(rbd_dev);
|
||||||
if (tmp)
|
|
||||||
rbd_warn(rbd_dev, "unable to tear down "
|
|
||||||
"watch request (%d)\n", tmp);
|
|
||||||
}
|
|
||||||
out_header_name:
|
out_header_name:
|
||||||
kfree(rbd_dev->header_name);
|
kfree(rbd_dev->header_name);
|
||||||
rbd_dev->header_name = NULL;
|
rbd_dev->header_name = NULL;
|
||||||
|
@ -5250,16 +5261,14 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
|
||||||
if (ret < 0 || already)
|
if (ret < 0 || already)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = rbd_dev_header_watch_sync(rbd_dev, false);
|
rbd_dev_header_unwatch_sync(rbd_dev);
|
||||||
if (ret)
|
|
||||||
rbd_warn(rbd_dev, "failed to cancel watch event (%d)\n", ret);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* flush remaining watch callbacks - these must be complete
|
* flush remaining watch callbacks - these must be complete
|
||||||
* before the osd_client is shutdown
|
* before the osd_client is shutdown
|
||||||
*/
|
*/
|
||||||
dout("%s: flushing notifies", __func__);
|
dout("%s: flushing notifies", __func__);
|
||||||
ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc);
|
ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't free anything from rbd_dev->disk until after all
|
* Don't free anything from rbd_dev->disk until after all
|
||||||
* notifies are completely processed. Otherwise
|
* notifies are completely processed. Otherwise
|
||||||
|
|
Loading…
Add table
Reference in a new issue