From patchwork Tue Apr 16 03:37:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2447371 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 97BD83FD40 for ; Tue, 16 Apr 2013 03:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935537Ab3DPDhu (ORCPT ); Mon, 15 Apr 2013 23:37:50 -0400 Received: from mail-ia0-f172.google.com ([209.85.210.172]:39885 "EHLO mail-ia0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935355Ab3DPDhu (ORCPT ); Mon, 15 Apr 2013 23:37:50 -0400 Received: by mail-ia0-f172.google.com with SMTP id k38so47006iah.17 for ; Mon, 15 Apr 2013 20:37:48 -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=wVgxLQdrybjCO1k7gkGyVgPZ+fQW5CVtrhbWK69eups=; b=eHZLHO6lFGDbQqz+oj7HP9fkjf1wvi11c9CoNykNYeV7x7Canu03jgRefkBdO0YpuR YW8LKFeM7yIFKPisp2nPy7SUdndj2sG9SSQpOz6Q6hE6hYnhiRTKA3Q1CzWFpXdJzzgV 7JtqbKlezxZjMeyOtUEeYztfvf670cDKbha6yiS9fC8cFaogq0X6bX6dDSn84cPwPDIy CQrB57ZD+UDr6DcK1XQ4dLKn8vfLkJQz3q9sHyWZ5Q6iKP31djcJY2QdHoFazmDvPZrM x79tnDNCjXUHEpTEA5frdu+wnPEA6y2WqoCLyH4Gqbh1vmooUYglDEAFvthB42n8mArE UQEw== X-Received: by 10.50.78.37 with SMTP id y5mr6833451igw.43.1366083468895; Mon, 15 Apr 2013 20:37:48 -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 ua6sm14080139igb.0.2013.04.15.20.37.47 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 20:37:48 -0700 (PDT) Message-ID: <516CC78B.9000608@inktank.com> Date: Mon, 15 Apr 2013 22:37:47 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 2/7] libceph: clean up osd data field access functions References: <516CC6E4.6070307@inktank.com> In-Reply-To: <516CC6E4.6070307@inktank.com> X-Gm-Message-State: ALoCoQnT5AubFrdakMG8ofhoZBcAeQyDSXRLCBmFQjcLee6wU4aSro21/mJtfufyWiSAW+s4Rp1v Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org There are a bunch of functions defined to encapsulate getting the address of a data field for a particular op in an osd request. They're all defined the same way, so create a macro to take the place of all of them. Two of these are used outside the osd client code, so preserve them (but convert them to use the new macro internally). Stop exporting the ones that aren't used elsewhere. Signed-off-by: Alex Elder --- net/ceph/osd_client.c | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) @@ -162,7 +144,7 @@ void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *osd_req, { struct ceph_osd_data *osd_data; - osd_data = osd_req_op_extent_osd_data(osd_req, which); + osd_data = osd_req_op_data(osd_req, which, extent, osd_data); ceph_osd_data_pages_init(osd_data, pages, length, alignment, pages_from_pool, own_pages); } @@ -173,7 +155,7 @@ void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *osd_req, { struct ceph_osd_data *osd_data; - osd_data = osd_req_op_extent_osd_data(osd_req, which); + osd_data = osd_req_op_data(osd_req, which, extent, osd_data); ceph_osd_data_pagelist_init(osd_data, pagelist); } EXPORT_SYMBOL(osd_req_op_extent_osd_data_pagelist); @@ -183,7 +165,8 @@ void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req, unsigned int which, struct bio *bio, size_t bio_length) { struct ceph_osd_data *osd_data; - osd_data = osd_req_op_extent_osd_data(osd_req, which); + + osd_data = osd_req_op_data(osd_req, which, extent, osd_data); ceph_osd_data_bio_init(osd_data, bio, bio_length); } EXPORT_SYMBOL(osd_req_op_extent_osd_data_bio); @@ -195,7 +178,7 @@ static void osd_req_op_cls_request_info_pagelist( { struct ceph_osd_data *osd_data; - osd_data = osd_req_op_cls_request_info(osd_req, which); + osd_data = osd_req_op_data(osd_req, which, cls, request_info); ceph_osd_data_pagelist_init(osd_data, pagelist); } @@ -205,7 +188,7 @@ void osd_req_op_cls_request_data_pagelist( { struct ceph_osd_data *osd_data; - osd_data = osd_req_op_cls_request_data(osd_req, which); + osd_data = osd_req_op_data(osd_req, which, cls, request_data); ceph_osd_data_pagelist_init(osd_data, pagelist); } EXPORT_SYMBOL(osd_req_op_cls_request_data_pagelist); @@ -216,7 +199,7 @@ void osd_req_op_cls_response_data_pages(struct ceph_osd_request *osd_req, { struct ceph_osd_data *osd_data; - osd_data = osd_req_op_cls_response_data(osd_req, which); + osd_data = osd_req_op_data(osd_req, which, cls, response_data); ceph_osd_data_pages_init(osd_data, pages, length, alignment, pages_from_pool, own_pages); } @@ -241,7 +224,6 @@ static u64 ceph_osd_data_length(struct ceph_osd_data *osd_data) } } - static void ceph_osd_data_release(struct ceph_osd_data *osd_data) { if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES && osd_data->own_pages) { diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index b76e416..104353a 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -115,43 +115,25 @@ static void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data, } #endif /* CONFIG_BLOCK */ +#define osd_req_op_data(oreq, whch, typ, fld) \ + ({ \ + BUG_ON(whch >= (oreq)->r_num_ops); \ + &(oreq)->r_ops[whch].typ.fld; \ + }) + struct ceph_osd_data * osd_req_op_extent_osd_data(struct ceph_osd_request *osd_req, unsigned int which) { - BUG_ON(which >= osd_req->r_num_ops); - - return &osd_req->r_ops[which].extent.osd_data; + return osd_req_op_data(osd_req, which, extent, osd_data); } EXPORT_SYMBOL(osd_req_op_extent_osd_data); struct ceph_osd_data * -osd_req_op_cls_request_info(struct ceph_osd_request *osd_req, - unsigned int which) -{ - BUG_ON(which >= osd_req->r_num_ops); - - return &osd_req->r_ops[which].cls.request_info; -} -EXPORT_SYMBOL(osd_req_op_cls_request_info); /* ??? */ - -struct ceph_osd_data * -osd_req_op_cls_request_data(struct ceph_osd_request *osd_req, - unsigned int which) -{ - BUG_ON(which >= osd_req->r_num_ops); - - return &osd_req->r_ops[which].cls.request_data; -} -EXPORT_SYMBOL(osd_req_op_cls_request_data); /* ??? */ - -struct ceph_osd_data * osd_req_op_cls_response_data(struct ceph_osd_request *osd_req, unsigned int which) { - BUG_ON(which >= osd_req->r_num_ops); - - return &osd_req->r_ops[which].cls.response_data; + return osd_req_op_data(osd_req, which, cls, response_data); } EXPORT_SYMBOL(osd_req_op_cls_response_data); /* ??? */