Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27502739rwd; Tue, 4 Jul 2023 04:03:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGVlIo19G37jyAHdXzTxhoPndFF9Hu25379Qhl2239fLY9Y7LZtjh8G2fzD3MF+n2r6lItW X-Received: by 2002:a05:6870:970d:b0:1b0:1e3f:1369 with SMTP id n13-20020a056870970d00b001b01e3f1369mr13076239oaq.57.1688468600672; Tue, 04 Jul 2023 04:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688468600; cv=none; d=google.com; s=arc-20160816; b=kNe7w39jKHKz/Z36EJYWHSh1CnAbh9SWo8V4Ao9Wl96QSQ1X9pm0DkyKUFVX3W0DX4 R0++ZCt5M1GRbEnxLiAAc1ERNzr8s9FC13dZcI5ptE1sMN/E30McEMkl29c7GspXTRrW e9j0pJrMQanbySxH7aG6L0w3a9DV/uyfU4yTC7BHbDshMN1feB3bbRX3GlTf1lcf7uEb YWcVfsCaJAn2RLAyFN7N1csJP1e2aaXlPLob21NicjCwqN1a45g8DWjXmi0fT2138inK WE55PnBrA6sNC0nx4EzR7gw5pw5afS2z8y+QfO4OdNVrmM/Cvk79XrV2J3Ch3fncneD5 fNsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/vdJu810T88gjWr0Pp0vyzm5kb4JMUb5SU9d9S62fLQ=; fh=3xcBLyQ5WX9NQl2rgx5zfcmTK2Tq58wDFznWFTpPLZ8=; b=qR9wg8nyS2ue1icRKvKB+3YNzpDtJdCPgvuDa8NKqLaKeUgjzxOFKyKldNw0gLaknT 2sakhsXFEymDvlR/rLrtBmQuGnKj77WNCy7l3aBn2dL9/fEa9PUYnUIP7R8hNsmpsxc/ 20cWNH2fH0AIWwK6v8ALxl7iQJDXgFvUJDHztj1AZ1rnZ2naFkGv4aWCwc6GkydIX1tZ gxf0R/JcbTj2cRC1kpTKVdV7BsxAV2AYcbeSk++t7JOrTUHgPkbzgq0bTT1HSolA/G+q Gwbl7ex/x70lLIQpFboadXgIIY06/yTr4zxBP8ygk/mZaACSqaCbejv5/uYZtFE+oVPN KQrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YDTeWjlX; 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 v10-20020a655c4a000000b00553a95a48a1si20684449pgr.445.2023.07.04.04.03.04; Tue, 04 Jul 2023 04:03:20 -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=YDTeWjlX; 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 S230052AbjGDKxJ (ORCPT + 99 others); Tue, 4 Jul 2023 06:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbjGDKxI (ORCPT ); Tue, 4 Jul 2023 06:53:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D427E6E for ; Tue, 4 Jul 2023 03:53:07 -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 BAFB7611CB for ; Tue, 4 Jul 2023 10:53:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12DE0C433C7; Tue, 4 Jul 2023 10:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688467986; bh=die6ZmES6fy82wymKtHjkHnfAFbNdCjAo4pk5803uh0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YDTeWjlX0uF87RsqVfyyR7iW1vpr923L1RUUcpt3zHoVrnWZ6MeuhkUEgfv2DJwfO sEwXvWtCGAugJRpdMEEGR2LCGjUuAZskU+YFk8COvYIz6drfU+FWVDXlYFkCdcWw3r asGB5jrEY+sTpyoeBB+oZsdLs526ap81iiAa4dToCL1cOPBtyKsnYWCFl8g3ESOH5f tFZHkgB7qK1E1Iuxy1AkGZLxhY7C/KmATLtcwf1hwIkY/ahdW9R2itFkW3f49ywH8e Mpaydkm/yU8GPOad7FOx4T7PfD6oaVBqe/WGiaInGBrSuNoBXuaoNe1D4Zkzl1AyCj 4QJCvYZ+p//fw== Date: Tue, 4 Jul 2023 03:53:04 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Daejun Park , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [f2fs-dev] [PATCH v2] f2fs: do not issue small discard commands during checkpoint Message-ID: References: <20230613203947.2745943-1-jaegeuk@kernel.org> <50d5fa8c-4fe9-8a03-be78-0b5383e55b62@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50d5fa8c-4fe9-8a03-be78-0b5383e55b62@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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. > > 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,