Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05756C4361B for ; Thu, 10 Dec 2020 06:42:07 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F8D923B98 for ; Thu, 10 Dec 2020 06:42:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F8D923B98 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1knFeO-00041z-NC; Thu, 10 Dec 2020 06:42:04 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knFeL-00041q-Rx for linux-f2fs-devel@lists.sourceforge.net; Thu, 10 Dec 2020 06:42:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=aimx0BLJLxBjHxW+EpCX7EfCKvg0LTgW7mZFasNk/TA=; b=NMdjVTTc6//IIig1IdBuXWd4tH ztx+Cv+iBOBGL4DNGIWZqcvzuLciKT71k9NXxzZoxkrUYMjsIhHGW1Eq3oGsXM5O0N+Me6dhvFnu6 Ug6U6+8Zyc5TzYdHgdsnr+NMW7TZ+VAJiCGBvC4pJ8p8FDw4PtTfNfpC7abQJ0EVFrgQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=aimx0BLJLxBjHxW+EpCX7EfCKvg0LTgW7mZFasNk/TA=; b=K HJxLblhtfn9YxCLWpEISfmBe4sjK/q2NvfGWfQLIc/ZtKs7iaCPO6NY2N1RWR0geJh9mwhygoR+dG e1awOpML+/tdnsnRMo+SjnGxYjBRDWxnyEzZKTKwriqmtEL4LIgaVgh4G8CqxhYDux5N6QgrvtZbD tYzRMksI2o5CzmFk=; Received: from szxga05-in.huawei.com ([45.249.212.191]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1knFeF-008d95-Pp for linux-f2fs-devel@lists.sourceforge.net; Thu, 10 Dec 2020 06:42:01 +0000 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Cs47Q2TDBzhq3p; Thu, 10 Dec 2020 14:41:06 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Thu, 10 Dec 2020 14:41:31 +0800 From: Chao Yu To: Date: Thu, 10 Dec 2020 14:41:15 +0800 Message-ID: <20201210064115.47351-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected X-Headers-End: 1knFeF-008d95-Pp Subject: [f2fs-dev] [PATCH v3 5/5] f2fs: introduce sb_status sysfs node X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Introduce /sys/fs/f2fs//stat/sb_status to show superblock status in real time as a hexadecimal value. value sb status macro description 0x1 SBI_IS_DIRTY, /* dirty flag for checkpoint */ 0x2 SBI_IS_CLOSE, /* specify unmounting */ 0x4 SBI_NEED_FSCK, /* need fsck.f2fs to fix */ 0x8 SBI_POR_DOING, /* recovery is doing or not */ 0x10 SBI_NEED_SB_WRITE, /* need to recover superblock */ 0x20 SBI_NEED_CP, /* need to checkpoint */ 0x40 SBI_IS_SHUTDOWN, /* shutdown by ioctl */ 0x80 SBI_IS_RECOVERED, /* recovered orphan/data */ 0x100 SBI_CP_DISABLED, /* CP was disabled last mount */ 0x200 SBI_CP_DISABLED_QUICK, /* CP was disabled quickly */ 0x400 SBI_QUOTA_NEED_FLUSH, /* need to flush quota info in CP */ 0x800 SBI_QUOTA_SKIP_FLUSH, /* skip flushing quota in current CP */ 0x1000 SBI_QUOTA_NEED_REPAIR, /* quota file may be corrupted */ 0x2000 SBI_IS_RESIZEFS, /* resizefs is in process */ Signed-off-by: Chao Yu --- v3: - just print one single value as output Documentation/ABI/testing/sysfs-fs-f2fs | 21 +++++++++++++++++++++ fs/f2fs/sysfs.c | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 3dfee94e0618..9b2f93eda1f8 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -377,3 +377,24 @@ 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. + + value sb status macro description + 0x1 SBI_IS_DIRTY, /* dirty flag for checkpoint */ + 0x2 SBI_IS_CLOSE, /* specify unmounting */ + 0x4 SBI_NEED_FSCK, /* need fsck.f2fs to fix */ + 0x8 SBI_POR_DOING, /* recovery is doing or not */ + 0x10 SBI_NEED_SB_WRITE, /* need to recover superblock */ + 0x20 SBI_NEED_CP, /* need to checkpoint */ + 0x40 SBI_IS_SHUTDOWN, /* shutdown by ioctl */ + 0x80 SBI_IS_RECOVERED, /* recovered orphan/data */ + 0x100 SBI_CP_DISABLED, /* CP was disabled last mount */ + 0x200 SBI_CP_DISABLED_QUICK, /* CP was disabled quickly */ + 0x400 SBI_QUOTA_NEED_FLUSH, /* need to flush quota info in CP */ + 0x800 SBI_QUOTA_SKIP_FLUSH, /* skip flushing quota in current CP */ + 0x1000 SBI_QUOTA_NEED_REPAIR, /* quota file may be corrupted */ + 0x2000 SBI_IS_RESIZEFS, /* resizefs is in process */ diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index ebca0b4961e8..d5198689ab02 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -101,6 +101,12 @@ static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a, sbi->sectors_written_start) >> 1))); } +static ssize_t sb_status_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + return sprintf(buf, "%lx\n", sbi->s_flag); +} + static ssize_t features_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { @@ -711,7 +717,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 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel