Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29794581rwd; Wed, 5 Jul 2023 18:08:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlGB182Kq+aeCwY8UbbagpF3fbkiMfCWGmh2sau2iPcJW4WoDjKmvkOfb8QlrnTdSGgVOPzE X-Received: by 2002:a05:6808:148e:b0:3a3:3d8f:6b15 with SMTP id e14-20020a056808148e00b003a33d8f6b15mr327537oiw.22.1688605738070; Wed, 05 Jul 2023 18:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688605738; cv=none; d=google.com; s=arc-20160816; b=0TLhs4ARyX3BLD1qzFsw57AgDpDEtX6/lh6qplHuD3ZI/vTvJ0S9SpbM65mQ/4Zj/s 52jcdwa8uHBYZtc+ksVjrkxaQb99A4n9yAlvz9zqs0/0OBU9cdFUSiDyd/boaD4L4IMZ Moxe13zBBe5/xkWMhfFGMmYKEBWd70RpyhwHQIlYK4Ul1z3YbpUI9+SuEX6qsYzrv+nc QIdGa3UoZnnXnsCFwlOWxPpvMalCQYKzmNt2YpUyTfA6nwdDu8B8ZIrf3YlkfmFdSPMK yZA3bwWxMkoeAfU5UGi7SvGKFRl9SvOHQvTL1hpT1thzJwBw1XUIMY8VFe+xYdLEhy0/ Ip9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=VERPLtZ41/MpnO/LfB1wKmGDvnXekWKRfPmacfxBfVQ=; fh=V3iHxQYHK8jTWdIKJQ9B8C3tSIIUA7cUxCLSi/QWgDg=; b=0oZcfYxPktPVCMhbI4HvqGphafI22qshfSoh8/t2vT1k/ePYQMA35fzq5/xH091DA2 CMsEEyM5rZp5fRdld220fdUsYvsFZYpTUjNITIdZGCjMvMe4MXKRu3c8uk7aJEsEsq0P pmEZDdtG4Ifqv7JvMo/xoeGlmwjYMVUrEzFm1UisEY9im1eh8CxYH09p3LVMQ2oDhjJ/ RD8J03Oqm8et+dHj4sLinOZKbluFc+4ftDfVy4sL2pbsNRvbmDsAQGal7rtYxBHOl2WC lLTlmg3fHej3tQeRwASfDT1ESMCf2PVfbr9Pau/MIGdaFU2r5IrR7BqijnoWe3qVxwX/ khGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bl1SkOIp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i70-20020a638749000000b00533ffeaca3dsi425311pge.40.2023.07.05.18.08.45; Wed, 05 Jul 2023 18:08:58 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bl1SkOIp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232505AbjGFAqw (ORCPT + 99 others); Wed, 5 Jul 2023 20:46:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjGFAqv (ORCPT ); Wed, 5 Jul 2023 20:46:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A153171A for ; Wed, 5 Jul 2023 17:46:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 984B7617D5 for ; Thu, 6 Jul 2023 00:46:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1787EC433C7; Thu, 6 Jul 2023 00:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688604409; bh=K7XtV0MJ+Qrk4bv1eFylFG3uLMZzjyg4PV7PAJHk7Pk=; h=Date:To:Cc:References:From:Subject:In-Reply-To:From; b=Bl1SkOIpVGW6hcGbc5cMMbxqYDDiCdcSfZDOEME5PNVHWUXtVrd7PwkgRrH8kaOQe akXjeHKdJglMoNRnv49qPMCIJv6IlXXl7HTEG3HHY9vA832LkWy6dskn3Pix4zb1GN Ac8LXbPHO4oZdVnAy7WYoyqteIRAmhH1V+MjPsN4kU2ebT/yMEMDJ53iLhHRgnqlUg N5A9BopyHz1FoMhK56fICuN0So84NopPypNQSPfxVZKYDpFETLe5NnTPncOJErG0WR RgFq6/v3O1zqwbGjJeuBYGSZzHEG5oMHWKQSxdHUYj+0Wi05QlLH5m2JsVtFZTiVbX 47ZbChLsDUvyw== Message-ID: Date: Thu, 6 Jul 2023 08:46:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: Jaegeuk Kim Cc: Daejun Park , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20230613203947.2745943-1-jaegeuk@kernel.org> <50d5fa8c-4fe9-8a03-be78-0b5383e55b62@kernel.org> <65143701-4c19-ab66-1500-abd1162639cd@kernel.org> From: Chao Yu Subject: Re: [f2fs-dev] [PATCH v2] f2fs: do not issue small discard commands during checkpoint In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/7/6 1:30, Jaegeuk Kim wrote: > On 07/04, Chao Yu wrote: >> On 2023/7/4 18:53, Jaegeuk Kim wrote: >>> On 07/03, Chao Yu wrote: >>>> On 2023/6/15 0:10, Jaegeuk Kim wrote: >>>>> If there're huge # of small discards, this will increase checkpoint latency >>>>> insanely. Let's issue small discards only by trim. >>>>> >>>>> Signed-off-by: Jaegeuk Kim >>>>> --- >>>>> >>>>> Change log from v1: >>>>> - move the skip logic to avoid dangling objects >>>>> >>>>> fs/f2fs/segment.c | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>>>> index 8c7af8b4fc47..0457d620011f 100644 >>>>> --- a/fs/f2fs/segment.c >>>>> +++ b/fs/f2fs/segment.c >>>>> @@ -2193,7 +2193,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, >>>>> len = next_pos - cur_pos; >>>>> if (f2fs_sb_has_blkzoned(sbi) || >>>>> - (force && len < cpc->trim_minlen)) >>>>> + !force || len < cpc->trim_minlen) >>>>> goto skip; >>>> >>>> Sorry for late reply. >>>> >>>> We have a configuration for such case, what do you think of setting >>>> max_small_discards to zero? otherwise, w/ above change, max_small_discards >>>> logic may be broken? >>>> >>>> What: /sys/fs/f2fs//max_small_discards >>>> Date: November 2013 >>>> Contact: "Jaegeuk Kim" >>>> Description: Controls the issue rate of discard commands that consist of small >>>> blocks less than 2MB. The candidates to be discarded are cached until >>>> checkpoint is triggered, and issued during the checkpoint. >>>> By default, it is disabled with 0. >>>> >>>> Or, if we prefer to disable small_discards by default, what about below change: >>> >>> I think small_discards is fine, but need to avoid long checkpoint latency only. >> >> I didn't get you, do you mean we can still issue small discard by >> fstrim, so small_discards functionality is fine? > > You got the point. Well, actually, what I mean is max_small_discards sysfs entry's functionality is broken. Now, the entry can not be used to control number of small discards committed by checkpoint. I think there is another way to achieve "avoid long checkpoint latency caused by committing huge # of small discards", the way is we can set max_small_discards to small value or zero, w/ such configuration, it will take checkpoint much less time or no time to committing small discard due to below control logic: f2fs_flush_sit_entries() { ... if (!(cpc->reason & CP_DISCARD)) { cpc->trim_start = segno; add_discard_addrs(sbi, cpc, false); } ... } add_discard_addrs() { ... while (force || SM_I(sbi)->dcc_info->nr_discards <= SM_I(sbi)->dcc_info->max_discards) { It will break the loop once nr_discards is larger than max_discards, if max_discards is set to zero, checkpoint won't take time to handle small discards. ... if (!de) { de = f2fs_kmem_cache_alloc(discard_entry_slab, GFP_F2FS_ZERO, true, NULL); de->start_blkaddr = START_BLOCK(sbi, cpc->trim_start); list_add_tail(&de->list, head); } ... } ... Thanks, > >> >> Thanks, >> >>> >>>> >>>> From eb89d9b56e817e3046d7fa17165b12416f09d456 Mon Sep 17 00:00:00 2001 >>>> From: Chao Yu >>>> Date: Mon, 3 Jul 2023 09:06:53 +0800 >>>> Subject: [PATCH] Revert "f2fs: enable small discard by default" >>>> >>>> This reverts commit d618ebaf0aa83d175658aea5291e0c459d471d39 in order >>>> to disable small discard by default, so that if there're huge number of >>>> small discards, it will decrease checkpoint's latency obviously. >>>> >>>> Also, this patch reverts 9ac00e7cef10 ("f2fs: do not issue small discard >>>> commands during checkpoint"), due to it breaks small discard feature which >>>> may be configured via sysfs entry max_small_discards. >>>> >>>> Fixes: 9ac00e7cef10 ("f2fs: do not issue small discard commands during checkpoint") >>>> Signed-off-by: Chao Yu >>>> --- >>>> fs/f2fs/segment.c | 4 ++-- >>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>>> index 14c822e5c9c9..0a313368f18b 100644 >>>> --- a/fs/f2fs/segment.c >>>> +++ b/fs/f2fs/segment.c >>>> @@ -2193,7 +2193,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, >>>> len = next_pos - cur_pos; >>>> >>>> if (f2fs_sb_has_blkzoned(sbi) || >>>> - !force || len < cpc->trim_minlen) >>>> + (force && len < cpc->trim_minlen)) >>>> goto skip; >>>> >>>> f2fs_issue_discard(sbi, entry->start_blkaddr + cur_pos, >>>> @@ -2269,7 +2269,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi) >>>> atomic_set(&dcc->queued_discard, 0); >>>> atomic_set(&dcc->discard_cmd_cnt, 0); >>>> dcc->nr_discards = 0; >>>> - dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; >>>> + dcc->max_discards = 0; >>>> dcc->max_discard_request = DEF_MAX_DISCARD_REQUEST; >>>> dcc->min_discard_issue_time = DEF_MIN_DISCARD_ISSUE_TIME; >>>> dcc->mid_discard_issue_time = DEF_MID_DISCARD_ISSUE_TIME; >>>> -- >>>> 2.40.1 >>>> >>>> >>>> >>>>> f2fs_issue_discard(sbi, entry->start_blkaddr + cur_pos,