Skip to contentSkip to conversation

block: don't account for split bio's size in cgroup stats

PATCH Applied Josef Bacik 2 participants 2 messages Jul 30, 2018

Subsystems (2)
lore
Share & tools
lore

Josef Bacik

author maintainer
#0 lore raw

PATCH v3 1/1 block: don't account for split bio's size in cgroup stats

We need to check in blkcg_bio_issue_check if the bio is flagged as QUEUE_ENTERED, because if it is then we've already accounted for the size of the IO in the cgroup stats. We can still however account for the extra IO since it'll be another request.

---
v2->v3:
- this one actually compiles

 include/linux/blk-cgroup.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
include/linux/blk-cgroup.h +8 -2
index 3bed5e02a873..f7b910768306 100644
@@ -769,8 +769,14 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q,
 
 	if (!throtl) {
 		blkg = blkg ?: q->root_blkg;
-		blkg_rwstat_add(&blkg->stat_bytes, bio->bi_opf,
-				bio->bi_iter.bi_size);
+		/*
+		 * If the bio is flagged with BIO_QUEUE_ENTERED it means this
+		 * is a split bio and we would have already accounted for the
+		 * size of the bio.
+		 */
+		if (!bio_flagged(bio, BIO_QUEUE_ENTERED))
+			blkg_rwstat_add(&blkg->stat_bytes, bio->bi_opf,
+					bio->bi_iter.bi_size);
 		blkg_rwstat_add(&blkg->stat_ios, bio->bi_opf, 1);
 	}
 
Signature · 1 line
2.14.3
maintainer Applied
#1 lore raw
Quoted 4 lines · Josef Bacik

We need to check in blkcg_bio_issue_check if the bio is flagged as QUEUE_ENTERED, because if it is then we've already accounted for the size of the IO in the cgroup stats. We can still however account for the extra IO since it'll be another request.

Applied, thanks.

Signature · 1 line
Jens Axboe