@@ -601,6 +601,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
bio_set_flag(bio, BIO_CLONED);
if (bio_flagged(bio_src, BIO_THROTTLED))
bio_set_flag(bio, BIO_THROTTLED);
+ if (bio_flagged(bio_src, BIO_THROTL_COUNTED))
+ bio_set_flag(bio, BIO_THROTL_COUNTED);
bio->bi_opf = bio_src->bi_opf;
bio->bi_write_hint = bio_src->bi_write_hint;
bio->bi_iter = bio_src->bi_iter;
@@ -492,8 +492,10 @@ extern struct bio *bio_copy_user_iov(struct request_queue *,
#define bio_set_dev(bio, bdev) \
do { \
- if ((bio)->bi_disk != (bdev)->bd_disk) \
- bio_clear_flag(bio, BIO_THROTTLED);\
+ if ((bio)->bi_disk != (bdev)->bd_disk) { \
+ bio_clear_flag(bio, BIO_THROTTLED); \
+ bio_clear_flag(bio, BIO_THROTL_COUNTED);\
+ } \
(bio)->bi_disk = (bdev)->bd_disk; \
(bio)->bi_partno = (bdev)->bd_partno; \
} while (0)
@@ -701,11 +701,12 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q,
throtl = blk_throtl_bio(q, blkg, bio);
- if (!throtl) {
+ if (!throtl && !bio_flagged(bio, BIO_THROTL_COUNTED)) {
blkg = blkg ?: q->root_blkg;
blkg_rwstat_add(&blkg->stat_bytes, bio->bi_opf,
bio->bi_iter.bi_size);
blkg_rwstat_add(&blkg->stat_ios, bio->bi_opf, 1);
+ bio_set_flag(bio, BIO_THROTL_COUNTED);
}
rcu_read_unlock();
@@ -135,6 +135,7 @@ struct bio {
* throttling rules. Don't do it again. */
#define BIO_TRACE_COMPLETION 10 /* bio_endio() should trace the final completion
* of this bio. */
+#define BIO_THROTL_COUNTED 11 /* This bio has already counted to rwstat. */
/* See BVEC_POOL_OFFSET below before adding new flags */
/*