[v2,08/19] ext4: get block from bh before pass it to ext4_free_blocks_simple in ext4_free_blocks
Message ID | 20230412172833.2317696-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 b10csp194173vqo; Wed, 12 Apr 2023 02:45:11 -0700 (PDT) X-Google-Smtp-Source: AKy350buJs7ooRECtPlUlMzlbn2zS5W7stD96VWWm0O0bmv0pW5wJrvmW4b7WRHN0Crg4X1brQ62 X-Received: by 2002:a50:fb95:0:b0:4bf:33e8:21ff with SMTP id e21-20020a50fb95000000b004bf33e821ffmr13385162edq.30.1681292711332; Wed, 12 Apr 2023 02:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681292711; cv=none; d=google.com; s=arc-20160816; b=dREI5JMFW8ydpnHq6tmx58tLwZetAqPvrT3Unj4s7mWpdBBiYvM41Sq9v5WUb+kz2d xnJ1naORGrcIidq/wC7Ttbr0zf6rogneiyqzSm9E+bpAEnlAwpMHTzAMTbn88a55Dw8Y yRhzyZKxKGSkiRTCEJoYh7OGQzekdKv7cS0wuxqSInCbyWSQNcmltdWRTo+raSC79Mz0 vlgGt0HbdEul4S65Lkf7DzdfYtmGrVaPvEhGeyfbq5pw3MxqawWwwYjW4nggZxCf75Q/ Trhfmd84m7vdjKYdP2eIfuAB+bHDap8CeuhYukMPTr5H4dJqutFvmJpTg+2ZjR/FTHoP 8Onw== 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=NGArT1KMqF6cSXwqCxOb3JH6kRKX/tPQjSUAlQUG77c=; b=IFP8fePEgXDyrK8wZCkucJDJCeEYeXqL8rTHzv1AiWjnbK81UTsK14AuEfdfHKAgOe zY5VdgGAf3mYkPyLEpaHGIxqetoTO6MhYYyor0ZxB0z1/pakdgFaDXWGEGhn+U6e4slz lQVe+JLHwh7m8wS4paIWvMTld7h/CuSSRt1U0ABpdwf0FiSvF0OC8BP9wb6DOJCwukOd rPtTaKw0cNvyqA5MLvMVjsBGMMZKwR24uTLVWS2ASzDxBgxRx1ASGLzTGRSoB13PgWm9 2FtvK0m3PkvnNqB41ZhIeDVdgEXjucq8uCVZG5H8R2SxPas8IB4WnUEgnN8mF6H1NnWO 8WNg== 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 g11-20020a056402180b00b005021f0d5761si3127516edy.680.2023.04.12.02.44.47; Wed, 12 Apr 2023 02:45:11 -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 S231589AbjDLJ1b (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Wed, 12 Apr 2023 05:27:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbjDLJ0Q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 12 Apr 2023 05:26:16 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52157EE1; Wed, 12 Apr 2023 02:26:13 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PxHQ80vF6z4f435t; Wed, 12 Apr 2023 17:26:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgDHL7MpeTZkL5_1HA--.3769S10; Wed, 12 Apr 2023 17:26:09 +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 v2 08/19] ext4: get block from bh before pass it to ext4_free_blocks_simple in ext4_free_blocks Date: Thu, 13 Apr 2023 01:28:22 +0800 Message-Id: <20230412172833.2317696-9-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230412172833.2317696-1-shikemeng@huaweicloud.com> References: <20230412172833.2317696-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgDHL7MpeTZkL5_1HA--.3769S10 X-Coremail-Antispam: 1UD129KBjvJXoW7JF48Cr4UZw1DJw1xJFy8Grg_yoW8Jr17pw srAFyrGr1kWwn2gF4fJw15JwsI9w48G3WUWFWfWw18Xry7X34Sy3WqyF15WF1UtrZav3ZF 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=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, SPF_HELO_NONE,SPF_PASS 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: <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?1762963186031665054?= X-GMAIL-MSGID: =?utf-8?q?1762963186031665054?= |
Series |
Fixes, cleanups and unit test for mballoc
|
|
Commit Message
Kemeng Shi
April 12, 2023, 5:28 p.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(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index b9a7b669b97d..ca11d0aa8a59 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -6117,12 +6117,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); @@ -6130,6 +6124,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 - "