diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2016-04-28 10:07:26 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2016-05-25 19:14:05 -0400 |
commit | 3540bfdb30fcb423a92cc959708e71bc39eb18c3 (patch) | |
tree | f254c05bb00af02150fb1377f669d9d04a3d8a69 /net | |
parent | 5aea3dcd50215fa9563270251ad7323e2f2490ee (diff) |
libceph: request_init() and request_release_checks()
These are going to be used by request_reinit() code.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/osd_client.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 4c856c87b1a9..46e6fb5a1299 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -354,6 +354,15 @@ static void target_destroy(struct ceph_osd_request_target *t) | |||
354 | /* | 354 | /* |
355 | * requests | 355 | * requests |
356 | */ | 356 | */ |
357 | static void request_release_checks(struct ceph_osd_request *req) | ||
358 | { | ||
359 | WARN_ON(!RB_EMPTY_NODE(&req->r_node)); | ||
360 | WARN_ON(!list_empty(&req->r_linger_item)); | ||
361 | WARN_ON(!list_empty(&req->r_linger_osd_item)); | ||
362 | WARN_ON(!list_empty(&req->r_unsafe_item)); | ||
363 | WARN_ON(req->r_osd); | ||
364 | } | ||
365 | |||
357 | static void ceph_osdc_release_request(struct kref *kref) | 366 | static void ceph_osdc_release_request(struct kref *kref) |
358 | { | 367 | { |
359 | struct ceph_osd_request *req = container_of(kref, | 368 | struct ceph_osd_request *req = container_of(kref, |
@@ -362,10 +371,7 @@ static void ceph_osdc_release_request(struct kref *kref) | |||
362 | 371 | ||
363 | dout("%s %p (r_request %p r_reply %p)\n", __func__, req, | 372 | dout("%s %p (r_request %p r_reply %p)\n", __func__, req, |
364 | req->r_request, req->r_reply); | 373 | req->r_request, req->r_reply); |
365 | WARN_ON(!RB_EMPTY_NODE(&req->r_node)); | 374 | request_release_checks(req); |
366 | WARN_ON(!list_empty(&req->r_linger_item)); | ||
367 | WARN_ON(!list_empty(&req->r_linger_osd_item)); | ||
368 | WARN_ON(req->r_osd); | ||
369 | 375 | ||
370 | if (req->r_request) | 376 | if (req->r_request) |
371 | ceph_msg_put(req->r_request); | 377 | ceph_msg_put(req->r_request); |
@@ -404,6 +410,22 @@ void ceph_osdc_put_request(struct ceph_osd_request *req) | |||
404 | } | 410 | } |
405 | EXPORT_SYMBOL(ceph_osdc_put_request); | 411 | EXPORT_SYMBOL(ceph_osdc_put_request); |
406 | 412 | ||
413 | static void request_init(struct ceph_osd_request *req) | ||
414 | { | ||
415 | /* req only, each op is zeroed in _osd_req_op_init() */ | ||
416 | memset(req, 0, sizeof(*req)); | ||
417 | |||
418 | kref_init(&req->r_kref); | ||
419 | init_completion(&req->r_completion); | ||
420 | init_completion(&req->r_safe_completion); | ||
421 | RB_CLEAR_NODE(&req->r_node); | ||
422 | INIT_LIST_HEAD(&req->r_linger_item); | ||
423 | INIT_LIST_HEAD(&req->r_linger_osd_item); | ||
424 | INIT_LIST_HEAD(&req->r_unsafe_item); | ||
425 | |||
426 | target_init(&req->r_t); | ||
427 | } | ||
428 | |||
407 | struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, | 429 | struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, |
408 | struct ceph_snap_context *snapc, | 430 | struct ceph_snap_context *snapc, |
409 | unsigned int num_ops, | 431 | unsigned int num_ops, |
@@ -425,25 +447,13 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, | |||
425 | if (unlikely(!req)) | 447 | if (unlikely(!req)) |
426 | return NULL; | 448 | return NULL; |
427 | 449 | ||
428 | /* req only, each op is zeroed in _osd_req_op_init() */ | 450 | request_init(req); |
429 | memset(req, 0, sizeof(*req)); | ||
430 | |||
431 | req->r_osdc = osdc; | 451 | req->r_osdc = osdc; |
432 | req->r_mempool = use_mempool; | 452 | req->r_mempool = use_mempool; |
433 | req->r_num_ops = num_ops; | 453 | req->r_num_ops = num_ops; |
434 | req->r_snapid = CEPH_NOSNAP; | 454 | req->r_snapid = CEPH_NOSNAP; |
435 | req->r_snapc = ceph_get_snap_context(snapc); | 455 | req->r_snapc = ceph_get_snap_context(snapc); |
436 | 456 | ||
437 | kref_init(&req->r_kref); | ||
438 | init_completion(&req->r_completion); | ||
439 | init_completion(&req->r_safe_completion); | ||
440 | RB_CLEAR_NODE(&req->r_node); | ||
441 | INIT_LIST_HEAD(&req->r_unsafe_item); | ||
442 | INIT_LIST_HEAD(&req->r_linger_item); | ||
443 | INIT_LIST_HEAD(&req->r_linger_osd_item); | ||
444 | |||
445 | target_init(&req->r_t); | ||
446 | |||
447 | dout("%s req %p\n", __func__, req); | 457 | dout("%s req %p\n", __func__, req); |
448 | return req; | 458 | return req; |
449 | } | 459 | } |