Message ID | 20230209194825.511043-6-shikemeng@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp289117wrn; Thu, 9 Feb 2023 03:58:28 -0800 (PST) X-Google-Smtp-Source: AK7set+Ju/lVyRTg1b+1WdjZ4Vrc/A4WQzhHQkOwGOKOYpBsb2wL0LO/ruLtt50ZLRzaGx4qPIZr X-Received: by 2002:a17:90b:1d05:b0:232:d0e2:2868 with SMTP id on5-20020a17090b1d0500b00232d0e22868mr1779531pjb.18.1675943908405; Thu, 09 Feb 2023 03:58:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675943908; cv=none; d=google.com; s=arc-20160816; b=qnTKsOxqOEaesatojsWvlbtzCSRd46xkcDtwL6hQjV1PjrEP2VyiF57tN0UwLlRTxo +jUvFIsgHLr4Lqwokfct7Gl65z3XXPwDSvOOqaspSHu3NmlemV+BIhvBEym0g0+tink0 4XA1MLM9mDlf135gKWKxPv+1qdsE8AFGcEO3NrJSVBtEg1b/0TYppg+Q33OH4IJtXiEg MVdloM7sK15U0OcaqhxOcLCz1cch7/+AL9rzaKsoZ0jAtuGHz/pll/E0cUTEAJ9k+WgO fMkx74UG31SbhiE3Nbx9MAMdlQkZB6mbVFoqMOAOek40kEhGOyLi0AfCtY4xa+hWuquR p7MQ== 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=eAK1uYMG0gMmHVhKho3OBjcbV9nwemgunTAe5qjzE1Q=; b=LXQokV0dvbisEiM3WK617O8DoMearW9YQJkx8BDPjp62ERMKQLA2bd0PDD1tWtUV28 ikO3GqKwsKMHkNrmritFD3twF4MOYYsNNITCIPTGieE1BOATQxNwSPweADLQR5HDg/tA keOtx07/tbqcRFsMAtjKda2RoRMJNooWFLFOj/pFk1nAPa1LdwBuUj5MQiyw5jQZsKfe jhThs3ziGBEzEAcWpVDFqlEXwj4DyNHjahIGO5m9jVyKDTQAhdesl6AVjysmX8ueuNBe IJdbQBGG/WRn1+OVFj14cGXPvh+0WeRyicTwbRbLS/l18v0X7InBuDc1mj/EAL2zt/MR tG4w== 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 ce21-20020a17090aff1500b00231041254cdsi1738936pjb.31.2023.02.09.03.58.15; Thu, 09 Feb 2023 03:58:28 -0800 (PST) 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 S230037AbjBIL5P (ORCPT <rfc822;ybw1215001957@gmail.com> + 99 others); Thu, 9 Feb 2023 06:57:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbjBIL4M (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Feb 2023 06:56:12 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2E85C487; Thu, 9 Feb 2023 03:46:29 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PCFSd1Ny2z4f3jpv; Thu, 9 Feb 2023 19:46:25 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgAn3rEQ3eRjgb0tDQ--.53508S7; Thu, 09 Feb 2023 19:46:27 +0800 (CST) From: Kemeng Shi <shikemeng@huaweicloud.com> To: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/21] ext4: correct calculation of s_mb_preallocated Date: Fri, 10 Feb 2023 03:48:09 +0800 Message-Id: <20230209194825.511043-6-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230209194825.511043-1-shikemeng@huaweicloud.com> References: <20230209194825.511043-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAn3rEQ3eRjgb0tDQ--.53508S7 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFWDCFykAw4kJF4rCw4Durg_yoW8JF4xpF sxKr1UGwn3urn0kaykW3Z8Wwn7Ka1xKr45GryIgr48ZFZrJryakF4qyrW8WF1SvrWkZFnI vFW29FyUCrWI937anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAv FVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3w A2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE 3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr2 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUIL05UUUUU 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_NONE 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?1757354560052971855?= X-GMAIL-MSGID: =?utf-8?q?1757354560052971855?= |
Series |
Some bugfix and cleanup to mballoc
|
|
Commit Message
Kemeng Shi
Feb. 9, 2023, 7:48 p.m. UTC
We will add pa_free to s_mb_preallocated when new ext4_prealloc_space is
created. In ext4_mb_new_inode_pa, we will call ext4_mb_use_inode_pa
before adding pa_free to s_mb_preallocated. However, ext4_mb_use_inode_pa
will consume pa_free for block allocation which triggerred the creation
of ext4_prealloc_space. Add pa_free to s_mb_preallocated before
ext4_mb_use_inode_pa to correct calculation of s_mb_preallocated.
There is no such problem in ext4_mb_new_group_pa as pa_free of group pa
is consumed in ext4_mb_release_context instead of ext4_mb_use_group_pa.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
fs/ext4/mballoc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, Feb 10, 2023 at 03:48:09AM +0800, Kemeng Shi wrote: > We will add pa_free to s_mb_preallocated when new ext4_prealloc_space is > created. In ext4_mb_new_inode_pa, we will call ext4_mb_use_inode_pa > before adding pa_free to s_mb_preallocated. However, ext4_mb_use_inode_pa > will consume pa_free for block allocation which triggerred the creation > of ext4_prealloc_space. Add pa_free to s_mb_preallocated before > ext4_mb_use_inode_pa to correct calculation of s_mb_preallocated. > There is no such problem in ext4_mb_new_group_pa as pa_free of group pa > is consumed in ext4_mb_release_context instead of ext4_mb_use_group_pa. > > Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> > --- > fs/ext4/mballoc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index f24f80ecf318..2bffc93778d5 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -4670,8 +4670,8 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac) > pa->pa_len, pa->pa_lstart); > trace_ext4_mb_new_inode_pa(ac, pa); > > - ext4_mb_use_inode_pa(ac, pa); > atomic_add(pa->pa_free, &sbi->s_mb_preallocated); > + ext4_mb_use_inode_pa(ac, pa); > > ei = EXT4_I(ac->ac_inode); > grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group); > -- > 2.30.0 > My understanding is that s_mb_preallocated is for all the blocks we ever preallocated and so we need to add 'original' pa_len instead of (pa_len - best_len). Hence, the patch looks correct to me. Feel free to add: Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index f24f80ecf318..2bffc93778d5 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -4670,8 +4670,8 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac) pa->pa_len, pa->pa_lstart); trace_ext4_mb_new_inode_pa(ac, pa); - ext4_mb_use_inode_pa(ac, pa); atomic_add(pa->pa_free, &sbi->s_mb_preallocated); + ext4_mb_use_inode_pa(ac, pa); ei = EXT4_I(ac->ac_inode); grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);