From patchwork Fri Apr 5 14:02:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2398681 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 9948B3FD8C for ; Fri, 5 Apr 2013 14:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161791Ab3DEOC3 (ORCPT ); Fri, 5 Apr 2013 10:02:29 -0400 Received: from mail-ia0-f181.google.com ([209.85.210.181]:34876 "EHLO mail-ia0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161757Ab3DEOC2 (ORCPT ); Fri, 5 Apr 2013 10:02:28 -0400 Received: by mail-ia0-f181.google.com with SMTP id o25so3187606iad.26 for ; Fri, 05 Apr 2013 07:02:28 -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=0vfQKJONGsudaVfeZPWSNzsoEEdQajZhEaOmrz5wXWs=; b=OYd/GYqVG9CIKwDiSGfggLidyhqCGHOJ3TDZfyAxmvebi/45mnAKM/0qCVn6Aoo3v6 NagqC21htJjNqWTjnMbpW3uYF9QiT6KP8rbvHRMhSiJK84jRFeT52iYJBn2GTF5PrwMZ liAP9xxgQJKfPijS0/84eipkk96K8FMzH8WSW5TZanhSKDQtj2kyqsQcxXPW9U9vsBu+ PgnBp9lHhT6csbMMlTawQdw5nB5cbxtP8R2t4pRW/M5I4YAWe0jk/kSLg/Zt9t96rjpE tmQrmBDKQ3VKf/Gyf6PhHn8r6pgQi9lcjP41BIWk2lqf6ei2g6psQtaRfKFYUWi5FB2A lwPA== X-Received: by 10.50.36.169 with SMTP id r9mr1628217igj.96.1365170548196; Fri, 05 Apr 2013 07:02:28 -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 a3sm2763243igq.5.2013.04.05.07.02.26 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Apr 2013 07:02:27 -0700 (PDT) Message-ID: <515ED972.2030309@inktank.com> Date: Fri, 05 Apr 2013 09:02:26 -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 05/20] libceph: define ceph_osd_data_length() References: <515ED849.9060901@inktank.com> In-Reply-To: <515ED849.9060901@inktank.com> X-Gm-Message-State: ALoCoQknwG8fGtoYlCG9NkV1tcqABosgbxSzja79ooSp3efsieVORuJmUX5WxYr2rg4+7WxGP+3C Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org One more osd data helper, which returns the length of the data item, regardless of its type. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- net/ceph/osd_client.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) if (osd_data->type != CEPH_OSD_DATA_TYPE_PAGES) @@ -1887,17 +1906,19 @@ bad: 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(osd_data->length > (u64) SIZE_MAX); - if (osd_data->length) + BUG_ON(length > (u64) SIZE_MAX); + if (length) ceph_msg_data_set_pages(msg, osd_data->pages, - osd_data->length, osd_data->alignment); + length, osd_data->alignment); } else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) { - BUG_ON(!osd_data->pagelist->length); + 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, osd_data->bio_length); + ceph_msg_data_set_bio(msg, osd_data->bio, length); #endif } else { BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE); diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index df0f856..110cd83 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -117,6 +117,25 @@ void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data, EXPORT_SYMBOL(ceph_osd_data_bio_init); #endif /* CONFIG_BLOCK */ +static u64 ceph_osd_data_length(struct ceph_osd_data *osd_data) +{ + switch (osd_data->type) { + case CEPH_OSD_DATA_TYPE_NONE: + return 0; + case CEPH_OSD_DATA_TYPE_PAGES: + return osd_data->length; + case CEPH_OSD_DATA_TYPE_PAGELIST: + return (u64)osd_data->pagelist->length; +#ifdef CONFIG_BLOCK + case CEPH_OSD_DATA_TYPE_BIO: + return (u64)osd_data->bio_length; +#endif /* CONFIG_BLOCK */ + default: + WARN(true, "unrecognized data type %d\n", (int)osd_data->type); + return 0; + } +} + static void ceph_osd_data_release(struct ceph_osd_data *osd_data) {