From patchwork Fri Apr 5 14:05:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2398781 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 6F656DF2E5 for ; Fri, 5 Apr 2013 14:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161821Ab3DEOFI (ORCPT ); Fri, 5 Apr 2013 10:05:08 -0400 Received: from mail-ia0-f171.google.com ([209.85.210.171]:39673 "EHLO mail-ia0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161548Ab3DEOFH (ORCPT ); Fri, 5 Apr 2013 10:05:07 -0400 Received: by mail-ia0-f171.google.com with SMTP id z13so3227798iaz.30 for ; Fri, 05 Apr 2013 07:05:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=69dBwbEs99aJ9VEZ/PW+AFtOvSJHCMY+xskAJncv0Cg=; b=Pa4IgE4Piz4fAb7ehEqXgnYrPj3l5o6rLRa1d45Ec930D9qKG4xdFaW7QLgSxeWi9i hqISUaSw3glN04xE1yr9LRXnu4oxpKG1WzRR1Ub5lSgfDO7xPEIouwWPCex0Eb+w1oI4 JI+gQaaS43Tb3TPJthZesXLVh1W5r/KnRKI0D39CHpExru1NQN4buaUC/GAeorBkK2jL CKJOuFlZAmEqaH2PjmNhnobYLmunGEogiEsYZc2BMXD8JZknYQwi/AoMUnDNkCW9ehxC mVkDopR3yfMcc1saiWd5G6T2t0FwkQqnfv8JN+m/dYg3H15vZd15jEk9gf9qt/O5txQe NLCw== X-Received: by 10.50.119.104 with SMTP id kt8mr1673648igb.0.1365170706896; Fri, 05 Apr 2013 07:05:06 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id p11sm2416462igr.4.2013.04.05.07.05.05 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Apr 2013 07:05:06 -0700 (PDT) Message-ID: <515EDA11.5080106@inktank.com> Date: Fri, 05 Apr 2013 09:05:05 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" Subject: [PATCH 15/20] libceph: format class info at init time References: <515ED849.9060901@inktank.com> In-Reply-To: <515ED849.9060901@inktank.com> X-Gm-Message-State: ALoCoQmYSF3JAVaxHCW6uChPma+0L6cp6a7CFcU9Pvd5MICGnK8rj/qzGuwz5fgSuLJ6TfVsy4hW Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 Reviewed-by: Josh Durgin --- include/linux/ceph/osd_client.h | 3 ++- net/ceph/osd_client.c | 29 +++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) op->payload_len = payload_len; @@ -456,7 +467,6 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, { struct ceph_osd_req_op *src; u64 request_data_len = 0; - struct ceph_pagelist *pagelist; BUG_ON(which >= req->r_num_ops); src = &req->r_ops[which]; @@ -485,23 +495,14 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, WARN_ON(src->extent.osd_data != &req->r_data_in); break; case CEPH_OSD_OP_CALL: - pagelist = kmalloc(sizeof (*pagelist), GFP_NOFS); - BUG_ON(!pagelist); - ceph_pagelist_init(pagelist); - dst->cls.class_len = src->cls.class_len; dst->cls.method_len = src->cls.method_len; dst->cls.indata_len = cpu_to_le32(src->cls.request_data_len); - ceph_pagelist_append(pagelist, src->cls.class_name, - src->cls.class_len); - ceph_pagelist_append(pagelist, src->cls.method_name, - src->cls.method_len); - ceph_pagelist_append(pagelist, src->cls.request_data, - src->cls.request_data_len); - ceph_osd_data_pagelist_init(&req->r_data_out, pagelist); - WARN_ON(src->cls.response_data != &req->r_data_in); - request_data_len = pagelist->length; + WARN_ON(src->cls.request_info != &req->r_data_out); + BUG_ON(src->cls.request_info->type != + CEPH_OSD_DATA_TYPE_PAGELIST); + request_data_len = src->cls.request_info->pagelist->length; break; case CEPH_OSD_OP_STARTSYNC: break; diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index 144d57c..71c4157 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h @@ -93,8 +93,9 @@ struct ceph_osd_req_op { const char *class_name; const char *method_name; const void *request_data; - u32 request_data_len; + struct ceph_osd_data *request_info; struct ceph_osd_data *response_data; + u32 request_data_len; __u8 class_len; __u8 method_len; __u8 argc; diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index e698ccf..6c6d7b8 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, const void *request_data, size_t request_data_size) { struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode); + struct ceph_pagelist *pagelist; size_t payload_len = 0; size_t size; BUG_ON(opcode != CEPH_OSD_OP_CALL); + pagelist = kmalloc(sizeof (*pagelist), GFP_NOFS); + BUG_ON(!pagelist); + ceph_pagelist_init(pagelist); + op->cls.class_name = class; size = strlen(class); BUG_ON(size > (size_t) U8_MAX); op->cls.class_len = size; + ceph_pagelist_append(pagelist, class, size); payload_len += size; op->cls.method_name = method; size = strlen(method); BUG_ON(size > (size_t) U8_MAX); op->cls.method_len = size; + ceph_pagelist_append(pagelist, method, size); payload_len += size; op->cls.request_data = request_data; BUG_ON(request_data_size > (size_t) U32_MAX); op->cls.request_data_len = (u32) request_data_size; + ceph_pagelist_append(pagelist, request_data, request_data_size); payload_len += request_data_size; + op->cls.request_info = &osd_req->r_data_out; + ceph_osd_data_pagelist_init(op->cls.request_info, pagelist); + op->cls.argc = 0; /* currently unused */