Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2894116pxu; Mon, 7 Dec 2020 20:12:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzR9kxCBky/ZDcyiqTJvnH+NpMtTYvg5zU4NF2sPTJ0iBxMqeb4cW69bz28JnxCm00ofGDM X-Received: by 2002:a17:906:2602:: with SMTP id h2mr21255082ejc.358.1607400740073; Mon, 07 Dec 2020 20:12:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607400740; cv=none; d=google.com; s=arc-20160816; b=n4pDL3G47PdDuq5ruCIt6zU6iC6RPO8572J+2k8g321/rvgOrlJveG4E/8xj7lBZB3 tDupNnLIeE48V9DdoRaxwzDhCYmPqsOGLLqHr3OjsV44+vv6OZyZKCigPaLvuCVmquJI MFfzVul5JLKJbvoMfhMiWWqqq/8BKDs7nAN0BocYT/pmDJO6BxbF4xXF63NIHBo1GF2I pgp2g2cXBiVGbUzC74UX87we2KlZLcN8BV4QLQt8NQ+RaqERbhx1R7E1ez7NW+Nha3De hw5kynEETu45IG8v14hmdhHG2Qh0SQooJSmz0YAePAatsI/kutsG8AGEbnN1mIYN8gKX onlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=KcZuF+/B4GAWkfGWtv6VwrBjnUMJ7HIM0YYISEbfkr8=; b=r6GMlTSjZgUSPq/eZKWLGjhd0Bmay1hLhCRNc+siM5uHLKZpnPsBie+3ciGodV17hM +Uw3Pdwrs0tc4AdFJKpas0KjG2cxg5316GEyYfF0IA23/DX+yJmY5QaUGdMrgBv2yLcz Ri6Dfp6EfprumuqUYmmuuMWup0+h4X4BvM4rczNKbE16m7zISvhRy3UVnfIyjiH7jNZT WHJ/PNUIK/n2sq25pwGpmOinc7aKdJoxjfL7xkfPZyBw49wLoNvmS5WV/RhFa5flXTDi 6J65ZlGybpQLRi9Urj8ieGtiOD26hhi5lN1fhmSprI+Hxuaux0Q/RHlwWE2Xvez7zxi2 UBAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz16si7061148ejb.373.2020.12.07.20.11.57; Mon, 07 Dec 2020 20:12:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbgLHDlm (ORCPT + 99 others); Mon, 7 Dec 2020 22:41:42 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8723 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbgLHDll (ORCPT ); Mon, 7 Dec 2020 22:41:41 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CqmCl3KNDzkmkY; Tue, 8 Dec 2020 11:40:19 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Tue, 8 Dec 2020 11:40:52 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH] f2fs: introduce sb_status sysfs node Date: Tue, 8 Dec 2020 11:40:40 +0800 Message-ID: <20201208034040.67658-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce /sys/fs/f2fs//stat/sb_status to show superblock status in real time. Signed-off-by: Chao Yu --- Documentation/ABI/testing/sysfs-fs-f2fs | 5 ++++ fs/f2fs/sysfs.c | 36 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 3dfee94e0618..57ab839dc3a2 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -377,3 +377,8 @@ Description: This gives a control to limit the bio size in f2fs. Default is zero, which will follow underlying block layer limit, whereas, if it has a certain bytes value, f2fs won't submit a bio larger than that size. + +What: /sys/fs/f2fs//stat/sb_status +Date: December 2020 +Contact: "Chao Yu" +Description: Show status of f2fs superblock in real time. diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index ebca0b4961e8..1b85e6d16a94 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -101,6 +101,40 @@ static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a, sbi->sectors_written_start) >> 1))); } +#define SB_STATUS(s) (s ? "yes" : "no") +static ssize_t sb_status_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + return sprintf(buf, "IS_DIRTY: %s\n" + "IS_CLOSE: %s\n" + "IS_SHUTDOWN: %s\n" + "IS_RECOVERED: %s\n" + "IS_RESIZEFS: %s\n" + "NEED_FSCK: %s\n" + "POR_DOING: %s\n" + "NEED_SB_WRITE: %s\n" + "NEED_CP: %s\n" + "CP_DISABLED: %s\n" + "CP_DISABLED_QUICK: %s\n" + "QUOTA_NEED_FLUSH: %s\n" + "QUOTA_SKIP_FLUSH: %s\n" + "QUOTA_NEED_REPAIR: %s\n", + SB_STATUS(is_sbi_flag_set(sbi, SBI_IS_DIRTY)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_IS_CLOSE)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_IS_RECOVERED)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_IS_RESIZEFS)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_NEED_FSCK)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_POR_DOING)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_NEED_SB_WRITE)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_NEED_CP)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_CP_DISABLED)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_CP_DISABLED_QUICK)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_QUOTA_NEED_FLUSH)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH)), + SB_STATUS(is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR))); +} + static ssize_t features_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { @@ -711,7 +745,9 @@ static struct attribute *f2fs_feat_attrs[] = { }; ATTRIBUTE_GROUPS(f2fs_feat); +F2FS_GENERAL_RO_ATTR(sb_status); static struct attribute *f2fs_stat_attrs[] = { + ATTR_LIST(sb_status), NULL, }; ATTRIBUTE_GROUPS(f2fs_stat); -- 2.29.2