libceph: get rid of unused "one shot" event support
Subsystems (3)
cover libceph: get rid of unused "one shot" event support
The osd client supports a "one shot" event, but nobody ever uses it. It probably works right, but it's effectively dead code, so just get rid of it. Get rid of ceph_osd_wait_event() as well, because whatever purpose it served was probably related to using a one shot event.
-Alex
[PATCH 1/2] libceph: kill ceph_osdc_create_event() "one_shot" [PATCH 2/2] libceph: kill ceph_osdc_wait_event()
PATCH 1/2 libceph: kill ceph_osdc_create_event() "one_shot" parameter
There is only one caller of ceph_osdc_create_event(), and it provides 0 as its "one_shot" argument. Get rid of that argument and just use 0 in its place.
Replace the code in handle_watch_notify() that executes if one_shot is nonzero in the event with a BUG_ON() call.
While modifying "osd_client.c", give handle_watch_notify() static scope.
--- drivers/block/rbd.c | 2 +- include/linux/ceph/osd_client.h | 3 +-- net/ceph/osd_client.c | 11 +++++------ 3 files changed, 7 insertions(+), 9 deletions(-)
drivers/block/rbd.c +0 -0
@@ -1744,7 +1744,7 @@ static int rbd_dev_header_watch_sync(struct
rbd_device *rbd_dev, int start)
rbd_assert(start ^ !!rbd_dev->watch_request);
if (start) {
- ret = ceph_osdc_create_event(osdc, rbd_watch_cb, 0, rbd_dev,
+ ret = ceph_osdc_create_event(osdc, rbd_watch_cb, rbd_dev,
&rbd_dev->watch_event);
if (ret < 0)
return ret;
(quoted diff) +0 -0
b/include/linux/ceph/osd_client.h
index c39e7ed..39c55d6 100644
include/linux/ceph/osd_client.h +0 -0
@@ -273,8 +273,7 @@ extern int ceph_osdc_writepages(struct
ceph_osd_client *osdc,
/* watch/notify events */
extern int ceph_osdc_create_event(struct ceph_osd_client *osdc,
void (*event_cb)(u64, u64, u8, void *),
- int one_shot, void *data, - struct ceph_osd_event **pevent); + void *data, struct ceph_osd_event **pevent);
extern void ceph_osdc_cancel_event(struct ceph_osd_event *event); extern int ceph_osdc_wait_event(struct ceph_osd_event *event,
unsigned long timeout);
net/ceph/osd_client.c +0 -0
@@ -1477,8 +1477,7 @@ static void __remove_event(struct ceph_osd_event
*event)
int ceph_osdc_create_event(struct ceph_osd_client *osdc,
void (*event_cb)(u64, u64, u8, void *),
- int one_shot, void *data, - struct ceph_osd_event **pevent) + void *data, struct ceph_osd_event **pevent)
{
struct ceph_osd_event *event;
@@ -1488,7 +1487,7 @@ int ceph_osdc_create_event(struct ceph_osd_client *osdc,
dout("create_event %p\n", event);
event->cb = event_cb;
- event->one_shot = one_shot;
+ event->one_shot = 0;
event->data = data;
event->osdc = osdc;
INIT_LIST_HEAD(&event->osd_node);
@@ -1541,7 +1540,8 @@ static void do_event_work(struct work_struct *work)
/*
* Process osd watch notifications
*/
-void handle_watch_notify(struct ceph_osd_client *osdc, struct ceph_msg *msg)
+static void handle_watch_notify(struct ceph_osd_client *osdc,
+ struct ceph_msg *msg)
{
void *p, *end;
u8 proto_ver;
@@ -1562,9 +1562,8 @@ void handle_watch_notify(struct ceph_osd_client *osdc, struct ceph_msg *msg)
spin_lock(&osdc->event_lock);
event = __find_event(osdc, cookie);
if (event) {
+ BUG_ON(event->one_shot);
get_event(event);
- if (event->one_shot)
- __remove_event(event);
}
spin_unlock(&osdc->event_lock); dout("handle_watch_notify cookie %lld ver %lld event %p\n",
Signature · 1 line
1.7.9.5
PATCH 2/2 libceph: kill ceph_osdc_wait_event()
In reply to Alex ElderThere are no actual users of ceph_osdc_wait_event(). This would have been one-shot events, but we no longer support those so just get rid of this function.
Since this leaves nothing else that waits for the completion of an event, we can get rid of the completion in a struct ceph_osd_event.
--- include/linux/ceph/osd_client.h | 3 --- net/ceph/osd_client.c | 18 ------------------ 2 files changed, 21 deletions(-)
(quoted diff) +0 -0
b/include/linux/ceph/osd_client.h
index 39c55d6..388158f 100644
include/linux/ceph/osd_client.h +0 -1
@@ -107,7 +107,6 @@ struct ceph_osd_event {struct rb_node node;struct list_head osd_node;struct kref kref; -struct completion completion; };struct ceph_osd_event_work {
@@ -275,8 +274,6 @@ extern int ceph_osdc_create_event(struct
ceph_osd_client *osdc,
void (*event_cb)(u64, u64, u8, void *), void *data, struct ceph_osd_event **pevent);
extern void ceph_osdc_cancel_event(struct ceph_osd_event *event);
-extern int ceph_osdc_wait_event(struct ceph_osd_event *event,
- unsigned long timeout);
extern void ceph_osdc_put_event(struct ceph_osd_event *event); #endif
net/ceph/osd_client.c +0 -0
@@ -1494,7 +1494,6 @@ int ceph_osdc_create_event(struct ceph_osd_client
*osdc,
RB_CLEAR_NODE(&event->node);
kref_init(&event->kref); /* one ref for us */
kref_get(&event->kref); /* one ref for the caller */
- init_completion(&event->completion);
spin_lock(&osdc->event_lock);
event->cookie = ++osdc->event_count;
@@ -1530,7 +1529,6 @@ static void do_event_work(struct work_struct *work)
dout("do_event_work completing %p\n", event); event->cb(ver, notify_id, opcode, event->data);
- complete(&event->completion);
dout("do_event_work completed %p\n", event); ceph_osdc_put_event(event); kfree(event_work);
@@ -1588,7 +1586,6 @@ static void handle_watch_notify(struct ceph_osd_client *osdc,
return;
done_err:
- complete(&event->completion);
ceph_osdc_put_event(event);
return;
@@ -1597,21 +1594,6 @@ bad:
return;
}
-int ceph_osdc_wait_event(struct ceph_osd_event *event, unsigned long timeout)
-{
- int err;
-
- dout("wait_event %p\n", event);
- err = wait_for_completion_interruptible_timeout(&event->completion,
- timeout * HZ);
- ceph_osdc_put_event(event);
- if (err > 0)
- err = 0;
- dout("wait_event %p returns %d\n", event, err);
- return err;
-}
-EXPORT_SYMBOL(ceph_osdc_wait_event);
-
/*
* Register request, send initial attempt.
*/
Signature · 1 line
1.7.9.5
Quoted 10 lines · Alex Elder
The osd client supports a "one shot" event, but nobody ever uses it. It probably works right, but it's effectively dead code, so just get rid of it. Get rid of
ceph_osd_wait_event()as well, because whatever purpose it served was probably related to using a one shot event.-Alex
[PATCH 1/2] libceph: kill
ceph_osdc_create_event()"one_shot" [PATCH 2/2] libceph: killceph_osdc_wait_event()
These look good.