From patchwork Fri Apr 5 14:02:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2398671 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 623163FD8C for ; Fri, 5 Apr 2013 14:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161760Ab3DEOCR (ORCPT ); Fri, 5 Apr 2013 10:02:17 -0400 Received: from mail-ie0-f173.google.com ([209.85.223.173]:63901 "EHLO mail-ie0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161757Ab3DEOCR (ORCPT ); Fri, 5 Apr 2013 10:02:17 -0400 Received: by mail-ie0-f173.google.com with SMTP id 9so4348955iec.32 for ; Fri, 05 Apr 2013 07:02:17 -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=aH5xbZ9vHBOeVFLfExsPiI0OHKZ3BksgO+f5VOEid5g=; b=ZubJa3AzPnYCzPXnPv0UdOjh5uKLDaM46SaNIyvv/wtLvVicsgmhE6QzxPiBiGsZPw 79ZQPGdmtrP7NLcfKM76fRH8OXiO+sqHMktzmXRks6JrobJyeZEhXVWTQ39iTFWjIDJz Ldr7oSZAIoGwftWMKI0HogIBJTIYXALsO+2zKoWTQau8LX/xYoU3eVh0p02jS4V1oOxF nJ7kuk6gmaVMsWq5DE9FpLBM7eJFz5Q+AXp4d6zDJCBvkWHd+4jDafORJZydiSy+z0gn l/R9wh8HJCSJ+xyKWDdQC5eQuRQTqYP3Y6dCH/WrVPGSDgbzWITflvYR4k61udkJCr9r Pbgg== X-Received: by 10.43.96.8 with SMTP id ce8mr5461431icc.12.1365170537004; Fri, 05 Apr 2013 07:02:17 -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 a3sm2775757igq.5.2013.04.05.07.02.15 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Apr 2013 07:02:16 -0700 (PDT) Message-ID: <515ED966.50704@inktank.com> Date: Fri, 05 Apr 2013 09:02:14 -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 04/20] libceph: define a few more helpers References: <515ED849.9060901@inktank.com> In-Reply-To: <515ED849.9060901@inktank.com> X-Gm-Message-State: ALoCoQlwZuOSMaunnM9uTcZxfNGe1sD4ksQJySODGWQ/lKteEioNIQhOvSVCDGf7BJ18vH9k3yH9 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Define ceph_osd_data_init() and ceph_osd_data_release() to clean up a little code. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- net/ceph/osd_client.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) bool pages_from_pool, bool own_pages) @@ -111,16 +117,28 @@ void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data, EXPORT_SYMBOL(ceph_osd_data_bio_init); #endif /* CONFIG_BLOCK */ +static void ceph_osd_data_release(struct ceph_osd_data *osd_data) +{ + if (osd_data->type != CEPH_OSD_DATA_TYPE_PAGES) + return; + + if (osd_data->own_pages) { + int num_pages; + + num_pages = calc_pages_for((u64)osd_data->alignment, + (u64)osd_data->length); + ceph_release_page_vector(osd_data->pages, num_pages); + } +} + /* * requests */ void ceph_osdc_release_request(struct kref *kref) { - int num_pages; - struct ceph_osd_request *req = container_of(kref, - struct ceph_osd_request, - r_kref); + struct ceph_osd_request *req; + req = container_of(kref, struct ceph_osd_request, r_kref); if (req->r_request) ceph_msg_put(req->r_request); if (req->r_reply) { @@ -128,18 +146,8 @@ void ceph_osdc_release_request(struct kref *kref) ceph_msg_put(req->r_reply); } - if (req->r_data_in.type == CEPH_OSD_DATA_TYPE_PAGES && - req->r_data_in.own_pages) { - num_pages = calc_pages_for((u64)req->r_data_in.alignment, - (u64)req->r_data_in.length); - ceph_release_page_vector(req->r_data_in.pages, num_pages); - } - if (req->r_data_out.type == CEPH_OSD_DATA_TYPE_PAGES && - req->r_data_out.own_pages) { - num_pages = calc_pages_for((u64)req->r_data_out.alignment, - (u64)req->r_data_out.length); - ceph_release_page_vector(req->r_data_out.pages, num_pages); - } + ceph_osd_data_release(&req->r_data_in); + ceph_osd_data_release(&req->r_data_out); ceph_put_snap_context(req->r_snapc); if (req->r_mempool) @@ -203,8 +211,8 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, } req->r_reply = msg; - req->r_data_in.type = CEPH_OSD_DATA_TYPE_NONE; - req->r_data_out.type = CEPH_OSD_DATA_TYPE_NONE; + 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) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index f8f8561..df0f856 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -79,6 +79,12 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen, return 0; } +static void ceph_osd_data_init(struct ceph_osd_data *osd_data) +{ + memset(osd_data, 0, sizeof *osd_data); + osd_data->type = CEPH_OSD_DATA_TYPE_NONE; +} + void ceph_osd_data_pages_init(struct ceph_osd_data *osd_data, struct page **pages, u64 length, u32 alignment,