All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 02/11] rbd: record aggregate image transfer count
Date: Thu, 11 Apr 2013 21:17:15 -0500	[thread overview]
Message-ID: <51676EAB.1030804@inktank.com> (raw)
In-Reply-To: <51676E0F.2010504@inktank.com>

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 <elder@inktank.com>
---
 drivers/block/rbd.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

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);
 	else
-- 
1.7.9.5


  parent reply	other threads:[~2013-04-12  2:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12  2:14 [PATCH 00/11] rbd: layered read functionality Alex Elder
2013-04-12  2:17 ` [PATCH 01/11] rbd: record overall image request result Alex Elder
2013-04-12  2:17 ` Alex Elder [this message]
2013-04-12  2:17 ` [PATCH 03/11] rbd: record image-relative offset in object requests Alex Elder
2013-04-12  2:17 ` [PATCH 04/11] rbd: define image request flags Alex Elder
2013-04-12  2:17 ` [PATCH 05/11] rbd: define image request originator flag Alex Elder
2013-04-12  2:18 ` [PATCH 06/11] rbd: define image request layered flag Alex Elder
2013-04-12  2:18 ` [PATCH 07/11] rbd: encapsulate image object end request handling Alex Elder
2013-04-12  2:18 ` [PATCH 08/11] rbd: define an rbd object request flags field Alex Elder
2013-04-12  2:18 ` [PATCH 09/11] rbd: add an object request flag for image data objects Alex Elder
2013-04-12  2:18 ` [PATCH 10/11] rbd: probe the parent of an image if present Alex Elder
2013-04-12  2:19 ` [PATCH 11/11] rbd: implement layered reads Alex Elder
2013-04-14 17:22 ` [PATCH 00/11] rbd: layered read functionality Josh Durgin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51676EAB.1030804@inktank.com \
    --to=elder@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.