Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp179764rdb; Mon, 15 Jan 2024 17:27:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHndKNXuEWMqYHyFafz5m65wUiIEx+qd0UvFoGvQ+dSDPZ3LReZs4el3EgUIUtxSZfkpD3z X-Received: by 2002:a17:903:2651:b0:1d4:e0e:fa1b with SMTP id je17-20020a170903265100b001d40e0efa1bmr6666450plb.57.1705368439128; Mon, 15 Jan 2024 17:27:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705368439; cv=none; d=google.com; s=arc-20160816; b=NQig/uGOMSuXYs+1hmBMm4YG39A6Kflan+paHYfXHsSW7qrkAAJE2a6K24nkYrstRe ncQ3To5kecc6T2c6qHCxlfHxyw995uOtZ1cIqldjYdqM/+hNzoQhIJF5BpYKvFawmqeb pX+pEGtbqOT4NdMGLEh5cLCotqvFWOQOXT/f8a3jFAqdGLeIZVutHKK+4z7WinzjAjad rgHpFtD5pcqNSUkGzxkPPQJcTD0J5VFC/LLickZZNI94k6rYFZLmYX+yoPeySviQ6Fj8 vStw6OgAHuSixB6LLKSYuwcKsV3wuOv88LSjpfxphGGpJY1aIUnJ6V00a8ZWpCJaScK3 HIFg== ARC-Message-Signature: i=1; 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=TeCjw/xffbyma5F/tpA6VjUHw1NnXquOEn2G1yE2vYg=; fh=d+gMDtPuljJsqs3TbJNp9TjO5W6xJ4rlQSzWtHUL7bQ=; b=ev5oFD9IJ33wmnneqd0VhHrQeqfLEObasv0YLH5jnOsDE5MQlxhXPwvpRyH4F295o0 mLkg+d/gPkVLe7FrwTFtZTPTi3ZdRwCLZb6DZadufz24EAOuiqIeUdUdaCM0mQCi1Rla lc2a2WfX0jmfIkJ3Yvf22Ycr2SasMtcV8JhgunE2gUtchVe+PQLTdv4ZCZo4TOvYD4uH Mo6+KwL9sgajarUj4930t8LcVetYZu6o/wfE0bOchHOUZnunTnhVPb/F38KjfgXl4Cdl 5YVU3Wascc0Z8RIji/nVerABC+THUarL8bs0ctyo/YZXeGjXaZImtGiOypc1Vo+r1+K/ yF4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-791-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lg16-20020a170902fb9000b001d5c392ec0esi4408096plb.106.2024.01.15.17.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 17:27:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-791-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-791-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0F9DB285CC0 for ; Tue, 16 Jan 2024 01:16:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C936510971; Tue, 16 Jan 2024 01:03:01 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 05F7E101E8 for ; Tue, 16 Jan 2024 01:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TDW1773jXzvTrQ; Tue, 16 Jan 2024 09:01:31 +0800 (CST) Received: from kwepemd200008.china.huawei.com (unknown [7.221.188.40]) by mail.maildlp.com (Postfix) with ESMTPS id 2088C180071; Tue, 16 Jan 2024 09:02:55 +0800 (CST) Received: from [10.174.177.210] (10.174.177.210) by kwepemd200008.china.huawei.com (7.221.188.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Tue, 16 Jan 2024 09:02:54 +0800 Message-ID: <4284c67d-eefd-d4eb-2df3-d863ca4651b4@huawei.com> Date: Tue, 16 Jan 2024 09:02:53 +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 , , CC: , References: <20231230070654.178638-1-yangerkun@huaweicloud.com> From: yangerkun In-Reply-To: <20231230070654.178638-1-yangerkun@huaweicloud.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd200008.china.huawei.com (7.221.188.40) Ping... 在 2023/12/30 15:06, yangerkun 写道: > 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 > --- > 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);