diff options
author | Alex Elder <elder@inktank.com> | 2013-04-10 13:34:25 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:18:38 -0400 |
commit | 55f27e09312310d4dea9bb7b80c696f407caf1be (patch) | |
tree | e5534d19fb6adc31e7597edf573024f655f5987b /drivers/block | |
parent | a5a337d4382dfe0f9e9e072e7d3eaad8e05e4b0b (diff) |
rbd: record aggregate image transfer count
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>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/rbd.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 69eab66b6c67..e8374aec93da 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -214,6 +214,7 @@ struct rbd_img_request { | |||
214 | spinlock_t completion_lock;/* protects next_completion */ | 214 | spinlock_t completion_lock;/* protects next_completion */ |
215 | u32 next_completion; | 215 | u32 next_completion; |
216 | rbd_img_callback_t callback; | 216 | rbd_img_callback_t callback; |
217 | u64 xferred;/* aggregate bytes transferred */ | ||
217 | int result; /* first nonzero obj_request result */ | 218 | int result; /* first nonzero obj_request result */ |
218 | 219 | ||
219 | u32 obj_request_count; | 220 | u32 obj_request_count; |
@@ -1148,7 +1149,24 @@ static int rbd_obj_request_submit(struct ceph_osd_client *osdc, | |||
1148 | 1149 | ||
1149 | static void rbd_img_request_complete(struct rbd_img_request *img_request) | 1150 | static void rbd_img_request_complete(struct rbd_img_request *img_request) |
1150 | { | 1151 | { |
1152 | |||
1151 | dout("%s: img %p\n", __func__, img_request); | 1153 | dout("%s: img %p\n", __func__, img_request); |
1154 | |||
1155 | /* | ||
1156 | * If no error occurred, compute the aggregate transfer | ||
1157 | * count for the image request. We could instead use | ||
1158 | * atomic64_cmpxchg() to update it as each object request | ||
1159 | * completes; not clear which way is better off hand. | ||
1160 | */ | ||
1161 | if (!img_request->result) { | ||
1162 | struct rbd_obj_request *obj_request; | ||
1163 | u64 xferred = 0; | ||
1164 | |||
1165 | for_each_obj_request(img_request, obj_request) | ||
1166 | xferred += obj_request->xferred; | ||
1167 | img_request->xferred = xferred; | ||
1168 | } | ||
1169 | |||
1152 | if (img_request->callback) | 1170 | if (img_request->callback) |
1153 | img_request->callback(img_request); | 1171 | img_request->callback(img_request); |
1154 | else | 1172 | else |