From patchwork Fri Apr 5 14:06:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2398821 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E4E1B3FD8C for ; Fri, 5 Apr 2013 14:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161832Ab3DEOGI (ORCPT ); Fri, 5 Apr 2013 10:06:08 -0400 Received: from mail-ia0-f175.google.com ([209.85.210.175]:56828 "EHLO mail-ia0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161475Ab3DEOGH (ORCPT ); Fri, 5 Apr 2013 10:06:07 -0400 Received: by mail-ia0-f175.google.com with SMTP id e16so3153408iaa.6 for ; Fri, 05 Apr 2013 07:06: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=9KvZappfPzNGXzHUmK7LOfq4oaqfZeUsW2FkPKqUgN8=; b=gNnQwohz08RHt4GeaLXOq/S8+MSPWDlXn9jMKKbZeo9XeNVScXHWf6nbRbmEBn6BXk ocsXqksn6JxurGByQnrAcqAirg01t+3KrVr/b5gNm1ZsiSnYLo5UQv74kcUV+8soeBzs q83PTdPunHKisCLbMxRPUawx4utck3kJgFVlZpBKVITSY3xB2N9FjZ+Og7sIrdjOJ/Cc TB1S8I+Ar41V6Mi0uvQ/xBxbaVoI1sXvDNuQ3d4If6NrVmWRxKlM/xR1OGFEOodhgVzZ 2AcCu+5JYOYAmGFZ/9jVCk2WHra8CAg9QVfiAvQyYWAED3ezX8IztHZId2uq5ZgMZiw3 W2Jg== X-Received: by 10.50.154.71 with SMTP id vm7mr1714269igb.9.1365170765890; Fri, 05 Apr 2013 07:06:05 -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 y5sm2768804igg.7.2013.04.05.07.06.04 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Apr 2013 07:06:05 -0700 (PDT) Message-ID: <515EDA4C.4090305@inktank.com> Date: Fri, 05 Apr 2013 09:06:04 -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 19/20] libceph: set the data pointers when encoding ops References: <515ED849.9060901@inktank.com> In-Reply-To: <515ED849.9060901@inktank.com> X-Gm-Message-State: ALoCoQkg+xf3ymvGhKg4tP5vfcJ6HFpCxqorijs7LOWzk7UYYDDwjCe3N9mGgtXjZIEp2xQKOyqo Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 Reviewed-by: Josh Durgin --- include/linux/ceph/osd_client.h | 2 +- net/ceph/osd_client.c | 63 +++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 33 deletions(-) msg = ceph_msgpool_get(&osdc->msgpool_op, 0); @@ -549,6 +546,28 @@ void osd_req_op_watch_init(struct ceph_osd_request *osd_req, } EXPORT_SYMBOL(osd_req_op_watch_init); +static void ceph_osdc_msg_data_set(struct ceph_msg *msg, + struct ceph_osd_data *osd_data) +{ + u64 length = ceph_osd_data_length(osd_data); + + if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) { + BUG_ON(length > (u64) SIZE_MAX); + if (length) + ceph_msg_data_set_pages(msg, osd_data->pages, + length, osd_data->alignment); + } else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) { + BUG_ON(!length); + ceph_msg_data_set_pagelist(msg, osd_data->pagelist); +#ifdef CONFIG_BLOCK + } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) { + ceph_msg_data_set_bio(msg, osd_data->bio, length); +#endif + } else { + BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE); + } +} + static u64 osd_req_encode_op(struct ceph_osd_request *req, struct ceph_osd_op *dst, unsigned int which) { @@ -576,17 +595,24 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, cpu_to_le64(src->extent.truncate_size); dst->extent.truncate_seq = cpu_to_le32(src->extent.truncate_seq); - if (src->op == CEPH_OSD_OP_WRITE) + if (src->op == CEPH_OSD_OP_WRITE) { WARN_ON(src->extent.osd_data != &req->r_data_out); - else + ceph_osdc_msg_data_set(req->r_request, + src->extent.osd_data); + } else { WARN_ON(src->extent.osd_data != &req->r_data_in); + ceph_osdc_msg_data_set(req->r_reply, + src->extent.osd_data); + } break; case CEPH_OSD_OP_CALL: 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); WARN_ON(src->cls.response_data != &req->r_data_in); + ceph_osdc_msg_data_set(req->r_reply, src->cls.response_data); WARN_ON(src->cls.request_info != &req->r_data_out); + ceph_osdc_msg_data_set(req->r_request, src->cls.request_info); BUG_ON(src->cls.request_info->type != CEPH_OSD_DATA_TYPE_PAGELIST); request_data_len = src->cls.request_info->pagelist->length; @@ -1930,28 +1956,6 @@ bad: return; } -static void ceph_osdc_msg_data_set(struct ceph_msg *msg, - struct ceph_osd_data *osd_data) -{ - u64 length = ceph_osd_data_length(osd_data); - - if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) { - BUG_ON(length > (u64) SIZE_MAX); - if (length) - ceph_msg_data_set_pages(msg, osd_data->pages, - length, osd_data->alignment); - } else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) { - BUG_ON(!length); - ceph_msg_data_set_pagelist(msg, osd_data->pagelist); -#ifdef CONFIG_BLOCK - } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) { - ceph_msg_data_set_bio(msg, osd_data->bio, length); -#endif - } else { - BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE); - } -} - /* * build new request AND message * @@ -1967,11 +1971,6 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off, u64 data_len; unsigned int i; - /* Set up response incoming data and request outgoing data fields */ - - ceph_osdc_msg_data_set(req->r_reply, &req->r_data_in); - ceph_osdc_msg_data_set(req->r_request, &req->r_data_out); - req->r_snapid = snap_id; req->r_snapc = ceph_get_snap_context(snapc); diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index f8a00b4..dd4ca4ba 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h @@ -51,7 +51,7 @@ struct ceph_osd { #define CEPH_OSD_MAX_OP 2 enum ceph_osd_data_type { - CEPH_OSD_DATA_TYPE_NONE, + CEPH_OSD_DATA_TYPE_NONE = 0, CEPH_OSD_DATA_TYPE_PAGES, CEPH_OSD_DATA_TYPE_PAGELIST, #ifdef CONFIG_BLOCK diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 86cb524..cc4003f 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, } req->r_reply = msg; - ceph_osd_data_init(&req->r_data_in); - ceph_osd_data_init(&req->r_data_out); - /* create request message; allow space for oid */ if (use_mempool)