From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 646C1C43334 for ; Mon, 6 Jun 2022 12:36:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237243AbiFFMg2 (ORCPT ); Mon, 6 Jun 2022 08:36:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237246AbiFFMg1 (ORCPT ); Mon, 6 Jun 2022 08:36:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 742BE2B1D5D for ; Mon, 6 Jun 2022 05:36:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0C12E611C9 for ; Mon, 6 Jun 2022 12:36:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 188C3C385A9; Mon, 6 Jun 2022 12:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654518985; bh=ew8k9+w5AyVliXbJyNxy5IJImUE0A909ZPk58MtQJWs=; h=Subject:To:Cc:From:Date:From; b=xOzXhMGyjDMQwWWG5VCvN66AhZ/mfI+AWmWbUJ88558UvI2psQGI/PrOlXmZ7Yfi/ +B+dhIZtwg2QY4Z/kKhXDq8++jiDNCUmjEAmtGQoKcwz1wi0fhXu4lkTVv84dP1ksH OeP4AZxrA8JtnSwuFSOfd5redK+0g4Q3sHB+sEg8= Subject: FAILED: patch "[PATCH] block: fix bio_clone_blkg_association() to associate with" failed to apply to 5.18-stable tree To: jack@suse.cz, axboe@kernel.dk, buczek@molgen.mpg.de, hch@lst.de, logang@deltatee.com Cc: From: Date: Mon, 06 Jun 2022 14:36:22 +0200 Message-ID: <1654518982221143@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 22b106e5355d6e7a9c3b5cb5ed4ef22ae585ea94 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 2 Jun 2022 10:12:42 +0200 Subject: [PATCH] block: fix bio_clone_blkg_association() to associate with proper blkcg_gq 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 Reported-and-tested-by: Donald Buczek Fixes: d92c370a16cb ("block: really clone the block cgroup in bio_clone_blkg_association") CC: stable@vger.kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20220602081242.7731-1-jack@suse.cz Signed-off-by: Jens Axboe diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 40161a3f68d0..764e740b0c0f 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1974,12 +1974,8 @@ EXPORT_SYMBOL_GPL(bio_associate_blkg); */ void bio_clone_blkg_association(struct bio *dst, struct bio *src) { - if (src->bi_blkg) { - if (dst->bi_blkg) - blkg_put(dst->bi_blkg); - blkg_get(src->bi_blkg); - dst->bi_blkg = src->bi_blkg; - } + if (src->bi_blkg) + bio_associate_blkg_from_css(dst, bio_blkcg_css(src)); } EXPORT_SYMBOL_GPL(bio_clone_blkg_association);