Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2710645rwb; Sun, 4 Sep 2022 23:24:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR61W7UkZ2GBCL5M/4bGv7sfZDhsgPhrlBrZemDVyunaB+XsO4RV99MZXWN1dPeS7cE+5DFQ X-Received: by 2002:a05:6402:518b:b0:448:f30:38b0 with SMTP id q11-20020a056402518b00b004480f3038b0mr35372798edd.164.1662359047092; Sun, 04 Sep 2022 23:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662359047; cv=none; d=google.com; s=arc-20160816; b=y4Qzxch6gY3qyGaOca7wfI//LpIY7V/x+iyowwYSSwINFrFaqJ2WDBJkNrU7Ynwv+Z hqJdG+ZKPmDWlkEXk1f0xDT6S9QZS1/7oA0XxZCutAoRyz/Fc0F4LLQEyleuJe4w/SeL j8wqQovgbb+oxtEc/sx5dx08NbSfaMTBM+EZyGTurdTHcubD4pppDxUDihfiWKx7uFUe LEjBmf2oNFKAPhKZZqNDj0OdFyMja8mtFrUNs4O4UWhwzBwTNRcaYcxs2MV0rp5eHprk KQceK9INpsDHYDhxoLGkNNxHT9vHnVGBxn49g5YOWFxaO6lIRe4zIVwb5Vj7Tp/R2IH6 Yt0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=3J5mI21zDchju4RkKdAYBFxzP1wasPvKKZUMFdOS3cg=; b=NIz+Hzdir4Kbi28Pg95aZ50YtAEzuTuXSLP6w+qgi+ZIvSjMgctoPqmcFYmGhyWts5 MUS9t6oOMQT2+7sQWOTG6NvMLDscSYK6HmsClvn6H3bsZ3m+wX8WV6unZ/5DAiyuYd3+ UVY/H4v4SMOzgMYIg7zq0ZWHfYy8hl/9J2dPBo+fY2CX0knvIIKkvJe3OoXMrYKHg6Zk CDuQ4sBpNN3P7NjiMvvkG/uJqJjM4L1nXuQmLtvXKB1/EJ3vuzoBLBmu4G3TBO1+pMWG x411KsTGbpdhchPmlu/fmMIYBXEEidFRA/1iX6Zb89gnRtyF7XCfCAhRbg+kPMPcL/Iw QuCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a056402195300b00448e9ce3ee1si7602718edz.634.2022.09.04.23.23.42; Sun, 04 Sep 2022 23:24:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236267AbiIEGH1 (ORCPT + 99 others); Mon, 5 Sep 2022 02:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236239AbiIEGHW (ORCPT ); Mon, 5 Sep 2022 02:07:22 -0400 Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E80332AE2C; Sun, 4 Sep 2022 23:07:20 -0700 (PDT) Received: from [192.168.0.2] (ip5f5aec85.dynamic.kabel-deutschland.de [95.90.236.133]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 3F8AF61EA1929; Mon, 5 Sep 2022 08:07:18 +0200 (CEST) Message-ID: <0be7f162-fe9d-1ecc-57bb-7b67cbfd50ee@molgen.mpg.de> Date: Mon, 5 Sep 2022 08:07:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH 1/2] md/raid5: Remove unnecessary bio_put() in raid5_read_one_chunk() Content-Language: en-US To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu , Christoph Hellwig , Guoqing Jiang , Stephen Bates , Martin Oliveira , David Sloan References: <20220902171609.23376-1-logang@deltatee.com> <20220902171609.23376-2-logang@deltatee.com> From: Paul Menzel In-Reply-To: <20220902171609.23376-2-logang@deltatee.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Logan, dear David, Thank you for the patch. Am 02.09.22 um 19:16 schrieb Logan Gunthorpe: > From: David Sloan > > When running chunk-sized reads on disks with badblocks duplicate bio > free/puts are observed: > > ============================================================================= > BUG bio-200 (Not tainted): Object already free > ----------------------------------------------------------------------------- > Allocated in mempool_alloc_slab+0x17/0x20 age=3 cpu=2 pid=7504 > __slab_alloc.constprop.0+0x5a/0xb0 […] > The double free is caused by an unnecessary bio_put() in the > if(is_badblock(...)) error path in raid5_read_one_chunk(). > > The error path was moved ahead of bio_alloc_clone() in c82aa1b76787c > ("md/raid5: move checking badblock before clone bio in > raid5_read_one_chunk"). The previous code checked and freed align_bio > which required a bio_put. After he move that is no longer needed as *t*he move > raid_bio is returned to the control of the common io path which > performs its own endio resulting in a double free on bad device blocks. > > Fixes: c82aa1b76787c ("md/raid5: move checking badblock before clone bio in raid5_read_one_chunk") This commit was added to Linux in v5.14-rc1, so it’s not a recent commit – or I misunderstood the cover letter. Kind regards, Paul > Signed-off-by: David Sloan > [logang@deltatee.com: minor rewording of commit message] > Signed-off-by: Logan Gunthorpe > --- > drivers/md/raid5.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > index 4e6d865a6456..734f92e75f85 100644 > --- a/drivers/md/raid5.c > +++ b/drivers/md/raid5.c > @@ -5538,7 +5538,6 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio) > > if (is_badblock(rdev, sector, bio_sectors(raid_bio), &first_bad, > &bad_sectors)) { > - bio_put(raid_bio); > rdev_dec_pending(rdev, mddev); > return 0; > }