Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1119118lqh; Sun, 5 May 2024 17:59:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+/QKxaZ6z3re8KIk4PiNsKcdlNuxMwfV9XBD7X8aGv5WtStC332mx9VGM0coKQXLbcaiELvO4CsoGdav5qLrJdTwMyjk9H6AhPRKKEA== X-Google-Smtp-Source: AGHT+IHdcSvjbvgeP/bTQ1q0joMo5z8nitcO3J4wfHMv+lS9DJIDXG6+am5ulrlnHvDbyWwHSkX7 X-Received: by 2002:a05:620a:4085:b0:792:8d92:35a4 with SMTP id f5-20020a05620a408500b007928d9235a4mr5352340qko.60.1714957174754; Sun, 05 May 2024 17:59:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714957174; cv=pass; d=google.com; s=arc-20160816; b=zhlD8fTQM9tqBsHlyMDvu1hvpVvH/Q6LLrxQbbkKYtq/jIa9nG22UJ1O7p7vSuXRRc maKDsPIsos55Jtsdnq0gZQXfSq40U8ZYYyY2NXYlLqwLayXr5gI0DSmDY7cr/CVRE0ha IZQ9IBilb1kZc36y2dj7q0cvSAyM3x/UVOV4d5uQMsJZU/QjxUxQMtZGsik3P9UyhqMf 3/iGum15hPCStp3i1u9EDQvCMsK9huOaAISh7j/91GVZRbtfHOxAP6AJGI/sHPToSCsf jmETFWecVCyXchrz/DxXcVLv6a+UbXOkk3DBm7JsTjNvXa7jZQFjust4hmZvgKFtR4mK +b4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=KoHgORqHORP+qG9Vdm+vLmQaa/V+ermV9s3R2vfj3tA=; fh=reMLUhBZXsEmmiYeXXtahIAizLoSqeyioob9hi7oVMs=; b=h5y2fuJenWERRS6eqT+rKeGdIIxRZ2cwW2TXku0QLbGHtbypkFqQb16fHFGOgC8SUB RaVAiwYX9AS4ETgyl0vYOKJiwNg/edzxW/sYsaUlgnNfG2zazLE75/y1qA+fi6d9DPvS CSVukDVtrV5hC4KDSA3awZzbCfPFzZBns78xHqjaeQlxGgZ0gaY4e77Y4B3cIffpld3a HpFrBjlWrwf9+B0f1p4DBwSY38WVQ3+q0RZ+NdWwNgOELiI4dpdRNMZwwijURkA1v+y/ EN1mv3/1JPEQD3iJDqIgOvWyvmS/CO3dYesJ6jU6TJRZ/uZjCrFCYqewJQyRnlXeSkX1 svlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2301-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2301-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id qp15-20020a05620a388f00b007929308a399si2639442qkn.3.2024.05.05.17.59.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 17:59:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2301-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2301-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2301-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7ACA01C2106E for ; Mon, 6 May 2024 00:59:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D59133B781; Mon, 6 May 2024 00:59:30 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 197EB38F91 for ; Mon, 6 May 2024 00:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714957170; cv=none; b=Af5rMmLOBXne/078U/8pI3iAYww0D/IcM6I+DM/rxHAtPAuQGEWTgL3LnqrnUbesHsCoDaFusdndSNmsc8zI2bTjrxK9y9wKvj4FrcDU26ja+iBOBXF+TlfL63/8SBAigVrRYpoScyyOPfiTWMl81uhKIXXzV8rvoS26oVZVHw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714957170; c=relaxed/simple; bh=k1QUYHjTwg9ScrGUxfSE1dgf3CKWDUZ4xyW0gZeKzkk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pmi5li2c6t2/g32Kf2pNlpD/EiiOCbhNW3tBcjWxoPC174lTa3LTYSfiW0XIdFcAe5ChdloHU9GEJFGB7hGVtBW/+pO7z21++UKuwRcqCAKzeqm4Y38djQQoh+5NQ8gl3Cza89MT6mk+jnpGLj2oUZnav5CYyCVsPF3m69fu+xE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VXjjF4fnRz4f3kjc for ; Mon, 6 May 2024 08:59:13 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id E10A11A0D91 for ; Mon, 6 May 2024 08:59:18 +0800 (CST) Received: from [10.174.177.210] (unknown [10.174.177.210]) by APP1 (Coremail) with SMTP id cCh0CgCXaBFlKzhmjcF_Lw--.27978S3; Mon, 06 May 2024 08:59:18 +0800 (CST) Message-ID: Date: Mon, 6 May 2024 08:59:17 +0800 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] ext4: clear EXT4_GROUP_INFO_WAS_TRIMMED_BIT even mount with discard To: yangerkun , Jan Kara , "Theodore Y . Ts'o" Cc: adilger.kernel@dilger.ca, boyu.mt@taobao.com, linux-ext4@vger.kernel.org References: <20231230070654.178638-1-yangerkun@huaweicloud.com> <20240221111852.olo7jeycctz7xntj@quack3> <7953c617-2f74-faa4-2aa4-c6ef9de2c28e@huawei.com> From: yangerkun In-Reply-To: <7953c617-2f74-faa4-2aa4-c6ef9de2c28e@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgCXaBFlKzhmjcF_Lw--.27978S3 X-Coremail-Antispam: 1UD129KBjvJXoWxXr4kuw4rtry5Aw1kJr1DZFb_yoW5Zryfpr 1ktF1jyry5Xr109r4jqr1jqFy8tw4UJw1UXr1UXF48JrZrtr1agr17Xr1j9ryUJF48Jr1U XF15Xry3ZF1UArDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyEb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxvr21l42xK82IYc2Ij 64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x 8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE 2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42 xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIE c7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1zuWJUUUUU== X-CM-SenderInfo: 51dqwvhunx0q5kxd4v5lfo033gof0z/ Hi, Ted, Ping again... 在 2024/3/30 16:04, yangerkun 写道: > Hi, Ted, > > Ping for this patch. > > > 在 2024/2/21 19:18, Jan Kara 写道: >> On Sat 30-12-23 15:06:54, yangerkun wrote: >>> Commit 3d56b8d2c74c ("ext4: Speed up FITRIM by recording flags in >>> ext4_group_info") speed up fstrim by skipping trim trimmed group. We >>> also has the chance to clear trimmed once there exists some block free >>> for this group(mount without discard), and the next trim for this group >>> will work well too. >>> >>> For mount with discard, we will issue dicard when we free blocks, so >>> leave trimmed flag keep alive to skip useless trim trigger from >>> userspace seems reasonable. But for some case like ext4 build on >>> dm-thinpool(ext4 blocksize 4K, pool blocksize 128K), discard from ext4 >>> maybe unaligned for dm thinpool, and thinpool will just finish this >>> discard(see process_discard_bio when begein equals to end) without >>> actually process discard. For this case, trim from userspace can really >>> help us to free some thinpool block. >>> >>> So convert to clear trimmed flag for all case no matter mounted with >>> discard or not. >>> >>> Fixes: 3d56b8d2c74c ("ext4: Speed up FITRIM by recording flags in >>> ext4_group_info") >>> Signed-off-by: yangerkun >> >> Thanks for the fix. It looks good. Feel free to add: >> >> Reviewed-by: Jan Kara >> >>                                 Honza >> >>> --- >>>   fs/ext4/mballoc.c | 10 ++++------ >>>   1 file changed, 4 insertions(+), 6 deletions(-) >>> >>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c >>> index d72b5e3c92ec..69240ae775f1 100644 >>> --- a/fs/ext4/mballoc.c >>> +++ b/fs/ext4/mballoc.c >>> @@ -3855,11 +3855,8 @@ static void ext4_free_data_in_buddy(struct >>> super_block *sb, >>>       /* >>>        * Clear the trimmed flag for the group so that the next >>>        * ext4_trim_fs can trim it. >>> -     * If the volume is mounted with -o discard, online discard >>> -     * is supported and the free blocks will be trimmed online. >>>        */ >>> -    if (!test_opt(sb, DISCARD)) >>> -        EXT4_MB_GRP_CLEAR_TRIMMED(db); >>> +    EXT4_MB_GRP_CLEAR_TRIMMED(db); >>>       if (!db->bb_free_root.rb_node) { >>>           /* No more items in the per group rb tree >>> @@ -6481,8 +6478,9 @@ static void ext4_mb_clear_bb(handle_t *handle, >>> struct inode *inode, >>>                        " group:%u block:%d count:%lu failed" >>>                        " with %d", block_group, bit, count, >>>                        err); >>> -        } else >>> -            EXT4_MB_GRP_CLEAR_TRIMMED(e4b.bd_info); >>> +        } >>> + >>> +        EXT4_MB_GRP_CLEAR_TRIMMED(e4b.bd_info); >>>           ext4_lock_group(sb, block_group); >>>           mb_free_blocks(inode, &e4b, bit, count_clusters); >>> -- >>> 2.39.2 >>> >>>