From patchwork Tue Dec 19 02:21:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiguo Niu X-Patchwork-Id: 180712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1669597dyi; Mon, 18 Dec 2023 18:22:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGw0KijzoPSnoXy5ohL93iFZgoaeopgABkNe9Rt1lfp+DvrY7rFYyYiZU/XUhETilFVgykz X-Received: by 2002:a05:620a:20c9:b0:77b:bfc4:4e13 with SMTP id f9-20020a05620a20c900b0077bbfc44e13mr532430qka.18.1702952549992; Mon, 18 Dec 2023 18:22:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702952549; cv=none; d=google.com; s=arc-20160816; b=yXL0evyfF4VeFpOY/AoDvP2anDXlMtIHfp96wvdPRMz1cb+Q4o7mgjXuHgdn+fTRUD 2L/U2Db5XQUP3jg7DbShLIcXZT0mPg9gAsg6yHWutjmMk1nEMKPxPT0uIdZx5QaGXEli 6XqbqDHNNtObRZrCKfCjHPhBZKs3WPs3OJoTsw/xlQfTb+yJh3GyQSrFFCD8xaAu+E8t evsMQbx28aqapWG1wSc/Bftz3X8ONSEZbOI4U7IFTS7gS07/9K/HC7ogBsCTf/DXf2pv yZutF0VPzqLbimOa6mq8pdGP35pzzq8kCjVEYqTJ8lwINI1hI2gG7nN6v3qG2m4goFBB XaqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from; bh=eC7Rr/fW2X8leBLS+pCX7C5as7ZLIGzdQALlj8zWCtY=; fh=JkrfyujbIDmycozXR7ZDiVuf6xBFur6C1+1NEIITJEI=; b=VMsU9JRP36aqt/TvyEoMk//cfL565LKxCOUR70Inoib+p3vxSImDo784sMWqBoaPja 8lkVe/Cn8QqeTkIgcPyzkemCd56TLRVMZTRzZki4jJq0hgtmwxBRmQiPAAupm6iQDgAL MxNjvJnuYjFo20RL6zdDQ5Ft4Wh3mfvrhCy/f55Jlf7IuDAx1B7X9DUvNphg9DRKJKO8 it1haMJy7HGvIJ6cXSNqaQ7fKgfosOZB19LGawcH/kLEc+vSjLnur8/Qk0+2sduB1Mcy cBJEoyjF6obDxczqFc+Me9lD+Q3QbWKk0uP+/T5qymdKz/isPFPqex1qtLoVvGT4SEhX M+Qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4592-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e12-20020a05620a014c00b0077f8d25d39fsi14471101qkn.592.2023.12.18.18.22.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 18:22:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4592-ouuuleilei=gmail.com@vger.kernel.org" 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 C0FD21C216C6 for ; Tue, 19 Dec 2023 02:22:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B024D5253; Tue, 19 Dec 2023 02:22:15 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) (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 5D4174401 for ; Tue, 19 Dec 2023 02:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 3BJ2LOSe060334; Tue, 19 Dec 2023 10:21:24 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4SvKz30Xv3z2P0R2m; Tue, 19 Dec 2023 10:15:11 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 19 Dec 2023 10:21:21 +0800 From: Zhiguo Niu To: , CC: , , , , Subject: [PATCH V4] f2fs: show more discard status by sysfs Date: Tue, 19 Dec 2023 10:21:04 +0800 Message-ID: <1702952464-22050-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 3BJ2LOSe060334 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785675173381596507 X-GMAIL-MSGID: 1785675173381596507 The current pending_discard attr just only shows the discard_cmd_cnt information. More discard status can be shown so that we can check them through sysfs when needed. Signed-off-by: Zhiguo Niu --- changes of v2: Improve the patch according to Chao's suggestions. changes of v3: Add a blank line for easy reading. changes of v4: Split to three entries --- --- Documentation/ABI/testing/sysfs-fs-f2fs | 15 +++++++++++++++ fs/f2fs/sysfs.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 4f1d4e6..606a298 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -159,6 +159,21 @@ Date: November 2021 Contact: "Jaegeuk Kim" Description: Shows the number of pending discard commands in the queue. +What: /sys/fs/f2fs//issued_discard +Date: December 2023 +Contact: "Zhiguo Niu" +Description: Shows the number of issued discard. + +What: /sys/fs/f2fs//queued_discard +Date: December 2023 +Contact: "Zhiguo Niu" +Description: Shows the number of queued discard. + +What: /sys/fs/f2fs//undiscard_blks +Date: December 2023 +Contact: "Zhiguo Niu" +Description: Shows the total number of undiscard blocks. + What: /sys/fs/f2fs//max_victim_search Date: January 2014 Contact: "Jaegeuk Kim" diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 7099ffa..666efdd 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -143,6 +143,33 @@ static ssize_t pending_discard_show(struct f2fs_attr *a, &SM_I(sbi)->dcc_info->discard_cmd_cnt)); } +static ssize_t issued_discard_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + if (!SM_I(sbi)->dcc_info) + return -EINVAL; + return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read( + &SM_I(sbi)->dcc_info->issued_discard)); +} + +static ssize_t queued_discard_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + if (!SM_I(sbi)->dcc_info) + return -EINVAL; + return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read( + &SM_I(sbi)->dcc_info->queued_discard)); +} + +static ssize_t undiscard_blks_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + if (!SM_I(sbi)->dcc_info) + return -EINVAL; + return sysfs_emit(buf, "%u\n", + SM_I(sbi)->dcc_info->undiscard_blks); +} + static ssize_t gc_mode_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { @@ -1025,6 +1052,9 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a, F2FS_GENERAL_RO_ATTR(mounted_time_sec); F2FS_GENERAL_RO_ATTR(main_blkaddr); F2FS_GENERAL_RO_ATTR(pending_discard); +F2FS_GENERAL_RO_ATTR(issued_discard); +F2FS_GENERAL_RO_ATTR(queued_discard); +F2FS_GENERAL_RO_ATTR(undiscard_blks); F2FS_GENERAL_RO_ATTR(gc_mode); #ifdef CONFIG_F2FS_STAT_FS F2FS_GENERAL_RO_ATTR(moved_blocks_background); @@ -1084,6 +1114,9 @@ static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a, ATTR_LIST(max_ordered_discard), ATTR_LIST(discard_io_aware), ATTR_LIST(pending_discard), + ATTR_LIST(issued_discard), + ATTR_LIST(queued_discard), + ATTR_LIST(undiscard_blks), ATTR_LIST(gc_mode), ATTR_LIST(ipu_policy), ATTR_LIST(min_ipu_util),