All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: stable@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>,
	Paolo Valente <paolo.valente@linaro.org>,
	<linux-block@vger.kernel.org>, Jan Kara <jack@suse.cz>,
	Logan Gunthorpe <logang@deltatee.com>,
	Donald Buczek <buczek@molgen.mpg.de>,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH 6/6] block: fix bio_clone_blkg_association() to associate with proper blkcg_gq
Date: Tue,  7 Jun 2022 11:15:14 +0200	[thread overview]
Message-ID: <20220607091528.11906-6-jack@suse.cz> (raw)
In-Reply-To: <20220607091209.24033-1-jack@suse.cz>

commit 22b106e5355d6e7a9c3b5cb5ed4ef22ae585ea94 upstream.

Commit d92c370a16cb ("block: really clone the block cgroup in
bio_clone_blkg_association") changed bio_clone_blkg_association() to
just clone bio->bi_blkg reference from source to destination bio. This
is however wrong if the source and destination bios are against
different block devices because struct blkcg_gq is different for each
bdev-blkcg pair. This will result in IOs being accounted (and throttled
as a result) multiple times against the same device (src bdev) while
throttling of the other device (dst bdev) is ignored. In case of BFQ the
inconsistency can even result in crashes in bfq_bic_update_cgroup().
Fix the problem by looking up correct blkcg_gq for the cloned bio.

Reported-by: Logan Gunthorpe <logang@deltatee.com>
Reported-and-tested-by: Donald Buczek <buczek@molgen.mpg.de>
Fixes: d92c370a16cb ("block: really clone the block cgroup in bio_clone_blkg_association")
CC: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20220602081242.7731-1-jack@suse.cz
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/bio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/bio.c b/block/bio.c
index 40004a3631a8..08dbdc32ceaa 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -2179,7 +2179,7 @@ void bio_clone_blkg_association(struct bio *dst, struct bio *src)
 	rcu_read_lock();
 
 	if (src->bi_blkg)
-		__bio_associate_blkg(dst, src->bi_blkg);
+		bio_associate_blkg_from_css(dst, &bio_blkcg(src)->css);
 
 	rcu_read_unlock();
 }
-- 
2.35.3


  parent reply	other threads:[~2022-06-07  9:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07  9:15 [PATCH 0/6] bfq: cgroup fixes for 5.4 stable Jan Kara
2022-06-07  9:15 ` [PATCH 1/6] bfq: Avoid merging queues with different parents Jan Kara
2022-06-07  9:15 ` [PATCH 2/6] bfq: Drop pointless unlock-lock pair Jan Kara
2022-06-07  9:15 ` [PATCH 3/6] bfq: Remove pointless bfq_init_rq() calls Jan Kara
2022-06-07  9:15 ` [PATCH 4/6] bfq: Get rid of __bio_blkcg() usage Jan Kara
2022-06-07  9:15 ` [PATCH 5/6] bfq: Make sure bfqg for which we are queueing requests is online Jan Kara
2022-06-07  9:15 ` Jan Kara [this message]
2022-06-07  9:57 ` [PATCH 0/6] bfq: cgroup fixes for 5.4 stable Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2022-06-06 17:56 [PATCH 0/6] bfq: cgroup fixes for 5.10 stable Jan Kara
2022-06-06 17:56 ` [PATCH 6/6] block: fix bio_clone_blkg_association() to associate with proper blkcg_gq Jan Kara

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=20220607091528.11906-6-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=buczek@molgen.mpg.de \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=paolo.valente@linaro.org \
    --cc=stable@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.