aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-04-05 02:27:12 -0400
committerSage Weil <sage@inktank.com>2013-05-02 00:18:19 -0400
commit5f562df5f59340eae4272501b974903f48d2ad92 (patch)
tree6dccede3254a6878526da788febbddd8eac27462 /net/ceph
parent2169238dd3a01bc06670fb9c85635cbe97338ff8 (diff)
libceph: format class info at init time
An object class method is formatted using a pagelist which contains the class name, the method name, and the data concatenated into an osd request's outbound data. Currently when a class op is initialized in osd_req_op_cls_init(), the lengths of and pointers to these three items are recorded. Later, when the op is getting formatted into the request message, a new pagelist is created and that is when these items get copied into the pagelist. This patch makes it so the pagelist to hold these items is created when the op is initialized instead. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/osd_client.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index ad24f210bf0c..db2624860384 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -399,28 +399,39 @@ void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
399 const void *request_data, size_t request_data_size) 399 const void *request_data, size_t request_data_size)
400{ 400{
401 struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode); 401 struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode);
402 struct ceph_pagelist *pagelist;
402 size_t payload_len = 0; 403 size_t payload_len = 0;
403 size_t size; 404 size_t size;
404 405
405 BUG_ON(opcode != CEPH_OSD_OP_CALL); 406 BUG_ON(opcode != CEPH_OSD_OP_CALL);
406 407
408 pagelist = kmalloc(sizeof (*pagelist), GFP_NOFS);
409 BUG_ON(!pagelist);
410 ceph_pagelist_init(pagelist);
411
407 op->cls.class_name = class; 412 op->cls.class_name = class;
408 size = strlen(class); 413 size = strlen(class);
409 BUG_ON(size > (size_t) U8_MAX); 414 BUG_ON(size > (size_t) U8_MAX);
410 op->cls.class_len = size; 415 op->cls.class_len = size;
416 ceph_pagelist_append(pagelist, class, size);
411 payload_len += size; 417 payload_len += size;
412 418
413 op->cls.method_name = method; 419 op->cls.method_name = method;
414 size = strlen(method); 420 size = strlen(method);
415 BUG_ON(size > (size_t) U8_MAX); 421 BUG_ON(size > (size_t) U8_MAX);
416 op->cls.method_len = size; 422 op->cls.method_len = size;
423 ceph_pagelist_append(pagelist, method, size);
417 payload_len += size; 424 payload_len += size;
418 425
419 op->cls.request_data = request_data; 426 op->cls.request_data = request_data;
420 BUG_ON(request_data_size > (size_t) U32_MAX); 427 BUG_ON(request_data_size > (size_t) U32_MAX);
421 op->cls.request_data_len = (u32) request_data_size; 428 op->cls.request_data_len = (u32) request_data_size;
429 ceph_pagelist_append(pagelist, request_data, request_data_size);
422 payload_len += request_data_size; 430 payload_len += request_data_size;
423 431
432 op->cls.request_info = &osd_req->r_data_out;
433 ceph_osd_data_pagelist_init(op->cls.request_info, pagelist);
434
424 op->cls.argc = 0; /* currently unused */ 435 op->cls.argc = 0; /* currently unused */
425 436
426 op->payload_len = payload_len; 437 op->payload_len = payload_len;
@@ -456,7 +467,6 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,
456{ 467{
457 struct ceph_osd_req_op *src; 468 struct ceph_osd_req_op *src;
458 u64 request_data_len = 0; 469 u64 request_data_len = 0;
459 struct ceph_pagelist *pagelist;
460 470
461 BUG_ON(which >= req->r_num_ops); 471 BUG_ON(which >= req->r_num_ops);
462 src = &req->r_ops[which]; 472 src = &req->r_ops[which];
@@ -485,23 +495,14 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,
485 WARN_ON(src->extent.osd_data != &req->r_data_in); 495 WARN_ON(src->extent.osd_data != &req->r_data_in);
486 break; 496 break;
487 case CEPH_OSD_OP_CALL: 497 case CEPH_OSD_OP_CALL:
488 pagelist = kmalloc(sizeof (*pagelist), GFP_NOFS);
489 BUG_ON(!pagelist);
490 ceph_pagelist_init(pagelist);
491
492 dst->cls.class_len = src->cls.class_len; 498 dst->cls.class_len = src->cls.class_len;
493 dst->cls.method_len = src->cls.method_len; 499 dst->cls.method_len = src->cls.method_len;
494 dst->cls.indata_len = cpu_to_le32(src->cls.request_data_len); 500 dst->cls.indata_len = cpu_to_le32(src->cls.request_data_len);
495 ceph_pagelist_append(pagelist, src->cls.class_name,
496 src->cls.class_len);
497 ceph_pagelist_append(pagelist, src->cls.method_name,
498 src->cls.method_len);
499 ceph_pagelist_append(pagelist, src->cls.request_data,
500 src->cls.request_data_len);
501 ceph_osd_data_pagelist_init(&req->r_data_out, pagelist);
502
503 WARN_ON(src->cls.response_data != &req->r_data_in); 501 WARN_ON(src->cls.response_data != &req->r_data_in);
504 request_data_len = pagelist->length; 502 WARN_ON(src->cls.request_info != &req->r_data_out);
503 BUG_ON(src->cls.request_info->type !=
504 CEPH_OSD_DATA_TYPE_PAGELIST);
505 request_data_len = src->cls.request_info->pagelist->length;
505 break; 506 break;
506 case CEPH_OSD_OP_STARTSYNC: 507 case CEPH_OSD_OP_STARTSYNC:
507 break; 508 break;