[v3,08/19] ext4: get block from bh before pass it to ext4_free_blocks_simple in ext4_free_blocks
Message ID | 20230417110617.2664129-9-shikemeng@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1854179vqo; Sun, 16 Apr 2023 20:22:50 -0700 (PDT) X-Google-Smtp-Source: AKy350bBNvwhaLoxyS+K31M7SukzqjMRpdoMD21a5sLgNj73XIVE4b27+eT8iF0dRRArcwVbdYyz X-Received: by 2002:a17:90a:eac3:b0:23f:2c65:fab7 with SMTP id ev3-20020a17090aeac300b0023f2c65fab7mr13008467pjb.42.1681701770633; Sun, 16 Apr 2023 20:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681701770; cv=none; d=google.com; s=arc-20160816; b=jhfmQbBkNIVrIpLz4mXeAfgXkitNWCuAN7BpIy1CMK9Mo+N/56p6nXvcpTU0+tpFrG I7WqJ6Kph2Rn8iiFl/PRyJzWyEm+NJfTuqb9eROWdFL8rszZG/mkdRsSOIEqNQzuV+3n hPichnQHriAPm4tsevhF/W5GVLRudvN5clSBoSycMps4+jSK2SpUbps8i9urbG+kLles qZzLVoUnX2vHmV2t//OnC9fb2OTmm5KJhXNoSJqWyUFG7x7/SSm8laA2HGmG75f0LOlc q2KGQ7jgJnXHyX+Z2EyFQd3lBGMh888vS8W/MKdDLKOqHwZ+gaGYPca7yuWnYX5rgHz5 OfJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Yx+L8uyFqV/zBzJjTjdKJr6DJqToRyOIqi/PgcRBsao=; b=eMSUEPd8YiYLq5lRNCOPzoKJArS5O3z2EGpfVxF8yr3VHd7p5LF/9BYgikDGVQaqbJ 5hEJYuY1Vc3fh+czMaA9PI8cWprXsvDuVub94U90jlS6H8dJDRVrBypHcuxLisIq90Af zwjxBsYRg7TAP7KZ24ltIIHAF5KdcJjNdJhviCfAVgoEmPrYrnyfebEE+kcZMuNMqsAd Qlh7DuAzwwOdRklUEuvCNjSZUWdI3X5BJZhgAZXaK1/VfYqVQC/OrjptPE9O2aK3onRw Q6PjO/LpLauFtBoxHpU7EpxlNQaBQysfQppStv1wMaNRADMs/CWBsGYc/WSIxYD6Nm4P iK1g== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn18-20020a17090b38d200b00247a4bad97esi578614pjb.52.2023.04.16.20.22.36; Sun, 16 Apr 2023 20:22:50 -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 S230215AbjDQDFY (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Sun, 16 Apr 2023 23:05:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjDQDEC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 16 Apr 2023 23:04:02 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69964270C; Sun, 16 Apr 2023 20:04:01 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Q0Bhq3xLDz4f47kR; Mon, 17 Apr 2023 11:03:55 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgAXODIXtzxkfzJgHA--.17426S10; Mon, 17 Apr 2023 11:03:56 +0800 (CST) From: Kemeng Shi <shikemeng@huaweicloud.com> To: tytso@mit.edu, adilger.kernel@dilger.ca, ojaswin@linux.ibm.com Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH v3 08/19] ext4: get block from bh before pass it to ext4_free_blocks_simple in ext4_free_blocks Date: Mon, 17 Apr 2023 19:06:06 +0800 Message-Id: <20230417110617.2664129-9-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230417110617.2664129-1-shikemeng@huaweicloud.com> References: <20230417110617.2664129-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgAXODIXtzxkfzJgHA--.17426S10 X-Coremail-Antispam: 1UD129KBjvJXoW7JF48Cr4UZw1DJw1xJFy8Grg_yoW8Jr17pr srCFyrGr1kWwn2gF4fJr15Jwsa9w48G3WUWFWfuw18Xry7Z34Sy3WqyF15WF1UtrZav3ZF qFn0grW5Cw4UuaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRKfOw UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=2.5 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, KHOP_HELO_FCRDNS,MAY_BE_FORGED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763392115617857784?= X-GMAIL-MSGID: =?utf-8?q?1763392115617857784?= |
Series |
Fixes, cleanups and unit test for mballoc
|
|
Commit Message
Kemeng Shi
April 17, 2023, 11:06 a.m. UTC
ext4_free_blocks will retrieve block from bh if block parameter is zero.
Retrieve block before ext4_free_blocks_simple to avoid potentially
passing wrong block to ext4_free_blocks_simple.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
fs/ext4/mballoc.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
Comments
On Mon, Apr 17, 2023 at 07:06:06PM +0800, Kemeng Shi wrote: > ext4_free_blocks will retrieve block from bh if block parameter is zero. > Retrieve block before ext4_free_blocks_simple to avoid potentially > passing wrong block to ext4_free_blocks_simple. > > Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Hi Kemeng, Nice catch! feel free to add: Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> > --- > fs/ext4/mballoc.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index e980513c7a14..f37e921c11e5 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -6310,12 +6310,6 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, > > sbi = EXT4_SB(sb); > > - if (sbi->s_mount_state & EXT4_FC_REPLAY) { > - ext4_free_blocks_simple(inode, block, count); > - return; > - } > - > - might_sleep(); > if (bh) { > if (block) > BUG_ON(block != bh->b_blocknr); > @@ -6323,6 +6317,13 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, > block = bh->b_blocknr; > } > > + if (sbi->s_mount_state & EXT4_FC_REPLAY) { > + ext4_free_blocks_simple(inode, block, count); > + return; > + } > + > + might_sleep(); > + > if (!(flags & EXT4_FREE_BLOCKS_VALIDATED) && > !ext4_inode_block_valid(inode, block, count)) { > ext4_error(sb, "Freeing blocks not in datazone - " > -- > 2.30.0 >
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index e980513c7a14..f37e921c11e5 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -6310,12 +6310,6 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, sbi = EXT4_SB(sb); - if (sbi->s_mount_state & EXT4_FC_REPLAY) { - ext4_free_blocks_simple(inode, block, count); - return; - } - - might_sleep(); if (bh) { if (block) BUG_ON(block != bh->b_blocknr); @@ -6323,6 +6317,13 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, block = bh->b_blocknr; } + if (sbi->s_mount_state & EXT4_FC_REPLAY) { + ext4_free_blocks_simple(inode, block, count); + return; + } + + might_sleep(); + if (!(flags & EXT4_FREE_BLOCKS_VALIDATED) && !ext4_inode_block_valid(inode, block, count)) { ext4_error(sb, "Freeing blocks not in datazone - "