diff options
author | Alex Elder <elder@inktank.com> | 2013-04-05 02:27:12 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:18:24 -0400 |
commit | ec9123c56787fa7fb2608f05b19d21c5e1912d87 (patch) | |
tree | 84eb73a2dbb596c7aba369d42cd37146330fd2d4 /net/ceph/osd_client.c | |
parent | a4ce40a9a7c1053ac2a41cf64255e44e356e5522 (diff) |
libceph: set the data pointers when encoding ops
Still using the osd request r_data_in and r_data_out pointer, but
we're basically only referring to it via the data pointers in the
osd ops. And we're transferring that information to the request
or reply message only when the op indicates it's needed, in
osd_req_encode_op().
To avoid a forward reference, ceph_osdc_msg_data_set() was moved up
in the file.
Don't bother calling ceph_osd_data_init(), in ceph_osd_alloc(),
because the ops array will already be zeroed anyway.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph/osd_client.c')
-rw-r--r-- | net/ceph/osd_client.c | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 86cb52404f17..cc4003fdc01f 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -339,9 +339,6 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, | |||
339 | } | 339 | } |
340 | req->r_reply = msg; | 340 | req->r_reply = msg; |
341 | 341 | ||
342 | ceph_osd_data_init(&req->r_data_in); | ||
343 | ceph_osd_data_init(&req->r_data_out); | ||
344 | |||
345 | /* create request message; allow space for oid */ | 342 | /* create request message; allow space for oid */ |
346 | if (use_mempool) | 343 | if (use_mempool) |
347 | msg = ceph_msgpool_get(&osdc->msgpool_op, 0); | 344 | msg = ceph_msgpool_get(&osdc->msgpool_op, 0); |
@@ -549,6 +546,28 @@ void osd_req_op_watch_init(struct ceph_osd_request *osd_req, | |||
549 | } | 546 | } |
550 | EXPORT_SYMBOL(osd_req_op_watch_init); | 547 | EXPORT_SYMBOL(osd_req_op_watch_init); |
551 | 548 | ||
549 | static void ceph_osdc_msg_data_set(struct ceph_msg *msg, | ||
550 | struct ceph_osd_data *osd_data) | ||
551 | { | ||
552 | u64 length = ceph_osd_data_length(osd_data); | ||
553 | |||
554 | if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) { | ||
555 | BUG_ON(length > (u64) SIZE_MAX); | ||
556 | if (length) | ||
557 | ceph_msg_data_set_pages(msg, osd_data->pages, | ||
558 | length, osd_data->alignment); | ||
559 | } else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) { | ||
560 | BUG_ON(!length); | ||
561 | ceph_msg_data_set_pagelist(msg, osd_data->pagelist); | ||
562 | #ifdef CONFIG_BLOCK | ||
563 | } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) { | ||
564 | ceph_msg_data_set_bio(msg, osd_data->bio, length); | ||
565 | #endif | ||
566 | } else { | ||
567 | BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE); | ||
568 | } | ||
569 | } | ||
570 | |||
552 | static u64 osd_req_encode_op(struct ceph_osd_request *req, | 571 | static u64 osd_req_encode_op(struct ceph_osd_request *req, |
553 | struct ceph_osd_op *dst, unsigned int which) | 572 | struct ceph_osd_op *dst, unsigned int which) |
554 | { | 573 | { |
@@ -576,17 +595,24 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, | |||
576 | cpu_to_le64(src->extent.truncate_size); | 595 | cpu_to_le64(src->extent.truncate_size); |
577 | dst->extent.truncate_seq = | 596 | dst->extent.truncate_seq = |
578 | cpu_to_le32(src->extent.truncate_seq); | 597 | cpu_to_le32(src->extent.truncate_seq); |
579 | if (src->op == CEPH_OSD_OP_WRITE) | 598 | if (src->op == CEPH_OSD_OP_WRITE) { |
580 | WARN_ON(src->extent.osd_data != &req->r_data_out); | 599 | WARN_ON(src->extent.osd_data != &req->r_data_out); |
581 | else | 600 | ceph_osdc_msg_data_set(req->r_request, |
601 | src->extent.osd_data); | ||
602 | } else { | ||
582 | WARN_ON(src->extent.osd_data != &req->r_data_in); | 603 | WARN_ON(src->extent.osd_data != &req->r_data_in); |
604 | ceph_osdc_msg_data_set(req->r_reply, | ||
605 | src->extent.osd_data); | ||
606 | } | ||
583 | break; | 607 | break; |
584 | case CEPH_OSD_OP_CALL: | 608 | case CEPH_OSD_OP_CALL: |
585 | dst->cls.class_len = src->cls.class_len; | 609 | dst->cls.class_len = src->cls.class_len; |
586 | dst->cls.method_len = src->cls.method_len; | 610 | dst->cls.method_len = src->cls.method_len; |
587 | dst->cls.indata_len = cpu_to_le32(src->cls.request_data_len); | 611 | dst->cls.indata_len = cpu_to_le32(src->cls.request_data_len); |
588 | WARN_ON(src->cls.response_data != &req->r_data_in); | 612 | WARN_ON(src->cls.response_data != &req->r_data_in); |
613 | ceph_osdc_msg_data_set(req->r_reply, src->cls.response_data); | ||
589 | WARN_ON(src->cls.request_info != &req->r_data_out); | 614 | WARN_ON(src->cls.request_info != &req->r_data_out); |
615 | ceph_osdc_msg_data_set(req->r_request, src->cls.request_info); | ||
590 | BUG_ON(src->cls.request_info->type != | 616 | BUG_ON(src->cls.request_info->type != |
591 | CEPH_OSD_DATA_TYPE_PAGELIST); | 617 | CEPH_OSD_DATA_TYPE_PAGELIST); |
592 | request_data_len = src->cls.request_info->pagelist->length; | 618 | request_data_len = src->cls.request_info->pagelist->length; |
@@ -1930,28 +1956,6 @@ bad: | |||
1930 | return; | 1956 | return; |
1931 | } | 1957 | } |
1932 | 1958 | ||
1933 | static void ceph_osdc_msg_data_set(struct ceph_msg *msg, | ||
1934 | struct ceph_osd_data *osd_data) | ||
1935 | { | ||
1936 | u64 length = ceph_osd_data_length(osd_data); | ||
1937 | |||
1938 | if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) { | ||
1939 | BUG_ON(length > (u64) SIZE_MAX); | ||
1940 | if (length) | ||
1941 | ceph_msg_data_set_pages(msg, osd_data->pages, | ||
1942 | length, osd_data->alignment); | ||
1943 | } else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) { | ||
1944 | BUG_ON(!length); | ||
1945 | ceph_msg_data_set_pagelist(msg, osd_data->pagelist); | ||
1946 | #ifdef CONFIG_BLOCK | ||
1947 | } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) { | ||
1948 | ceph_msg_data_set_bio(msg, osd_data->bio, length); | ||
1949 | #endif | ||
1950 | } else { | ||
1951 | BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE); | ||
1952 | } | ||
1953 | } | ||
1954 | |||
1955 | /* | 1959 | /* |
1956 | * build new request AND message | 1960 | * build new request AND message |
1957 | * | 1961 | * |
@@ -1967,11 +1971,6 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off, | |||
1967 | u64 data_len; | 1971 | u64 data_len; |
1968 | unsigned int i; | 1972 | unsigned int i; |
1969 | 1973 | ||
1970 | /* Set up response incoming data and request outgoing data fields */ | ||
1971 | |||
1972 | ceph_osdc_msg_data_set(req->r_reply, &req->r_data_in); | ||
1973 | ceph_osdc_msg_data_set(req->r_request, &req->r_data_out); | ||
1974 | |||
1975 | req->r_snapid = snap_id; | 1974 | req->r_snapid = snap_id; |
1976 | req->r_snapc = ceph_get_snap_context(snapc); | 1975 | req->r_snapc = ceph_get_snap_context(snapc); |
1977 | 1976 | ||