Skip to content

Commit 81c6521

Browse files
committed
libceph: assign cookies in linger_submit()
Register lingers directly in linger_submit(). This avoids allocating memory for notify pagelist while holding osdc->lock and simplifies both callers of linger_submit(). Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 3b83f60 commit 81c6521

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

net/ceph/osd_client.c

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,11 +2998,21 @@ static void linger_submit(struct ceph_osd_linger_request *lreq)
29982998
struct ceph_osd_client *osdc = lreq->osdc;
29992999
struct ceph_osd *osd;
30003000

3001+
down_write(&osdc->lock);
3002+
linger_register(lreq);
3003+
if (lreq->is_watch) {
3004+
lreq->reg_req->r_ops[0].watch.cookie = lreq->linger_id;
3005+
lreq->ping_req->r_ops[0].watch.cookie = lreq->linger_id;
3006+
} else {
3007+
lreq->reg_req->r_ops[0].notify.cookie = lreq->linger_id;
3008+
}
3009+
30013010
calc_target(osdc, &lreq->t, NULL, false);
30023011
osd = lookup_create_osd(osdc, lreq->t.osd, true);
30033012
link_linger(osd, lreq);
30043013

30053014
send_linger(lreq);
3015+
up_write(&osdc->lock);
30063016
}
30073017

30083018
static void cancel_linger_map_check(struct ceph_osd_linger_request *lreq)
@@ -4523,15 +4533,14 @@ ceph_osdc_watch(struct ceph_osd_client *osdc,
45234533
goto err_put_lreq;
45244534
}
45254535

4526-
down_write(&osdc->lock);
4527-
linger_register(lreq); /* before osd_req_op_* */
4528-
osd_req_op_watch_init(lreq->reg_req, 0, lreq->linger_id,
4529-
CEPH_OSD_WATCH_OP_WATCH);
4530-
osd_req_op_watch_init(lreq->ping_req, 0, lreq->linger_id,
4531-
CEPH_OSD_WATCH_OP_PING);
4532-
linger_submit(lreq);
4533-
up_write(&osdc->lock);
4536+
/*
4537+
* Pass 0 for cookie because we don't know it yet, it will be
4538+
* filled in by linger_submit().
4539+
*/
4540+
osd_req_op_watch_init(lreq->reg_req, 0, 0, CEPH_OSD_WATCH_OP_WATCH);
4541+
osd_req_op_watch_init(lreq->ping_req, 0, 0, CEPH_OSD_WATCH_OP_PING);
45344542

4543+
linger_submit(lreq);
45354544
ret = linger_reg_commit_wait(lreq);
45364545
if (ret) {
45374546
linger_cancel(lreq);
@@ -4728,29 +4737,26 @@ int ceph_osdc_notify(struct ceph_osd_client *osdc,
47284737
goto out_put_lreq;
47294738
}
47304739

4740+
/*
4741+
* Pass 0 for cookie because we don't know it yet, it will be
4742+
* filled in by linger_submit().
4743+
*/
4744+
ret = osd_req_op_notify_init(lreq->reg_req, 0, 0, 1, timeout,
4745+
payload, payload_len);
4746+
if (ret)
4747+
goto out_put_lreq;
4748+
47314749
/* for notify_id */
47324750
pages = ceph_alloc_page_vector(1, GFP_NOIO);
47334751
if (IS_ERR(pages)) {
47344752
ret = PTR_ERR(pages);
47354753
goto out_put_lreq;
47364754
}
4737-
4738-
down_write(&osdc->lock);
4739-
linger_register(lreq); /* before osd_req_op_* */
4740-
ret = osd_req_op_notify_init(lreq->reg_req, 0, lreq->linger_id, 1,
4741-
timeout, payload, payload_len);
4742-
if (ret) {
4743-
linger_unregister(lreq);
4744-
up_write(&osdc->lock);
4745-
ceph_release_page_vector(pages, 1);
4746-
goto out_put_lreq;
4747-
}
47484755
ceph_osd_data_pages_init(osd_req_op_data(lreq->reg_req, 0, notify,
47494756
response_data),
47504757
pages, PAGE_SIZE, 0, false, true);
4751-
linger_submit(lreq);
4752-
up_write(&osdc->lock);
47534758

4759+
linger_submit(lreq);
47544760
ret = linger_reg_commit_wait(lreq);
47554761
if (!ret)
47564762
ret = linger_notify_finish_wait(lreq);

0 commit comments

Comments
 (0)