Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3566950rdh; Mon, 27 Nov 2023 18:45:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHM1UDeImkuKK4nw5IN0gHwO3AN3/GOKpyiC/ETKINWe1isZXpuQqZV3Re0BjtD25ynf8c9 X-Received: by 2002:a17:903:2444:b0:1cf:da41:729c with SMTP id l4-20020a170903244400b001cfda41729cmr4598835pls.56.1701139538969; Mon, 27 Nov 2023 18:45:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701139538; cv=none; d=google.com; s=arc-20160816; b=QOaT5qx24dNtIEbTetU40QiviB47FvCq1UjiyHUkEbQmwui9wt3VhCcbaTsgFWXanA kfi+V7kmqX6DuXilIy9xVv0TUKsKcWuNlO9qwAX/7jXxpYa5VgGwBV1q1o8/SJkSap1O 5p9VNEvj+r24TxPeCSuANeml4W1EWCVTEd1AiaxqfjsGy3xfgBgk6gjhs3dq6KfvHBf+ NkEC1N51XA7IX4s+hkimD8kVFTAKn+D3PUoselFYiqwt5PwCA5NzCT/laDMfBOOzn84W snclJwGsAH2JJrEELQVUVs4S6J4TbeOWEj4XWABtWusx969rvcyBbDuj6e0f07ot2NAE o5JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=uBgIx66JgbxS00z7d61Bmc74Zo2vZIf9EdPtiYw/aXQ=; fh=HGC0jBRpJrx+6V6Uj25tJTvJ/lKS43s8EhYYDkGliX8=; b=BdJOTBZOtYSiPzgHc1JrqF0RKPTPfLIbAlMQFXzQDDOE5+9ea8eRE3x4IohDTL3WCO hBy/+tMH9LaPoQ7V8RNYkdorkh/YcyB0hgTze354s+872VUtCh0jgcgD2N5oFeIBBtTV B3RiV0ZREOe//G9x7UiELubUu2N+/7AkR/GN8UDPnYDPl+x0Y97VjWycp7mQmzByT6m9 fwm7BhrrgENOZlWwrdIAI0nDDkoQ4vAaI1IbTJZzZXlmO5YYpDN/rW5loM0bJzTY+ZAE W4UpKEd1u7oLbzXeIB4IynKjxJhjD+QDInaltEFAmba1Ad4Nb9OIQb81uF81YNw+IMhb k7bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="m91MnMx/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id h5-20020a170902b94500b001c5de4a5b4esi10592372pls.597.2023.11.27.18.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 18:45:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="m91MnMx/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3331E8083491; Mon, 27 Nov 2023 18:45:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234455AbjK1CpQ (ORCPT + 99 others); Mon, 27 Nov 2023 21:45:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbjK1CpP (ORCPT ); Mon, 27 Nov 2023 21:45:15 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CE5A18B for ; Mon, 27 Nov 2023 18:45:21 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-54ba86ae133so213162a12.2 for ; Mon, 27 Nov 2023 18:45:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701139520; x=1701744320; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=uBgIx66JgbxS00z7d61Bmc74Zo2vZIf9EdPtiYw/aXQ=; b=m91MnMx/rtBLAwu6R8f0W/0nNOLu5RfsFZ+iFiFAgqQnoCfCTDWPDnk7NR2YSposUp qK2gbkvX5XpzTPD6TbxMlOXh7r6/jsHJBliQhlBs4UkLzHc4Q6z1OVSHjKScz61fAVzV Q47pjmvSwn8Z93zewNvU6sgO1uyBBNBXxvmMeFP+JR+/bctYTozxgQZPXVsTm6vz9hvt 0Qi5/QxXFOGOA7CYt141pVYUOvJXA+9F6iOkaU/GBRZQz2oYQmoNETz8ms+yjM70DlGn 7oEnVa+S7AKf8AlLI5aAxr3gVuQTFBm3cJ8oGCTq/DU0SKbLZC8AsYWRIq3yYzrFWCaj jDOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701139520; x=1701744320; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uBgIx66JgbxS00z7d61Bmc74Zo2vZIf9EdPtiYw/aXQ=; b=b2WuUIBJF33OXyFCGqRd17/vvfNupU63tzJsDl6cY5Wcn5KU6b/GVys546iB5iOgcz JSK08h4DzE8OjuwX/gNCzXXAkoz2oSOjWIGC8KuZb2srhJJRoerrn2eZ0885F3N4ry4z GAQ/Wdu4+uqKNfqNX3vMebeLyXzKiMZFOReDYXuPbXq4slQ27etoE2oJfgNR5qoqUnaK bUYQ8+q9AR2VjPXZ93D0rXhDZp0lTf1njQdXutAPXrQu9jGsan8n2l46gAWdY3k+tH60 6ZrPMYtbdTd9uoHrD2Dkkg6d1xFLU/9t2J+NxxoaOTNylHVWw92d/SOwo1BwVePFMlQi 2acA== X-Gm-Message-State: AOJu0YyDRVi3vcCJnBAMt/U121U1x3c3nXb1kxM8Ci0WQNHnmPFnNUKw T+Y0pR7iFJFUlKMT7M1O8ral04xg+jxGIn/c+5g= X-Received: by 2002:a05:6402:3585:b0:54b:592c:c318 with SMTP id y5-20020a056402358500b0054b592cc318mr4986308edc.34.1701139519706; Mon, 27 Nov 2023 18:45:19 -0800 (PST) MIME-Version: 1.0 References: <1700788128-29002-1-git-send-email-zhiguo.niu@unisoc.com> In-Reply-To: From: Zhiguo Niu Date: Tue, 28 Nov 2023 10:45:08 +0800 Message-ID: Subject: Re: [PATCH] f2fs: show more discard stat by sysfs To: Chao Yu Cc: Zhiguo Niu , jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, hongyu.jin@unisoc.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 27 Nov 2023 18:45:32 -0800 (PST) Dear Chao, On Tue, Nov 28, 2023 at 10:13=E2=80=AFAM Chao Yu wrote: > > On 2023/11/24 9:08, Zhiguo Niu wrote: > > The current pending_discard attr just only shows the discard_cmd_cnt > > information, which is not very meaningful. More discard information > > can be shown so that we can check them through sysfs when needed. > > What about adding this entry to /sys/fs/f2fs//stat/? I think it is ok! The purpose of this patch is to obtain f2fs discard related status when necessary. Because sys/kernel/debug/f2fs/status cannot be used on the user version, I will change it according to your suggestion. > > > > > Signed-off-by: Zhiguo Niu > > --- > > fs/f2fs/sysfs.c | 21 +++++++++++++++------ > > 1 file changed, 15 insertions(+), 6 deletions(-) > > > > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c > > index 417fae96..f98e680 100644 > > --- a/fs/f2fs/sysfs.c > > +++ b/fs/f2fs/sysfs.c > > @@ -134,13 +134,22 @@ static ssize_t cp_status_show(struct f2fs_attr *a= , > > return sysfs_emit(buf, "%x\n", le32_to_cpu(F2FS_CKPT(sbi)->ckpt_f= lags)); > > } > > > > -static ssize_t pending_discard_show(struct f2fs_attr *a, > > +static ssize_t discard_stat_show(struct f2fs_attr *a, > > struct f2fs_sb_info *sbi, char *buf) > > { > > - if (!SM_I(sbi)->dcc_info) > > + struct discard_cmd_control *dcc =3D SM_I(sbi)->dcc_info; > > + > > + if (!dcc) > > return -EINVAL; > > - return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read( > > - &SM_I(sbi)->dcc_info->discard_cmd_cnt)); > > It's better to keep the old one for any potential user. > > > + > > + return sysfs_emit(buf, "%llu, %llu, %llu, %u\n", > > + (unsigned long long)atomic_read( > > + &dcc->discard_cmd_cnt), > > + (unsigned long long)atomic_read( > > + &dcc->issued_discard), > > + (unsigned long long)atomic_read( > > + &dcc->queued_discard), > > + dcc->undiscard_blks); > > } > > > > static ssize_t gc_mode_show(struct f2fs_attr *a, > > @@ -1016,7 +1025,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_a= ttr *a, > > F2FS_GENERAL_RO_ATTR(encoding); > > F2FS_GENERAL_RO_ATTR(mounted_time_sec); > > F2FS_GENERAL_RO_ATTR(main_blkaddr); > > -F2FS_GENERAL_RO_ATTR(pending_discard); > > +F2FS_GENERAL_RO_ATTR(discard_stat); > > It needs to adjust Documentation/ABI/testing/sysfs-fs-f2fs. > > Thanks, > > > F2FS_GENERAL_RO_ATTR(gc_mode); > > #ifdef CONFIG_F2FS_STAT_FS > > F2FS_GENERAL_RO_ATTR(moved_blocks_background); > > @@ -1074,7 +1083,7 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_a= ttr *a, > > ATTR_LIST(discard_urgent_util), > > ATTR_LIST(discard_granularity), > > ATTR_LIST(max_ordered_discard), > > - ATTR_LIST(pending_discard), > > + ATTR_LIST(discard_stat), > > ATTR_LIST(gc_mode), > > ATTR_LIST(ipu_policy), > > ATTR_LIST(min_ipu_util),