Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2088015pxb; Sun, 10 Jan 2021 23:55:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuqfNKGuuKJCleY6ni6Fcx2Zs6lDE7BxsEkvYpQ1WiAdRnxTHR5xpgBd1Am+eotBrd91kH X-Received: by 2002:aa7:d0c5:: with SMTP id u5mr12655105edo.46.1610351705927; Sun, 10 Jan 2021 23:55:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610351705; cv=none; d=google.com; s=arc-20160816; b=nP184MgkXyDgq1vBDnvbVURx6iuDZayxI2wl/00aM1KT/TIendps/M4vE3E8T1D/Li s9JcoOYwCcsngPF/NzPT+P3eE/juqXSEQcf3nU8uN7wi9uIsLzVYHLgwUBTDpsRssy1J np+ly8eUpiZvNq/0lUw7XkMW401cW0hFf9oKd/lMX6ujTbNsusOyj4O/XtnM6DiaiAKc +tfVxz7GNx27FeAH8bd3U27XQmwlifpEY1O5e6ZkO3Oa68hdJT+963Uemj5TZsszYZkc 1b4/IEo8ciNXvJCy150/okMt9MxFC3dUiS/C6DX+t+qmt7vUIQNEcOPTesiA5urC6WEq egPg== 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=qX6G5m9GYFZ+YB96hQhxsWYphkD+Rc/8QLpcx/6H8Z4=; b=gpcqaaqqOvhDfExdL2CsUOYSn88y38MxVGS8EFzCLQfQ8L2f/bhCEmfObemn3R2cuv V76BM7fT4yAaTi6CJ10NHzfS9bDkh2U0ThRi1G37SiklZK7yYqgOesmrTGJEiumd5sex mCt3faZerAZjont8ICeMWhmVNE02wERwh/DgE8VvrOL5UjOaR6OV8ooa09DpjGLvuLWN /92Mdog5mnIig3NRIhUs3y5YqQgoc6V/zVtu2fceRb0+1MZqcee699McrqB1H1Wds2k4 pcEjY/HHqwqB8eoNgGqFhKv5xrx4hbmVSo/TINDEoUW83Rt5yfF4Oc9/nrj0J+0zDSht zcQQ== 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 q22si6363194edr.578.2021.01.10.23.54.42; Sun, 10 Jan 2021 23:55:05 -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 S1727738AbhAKHvp (ORCPT + 99 others); Mon, 11 Jan 2021 02:51:45 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:11376 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727723AbhAKHvp (ORCPT ); Mon, 11 Jan 2021 02:51:45 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DDm8C1WmFz7SfQ; Mon, 11 Jan 2021 15:50:03 +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.498.0; Mon, 11 Jan 2021 15:50:52 +0800 From: Chao Yu To: CC: , , , , Chao Yu Subject: [PATCH v4 5/5] f2fs: introduce sb_status sysfs node Date: Mon, 11 Jan 2021 15:50:17 +0800 Message-ID: <20210111075017.82370-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 --- v4: - fix linux-next build (htmldocs) warning: WARNING: Inline emphasis start-string without end-string. - reformat to fit rendering in html. Documentation/ABI/testing/sysfs-fs-f2fs | 23 +++++++++++++++++++++++ fs/f2fs/sysfs.c | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 3dfee94e0618..e5918c93f3bf 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -377,3 +377,26 @@ 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 bd1174ed2e6f..f39874d512ea 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -96,6 +96,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) { @@ -702,7 +708,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