From patchwork Fri Apr 12 02:17:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2433861 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 76CF9DF230 for ; Fri, 12 Apr 2013 02:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751202Ab3DLCRS (ORCPT ); Thu, 11 Apr 2013 22:17:18 -0400 Received: from mail-ia0-f170.google.com ([209.85.210.170]:41590 "EHLO mail-ia0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750974Ab3DLCRR (ORCPT ); Thu, 11 Apr 2013 22:17:17 -0400 Received: by mail-ia0-f170.google.com with SMTP id j38so2008477iad.1 for ; Thu, 11 Apr 2013 19:17:16 -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=TVRKnFKkIMGfqKP1eKhfsosyicKHlbJvNOB1qbVZgQU=; b=RDfiIO02GQPVfLd1KI1ayNC+aTSfonnwzvvpGRtC8ERYsBc2N7dqzI82QobTj5w5++ w8146NSlGNvOhhGVPiE+HyRkEgeb9sMcDQB55eacoi9B6ivFpVAtYA2K6nie/MQ0hWeI lNqGYK1M0sYKbGeHHD8c7/TjMcePJw67rx21gWfNBzAQIs1EBHCV6ELhevEsa40P8TRR lSr1XU9NkqWKfalC2fyuGifUMA+Y737x9+lCSIa4qJuxS4282xH5vJOmNFEAcjUwr/zc abbtcEYUVx1XeZOJlmj6p6QkhlsneSVoBwy1GrVVxi/yR3N2jcQOzUBPxS874ZiO+4RC sKYg== X-Received: by 10.50.181.201 with SMTP id dy9mr455828igc.18.1365733035925; Thu, 11 Apr 2013 19:17:15 -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 px9sm1327829igc.0.2013.04.11.19.17.14 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 19:17:15 -0700 (PDT) Message-ID: <51676EAB.1030804@inktank.com> Date: Thu, 11 Apr 2013 21:17:15 -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 02/11] rbd: record aggregate image transfer count References: <51676E0F.2010504@inktank.com> In-Reply-To: <51676E0F.2010504@inktank.com> X-Gm-Message-State: ALoCoQk6GcRy1DDa6hDZzpNk0Ky2q12FjM6n5eMP2HgVWNvlI7ixXUv5bYO+qsi6s6SukEsgMaaI Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Compute the total number of bytes transferred for an image request--the sum across each of the request's object requests. To avoid contention do it only when all object requests are complete, in rbd_img_request_complete(). Signed-off-by: Alex Elder --- drivers/block/rbd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) else diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 69eab66..e8374ae 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -214,6 +214,7 @@ struct rbd_img_request { spinlock_t completion_lock;/* protects next_completion */ u32 next_completion; rbd_img_callback_t callback; + u64 xferred;/* aggregate bytes transferred */ int result; /* first nonzero obj_request result */ u32 obj_request_count; @@ -1148,7 +1149,24 @@ static int rbd_obj_request_submit(struct ceph_osd_client *osdc, static void rbd_img_request_complete(struct rbd_img_request *img_request) { + dout("%s: img %p\n", __func__, img_request); + + /* + * If no error occurred, compute the aggregate transfer + * count for the image request. We could instead use + * atomic64_cmpxchg() to update it as each object request + * completes; not clear which way is better off hand. + */ + if (!img_request->result) { + struct rbd_obj_request *obj_request; + u64 xferred = 0; + + for_each_obj_request(img_request, obj_request) + xferred += obj_request->xferred; + img_request->xferred = xferred; + } + if (img_request->callback) img_request->callback(img_request);