Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp395481lqz; Sat, 30 Mar 2024 01:04:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX26ez9vRUHZYxEDmDFKNiQb167yBdviN4W5ZfNrTOJBIogPvAs5CVTwcnXJXHFgGRAoUm+eKUt9vg45/5ja/q+cfIEzmX9zZCTzCSozQ== X-Google-Smtp-Source: AGHT+IGBTJwxLK+SxRyd8H7E5wLNZHosfaKgzWpRk7RwoD0LEUXJSNO3KpSzHosaxPA/g57GVzC1 X-Received: by 2002:a05:620a:458b:b0:78b:d447:4752 with SMTP id bp11-20020a05620a458b00b0078bd4474752mr1623057qkb.17.1711785864328; Sat, 30 Mar 2024 01:04:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711785864; cv=pass; d=google.com; s=arc-20160816; b=LBCHe5an63kwUd1FT18o+PsWsXE/qqKf3zCP1WcqmM0rYMVHIKTzNQHjjQnIsuwAhC VCaND1l5r6b5YeLJpTh+PENDRHX7xlYDW/eBLVkCI5bosbjZBbPXoqkUv34G/Wnuho8P sSxX2DwazF7RgMsw5KhqTLQcArkIG0zIOXUeP1refABE9qb5UV6PSr5OreYIyvpftwzo RXlElQvB+IQL2I03Ysr1PjrJhPiFIuU7jeqvwhe/K0g3vmwKrnEvwL9YyOekuXEss3Sc CttHG6aykxr1A4IK31724KTrlruDoE8aL/WuTMq3A0iTB7wooLPLV9bHOpEy7DLBJI57 6Zlg== 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=o7Mzf8lum/b5OqlC14xBu8WiUW8m6K1bVLDMWNE8Es8=; fh=THOeAOdY3UB46LDfaT1Tl4OKjW8dH/HT4+ybGkd+8j8=; b=RYHHXdXUgbc1Db0hATOSuCjEYi5uhLFy4iYurNSbB1aBPrPCgWw8NZZJmOQTknlLLu CpyiozcfyL4VlRgWeDotoKIPR0iE3KMOKneyuv4SgMT2P/QNRmNerxirXx80a+HEMStk VDKhnirQDaUam+P7zwtKbK1Y5b5B1jYPksQXcBqOOegOJpmHR2d8fJ4ZUZ7rYtRzTex0 pzYuzg0jU36gJpAqKtTb0JBhVe+FPHm3lWIw4XvGdrB+WqIfAEolLhj/SGNHmgKeVh+y BLTb5bW7+BEAbaNjKl6dDn+xZOas0cArMz62b3aABpM9jFgB7Qitf1yZX22JSG83AqCO AsUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-ext4+bounces-1792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u5-20020a05620a084500b0078a360c47dasi5284117qku.338.2024.03.30.01.04.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Mar 2024 01:04:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-ext4+bounces-1792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1792-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 108121C20E86 for ; Sat, 30 Mar 2024 08:04:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E98D979E0; Sat, 30 Mar 2024 08:04:18 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 15E141C0DE5 for ; Sat, 30 Mar 2024 08:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711785858; cv=none; b=iK8EB34F+fwUDHaUTYBkBg88ITg0qU0pJj6zB+H08EOPYNOsiio5emlvF82g3W72Xc4ihv2jpQ3IucCmNYNrEo0NrfzNVYViqFGpNQfGB/dm8g9IxtlxjAVd3O+wFc0EXDt5y4LlZ1BK3uTtLXX40ep0d9XgsIPlfX5mxEdtE8c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711785858; c=relaxed/simple; bh=aNNgKrlB9TLwdmUDHleqTAzZkpPBKhO1F1BOcLb73Aw=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=R4YJxo2bsjlLORxtoQTgh7rE0Z8EvZfOAQy2OVMbza1Q5t4VJsRkvJaybUzheGkL1Mgq0nys8/sX7hu98lxzq60YBRxGq8chtdirrbVjoJ2X6PTSxs7EDmGjHWSyOJVXN0viOLsrnUQROjjEdkQS8K8VLYkeBHm7w3aYE9pYOaE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 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.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4V68qQ5m6yz1R92k; Sat, 30 Mar 2024 16:01:22 +0800 (CST) Received: from kwepemd200008.china.huawei.com (unknown [7.221.188.40]) by mail.maildlp.com (Postfix) with ESMTPS id 3947D1A0172; Sat, 30 Mar 2024 16:04:05 +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_256_GCM_SHA384) id 15.2.1258.28; Sat, 30 Mar 2024 16:04:04 +0800 Message-ID: <7953c617-2f74-faa4-2aa4-c6ef9de2c28e@huawei.com> Date: Sat, 30 Mar 2024 16:04:03 +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: Jan Kara , yangerkun , "Theodore Y . Ts'o" CC: , , , References: <20231230070654.178638-1-yangerkun@huaweicloud.com> <20240221111852.olo7jeycctz7xntj@quack3> From: yangerkun In-Reply-To: <20240221111852.olo7jeycctz7xntj@quack3> 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) 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 >> >>