Skip to content

Commit 39e58c3

Browse files
committed
libceph: introduce alloc_watch_request()
ceph_osdc_alloc_messages() call will be moved out of alloc_linger_request() in the next commit, which means that ceph_osdc_watch() will need to call ceph_osdc_alloc_messages() twice. Add a helper for that. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 81c6521 commit 39e58c3

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

net/ceph/osd_client.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4492,6 +4492,23 @@ alloc_linger_request(struct ceph_osd_linger_request *lreq)
44924492
return req;
44934493
}
44944494

4495+
static struct ceph_osd_request *
4496+
alloc_watch_request(struct ceph_osd_linger_request *lreq, u8 watch_opcode)
4497+
{
4498+
struct ceph_osd_request *req;
4499+
4500+
req = alloc_linger_request(lreq);
4501+
if (!req)
4502+
return NULL;
4503+
4504+
/*
4505+
* Pass 0 for cookie because we don't know it yet, it will be
4506+
* filled in by linger_submit().
4507+
*/
4508+
osd_req_op_watch_init(req, 0, 0, watch_opcode);
4509+
return req;
4510+
}
4511+
44954512
/*
44964513
* Returns a handle, caller owns a ref.
44974514
*/
@@ -4521,25 +4538,18 @@ ceph_osdc_watch(struct ceph_osd_client *osdc,
45214538
lreq->t.flags = CEPH_OSD_FLAG_WRITE;
45224539
ktime_get_real_ts64(&lreq->mtime);
45234540

4524-
lreq->reg_req = alloc_linger_request(lreq);
4541+
lreq->reg_req = alloc_watch_request(lreq, CEPH_OSD_WATCH_OP_WATCH);
45254542
if (!lreq->reg_req) {
45264543
ret = -ENOMEM;
45274544
goto err_put_lreq;
45284545
}
45294546

4530-
lreq->ping_req = alloc_linger_request(lreq);
4547+
lreq->ping_req = alloc_watch_request(lreq, CEPH_OSD_WATCH_OP_PING);
45314548
if (!lreq->ping_req) {
45324549
ret = -ENOMEM;
45334550
goto err_put_lreq;
45344551
}
45354552

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);
4542-
45434553
linger_submit(lreq);
45444554
ret = linger_reg_commit_wait(lreq);
45454555
if (ret) {

0 commit comments

Comments
 (0)