Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4585559pxu; Wed, 9 Dec 2020 23:37:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnZC+PgfqCFIvePsvsmrVpRYOp5gifp076TNid9ib5UqfabkqqcRkY3sODje9pkLCNdwNt X-Received: by 2002:a05:6402:1383:: with SMTP id b3mr5394423edv.100.1607585820602; Wed, 09 Dec 2020 23:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607585820; cv=none; d=google.com; s=arc-20160816; b=JRxe8M46ygaM+t5z7dkf3NhXeBCp6OP8zR1rJonQnYXROguRAiguFa+8JiU3Y3Wswg geWJzD6JTb4TWkOC/Cw2QBrWmpdctQhqh9qWq4PiIy3TNIDSACPo4I8q4LSQUX9TBnvJ c0+Ndu3Bf+2km/DXCSXo+zzMNiJZ4GWd5WUzapYOF3g35gRRMV+fqaTsZWXnIX1NhCGJ RNVgHkCDmXf8G452OqME87CAOK6KtrGEtSYosQNwFsMftLXiuQMgdZd5IVIRpzYTBqwq xbfOmBX8TzKPatRx1SQ/tyicLlMYzB42YnmUmGgdshcn04NQc+W0/cHG3A91QRH3OOw2 /DUQ== 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=aimx0BLJLxBjHxW+EpCX7EfCKvg0LTgW7mZFasNk/TA=; b=ATRUgiBxX3si1tREhk8Qr+ewnvnSXmdU+MmuSvo1G2wDIn3v22IF2Dj5R70PllDT/O BGqiJumgcqtF6B7acXCIAleZmLi676ymP13eeXbUehec4Gvorp+5q8DZoLQACSf6IX0Q 30uY41psPE2mFnhGwKU48V+OS78z+n34DeBn3guGbJgWg+WAqccfTtTTOH9UEQ13Y2gO LpHHiXrUAZNemvocREa4Merfg93i9ch2lnA7xZjRVVL82+/qEPJAJL6aR6gLdNngkyzU 4I1stWHDp7GHWs1zSFlJv4unCwV9KLmbnJsWkg9ZtlhEHgbbkpKsULJolPyLGefI6BVu DZSg== 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 g18si2218743edp.56.2020.12.09.23.36.37; Wed, 09 Dec 2020 23:37:00 -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 S1729976AbgLJGmW (ORCPT + 99 others); Thu, 10 Dec 2020 01:42:22 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:9053 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726686AbgLJGmW (ORCPT ); Thu, 10 Dec 2020 01:42:22 -0500 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: CC: , , , Chao Yu Subject: [PATCH v3 5/5] f2fs: introduce sb_status sysfs node 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 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 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