Skip to content

Commit 20e0af6

Browse files
committed
rbd: make rbd_obj_notify_ack() synchronous
The only user of rbd_obj_notify_ack() is rbd_watch_cb(). It used asynchronously with no tracking of when the notify ack completes, so it may still be in progress when the osd_client is shut down. This results in a BUG() since the osd client assumes no requests are in flight when it stops. Since all notifies are flushed before the osd_client is stopped, waiting for the notify ack to complete before returning from the watch callback ensures there are no notify acks in flight during shutdown. Rename rbd_obj_notify_ack() to rbd_obj_notify_ack_sync() to reflect its new synchronous nature. Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Alex Elder <[email protected]>
1 parent 9abc599 commit 20e0af6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/block/rbd.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ static void rbd_img_parent_read(struct rbd_obj_request *obj_request)
28082808
obj_request_done_set(obj_request);
28092809
}
28102810

2811-
static int rbd_obj_notify_ack(struct rbd_device *rbd_dev, u64 notify_id)
2811+
static int rbd_obj_notify_ack_sync(struct rbd_device *rbd_dev, u64 notify_id)
28122812
{
28132813
struct rbd_obj_request *obj_request;
28142814
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
@@ -2823,16 +2823,17 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev, u64 notify_id)
28232823
obj_request->osd_req = rbd_osd_req_create(rbd_dev, false, obj_request);
28242824
if (!obj_request->osd_req)
28252825
goto out;
2826-
obj_request->callback = rbd_obj_request_put;
28272826

28282827
osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK,
28292828
notify_id, 0, 0);
28302829
rbd_osd_req_format_read(obj_request);
28312830

28322831
ret = rbd_obj_request_submit(osdc, obj_request);
2833-
out:
28342832
if (ret)
2835-
rbd_obj_request_put(obj_request);
2833+
goto out;
2834+
ret = rbd_obj_request_wait(obj_request);
2835+
out:
2836+
rbd_obj_request_put(obj_request);
28362837

28372838
return ret;
28382839
}
@@ -2852,7 +2853,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
28522853
if (ret)
28532854
rbd_warn(rbd_dev, "header refresh error (%d)\n", ret);
28542855

2855-
rbd_obj_notify_ack(rbd_dev, notify_id);
2856+
rbd_obj_notify_ack_sync(rbd_dev, notify_id);
28562857
}
28572858

28582859
/*

0 commit comments

Comments
 (0)