Skip to content

Commit dd935f4

Browse files
committed
libceph: add function to ensure notifies are complete
Without a way to flush the osd client's notify workqueue, a watch event that is unregistered could continue receiving callbacks indefinitely. Unregistering the event simply means no new notifies are added to the queue, but there may still be events in the queue that will call the watch callback for the event. If the queue is flushed after the event is unregistered, the caller can be sure no more watch callbacks will occur for the canceled watch. Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Sage Weil <[email protected]> Reviewed-by: Alex Elder <[email protected]>
1 parent a8d436f commit dd935f4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/linux/ceph/osd_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
335335
struct ceph_osd_request *req);
336336
extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
337337

338+
extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc);
339+
338340
extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
339341
struct ceph_vino vino,
340342
struct ceph_file_layout *layout,

net/ceph/osd_client.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,17 @@ void ceph_osdc_sync(struct ceph_osd_client *osdc)
22152215
}
22162216
EXPORT_SYMBOL(ceph_osdc_sync);
22172217

2218+
/*
2219+
* Call all pending notify callbacks - for use after a watch is
2220+
* unregistered, to make sure no more callbacks for it will be invoked
2221+
*/
2222+
extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc)
2223+
{
2224+
flush_workqueue(osdc->notify_wq);
2225+
}
2226+
EXPORT_SYMBOL(ceph_osdc_flush_notifies);
2227+
2228+
22182229
/*
22192230
* init, shutdown
22202231
*/

0 commit comments

Comments
 (0)