public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, chao@kernel.org
Subject: Re: [PATCH RESEND v2 5/5] f2fs: introduce sb_status sysfs node
Date: Wed, 9 Dec 2020 08:04:05 -0800	[thread overview]
Message-ID: <X9D1dXVwKFvfHpP9@google.com> (raw)
In-Reply-To: <20201209084328.30416-5-yuchao0@huawei.com>

On 12/09, Chao Yu wrote:
> Introduce /sys/fs/f2fs/<devname>/stat/sb_status to show superblock
> status in real time as below:
> 
> IS_DIRTY:		no
> IS_CLOSE:		no
> IS_SHUTDOWN:		no
> IS_RECOVERED:		no
> IS_RESIZEFS:		no
> NEED_FSCK:		no
> POR_DOING:		no
> NEED_SB_WRITE:		no
> NEED_CP:		no
> CP_DISABLED:		no
> CP_DISABLED_QUICK:	no
> QUOTA_NEED_FLUSH:	no
> QUOTA_SKIP_FLUSH:	no
> QUOTA_NEED_REPAIR:	no

Wait, this is breaking a sysfs rule where one entry should show one value.

> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  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/<disk>/stat/sb_status
> +Date:		December 2020
> +Contact:	"Chao Yu" <yuchao0@huawei.com>
> +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

  reply	other threads:[~2020-12-09 16:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09  8:43 [PATCH RESEND v2 1/5] f2fs: compress: add compress_inode to cache compressed blocks Chao Yu
2020-12-09  8:43 ` [PATCH RESEND v2 2/5] f2fs: compress: support compress level Chao Yu
2020-12-09  8:43 ` [PATCH RESEND v2 3/5] f2fs: compress: deny setting unsupported compress algorithm Chao Yu
2020-12-09  8:43 ` [PATCH RESEND v2 4/5] f2fs: introduce a new per-sb directory in sysfs Chao Yu
2020-12-09  8:43 ` [PATCH RESEND v2 5/5] f2fs: introduce sb_status sysfs node Chao Yu
2020-12-09 16:04   ` Jaegeuk Kim [this message]
2020-12-10  1:40     ` Chao Yu
2020-12-10  1:56 ` [PATCH RESEND v2 1/5] f2fs: compress: add compress_inode to cache compressed blocks Chao Yu
2020-12-10  2:15   ` Jaegeuk Kim
2021-01-06 20:22     ` [f2fs-dev] " Jaegeuk Kim
2021-01-07 11:48       ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X9D1dXVwKFvfHpP9@google.com \
    --to=jaegeuk@kernel.org \
    --cc=chao@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox