Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3554320rdh; Mon, 27 Nov 2023 18:13:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEL5sumVrmx/T4ogrQDIFy8YI/j6VKqPXF5pDMvYxuvgUS9BXgrgUaOCny7jrIyoDLhangH X-Received: by 2002:a17:90b:4a45:b0:285:9d40:192e with SMTP id lb5-20020a17090b4a4500b002859d40192emr9371389pjb.6.1701137616228; Mon, 27 Nov 2023 18:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701137616; cv=none; d=google.com; s=arc-20160816; b=DhI5pnMm6HBYg3QQzryo8GGd3dmj+lDDBgcOGsKGnkei+Nolc7iDOZZegLdJCLptEr knbrXXbCMHPJa9LDlvs9dgaFVxmrKzDmJYp/cCSOyhq9lurrd1GIWrRyaoQub69UTsg/ M0AD8vyXNHR+Yk1V2+MYBsxWfvjtN+LCY0MwVr4yamUcF7GH14KOD799itXHQYMn23Ch piPtvaBBIGk8M311HobTAWNuoptduqusMAlTSzd38wxIs5Mk5rKlCfEhxNA/BKCMerll ngD6Ue7fPBJM520LuLMbfKcQi10yNAk0dB+UCZBvi9Xday3AFZwKaH3ENCOivqsgeHOC Wspg== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=8GImPcLcg5lIrHSA1sUddozesFNAizSxKlh0kyvdp60=; fh=M73uGObS6GgspJx3MJxUXGZbpw773rtpSv1n+l22qgI=; b=mRSMuwn/F6Tej3Nkq0bADlsKbnSfQ8KcC35HGCwGuG9vzPbEf7ezZr/624NWAQoeb3 XazGyTP+qjJZ3yXJzQ045BjX3Xqg7G20kJXMbBC83F87Mzn56nV3cMxweVKTVXHiWyUw QIkv7h0xikho+cUrdon1pCnqsSTbOg1lP6TdRoJo19CA3O64RVfKqIzSFjTj7cYcP1Qa qDt53uiiR07w8PkrIKGZLW+9sow0ihWmRPNMj2sLioBX2TH7hZzObOQk5e0EdLW9RRQg vYmROyAR2uTTiMNh7QEqH/KoBOa56TF9AcUnsPEXqBPJPpwiIKcGAQqRWbyR7ECH6ZG8 Fs5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NdRuarqJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id l9-20020a170902f68900b001cfd183c4c6si3290887plg.537.2023.11.27.18.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 18:13:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NdRuarqJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2C8938098FFF; Mon, 27 Nov 2023 18:13:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231952AbjK1CNK (ORCPT + 99 others); Mon, 27 Nov 2023 21:13:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbjK1CNI (ORCPT ); Mon, 27 Nov 2023 21:13:08 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57AE2C3 for ; Mon, 27 Nov 2023 18:13:15 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BD33C433C8; Tue, 28 Nov 2023 02:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701137594; bh=K00S5Yanj+6jxErg6y5RpnCOWOcJmkZS0lfYvqVWtPA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NdRuarqJvq8z+crp6qrhaQpkPN2NcSRbz5Xu4gr1Kyv5alhOCAAlO6VsauwkTCO6S mnkwiYAZBv00rorYRmfU5cnCsojjOZKeLgife0IlNYlJ3noepmE7K0dI7ioiyhO3TJ WcZcLIxPbEIq3m8IuTc+ukoNB7jeGKf9hwdQ+AsLPn8vpDrgJCgxGHVFj4GULVCm5x /MV824/mn7ORoBJbYT2yWMWs30agJdVNrPnbeaq0FkfTiVMx9YCNg5fygqvcIqayym YXhWFwFTw/iskvvATb0aXrLcyszoiuyR7HTZsxQlWTkdTY0rt+kE/IgL7IK+eUNUbi nzPtP0Gq0TvFg== Message-ID: Date: Tue, 28 Nov 2023 10:13:10 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH] f2fs: show more discard stat by sysfs Content-Language: en-US To: Zhiguo Niu , jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, niuzhiguo84@gmail.com, hongyu.jin@unisoc.com References: <1700788128-29002-1-git-send-email-zhiguo.niu@unisoc.com> From: Chao Yu In-Reply-To: <1700788128-29002-1-git-send-email-zhiguo.niu@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 27 Nov 2023 18:13:25 -0800 (PST) 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/? > > 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_flags)); > } > > -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 = 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_attr *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_attr *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),