All of lore.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] f2fs: introduce a new per-sb directory in sysfs
Date: Fri, 4 Dec 2020 10:23:40 -0800	[thread overview]
Message-ID: <X8p+rK6wQsXdcG33@google.com> (raw)
In-Reply-To: <af26ca56-1dbf-e59b-b7b0-63ce817fd94d@huawei.com>

On 12/03, Chao Yu wrote:
> Jaegeuk,
> 
> Can you comment on this patch?

Waiting for use-case? :)

> 
> On 2020/11/27 17:01, Chao Yu wrote:
> > Add a new directory 'stat' in path of /sys/fs/f2fs/<devname>/, later
> > we can add new readonly stat sysfs file into this directory, it will
> > make <devname> directory less mess.
> > 
> > Signed-off-by: Chao Yu <yuchao0@huawei.com>
> > ---
> >   fs/f2fs/f2fs.h  |  5 +++-
> >   fs/f2fs/sysfs.c | 69 +++++++++++++++++++++++++++++++++++++++++++++----
> >   2 files changed, 68 insertions(+), 6 deletions(-)
> > 
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index 0d38f2135016..a20059dece46 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -1510,9 +1510,12 @@ struct f2fs_sb_info {
> >   	unsigned int node_io_flag;
> >   	/* For sysfs suppport */
> > -	struct kobject s_kobj;
> > +	struct kobject s_kobj;			/* /sys/fs/f2fs/<devname> */
> >   	struct completion s_kobj_unregister;
> > +	struct kobject s_stat_kobj;		/* /sys/fs/f2fs/<devname>/stat */
> > +	struct completion s_stat_kobj_unregister;
> > +
> >   	/* For shrinker support */
> >   	struct list_head s_list;
> >   	int s_ndevs;				/* number of devices */
> > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> > index ec77ccfea923..8c63a6e61dfd 100644
> > --- a/fs/f2fs/sysfs.c
> > +++ b/fs/f2fs/sysfs.c
> > @@ -708,6 +708,11 @@ static struct attribute *f2fs_feat_attrs[] = {
> >   };
> >   ATTRIBUTE_GROUPS(f2fs_feat);
> > +static struct attribute *f2fs_stat_attrs[] = {
> > +	NULL,
> > +};
> > +ATTRIBUTE_GROUPS(f2fs_stat);
> > +
> >   static const struct sysfs_ops f2fs_attr_ops = {
> >   	.show	= f2fs_attr_show,
> >   	.store	= f2fs_attr_store,
> > @@ -736,6 +741,44 @@ static struct kobject f2fs_feat = {
> >   	.kset	= &f2fs_kset,
> >   };
> > +static ssize_t f2fs_stat_attr_show(struct kobject *kobj,
> > +				struct attribute *attr, char *buf)
> > +{
> > +	struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
> > +								s_stat_kobj);
> > +	struct f2fs_attr *a = container_of(attr, struct f2fs_attr, attr);
> > +
> > +	return a->show ? a->show(a, sbi, buf) : 0;
> > +}
> > +
> > +static ssize_t f2fs_stat_attr_store(struct kobject *kobj, struct attribute *attr,
> > +						const char *buf, size_t len)
> > +{
> > +	struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
> > +								s_stat_kobj);
> > +	struct f2fs_attr *a = container_of(attr, struct f2fs_attr, attr);
> > +
> > +	return a->store ? a->store(a, sbi, buf, len) : 0;
> > +}
> > +
> > +static void f2fs_stat_kobj_release(struct kobject *kobj)
> > +{
> > +	struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
> > +								s_stat_kobj);
> > +	complete(&sbi->s_stat_kobj_unregister);
> > +}
> > +
> > +static const struct sysfs_ops f2fs_stat_attr_ops = {
> > +	.show	= f2fs_stat_attr_show,
> > +	.store	= f2fs_stat_attr_store,
> > +};
> > +
> > +static struct kobj_type f2fs_stat_ktype = {
> > +	.default_groups = f2fs_stat_groups,
> > +	.sysfs_ops	= &f2fs_stat_attr_ops,
> > +	.release	= f2fs_stat_kobj_release,
> > +};
> > +
> >   static int __maybe_unused segment_info_seq_show(struct seq_file *seq,
> >   						void *offset)
> >   {
> > @@ -942,11 +985,15 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
> >   	init_completion(&sbi->s_kobj_unregister);
> >   	err = kobject_init_and_add(&sbi->s_kobj, &f2fs_sb_ktype, NULL,
> >   				"%s", sb->s_id);
> > -	if (err) {
> > -		kobject_put(&sbi->s_kobj);
> > -		wait_for_completion(&sbi->s_kobj_unregister);
> > -		return err;
> > -	}
> > +	if (err)
> > +		goto put_sb_kobj;
> > +
> > +	sbi->s_stat_kobj.kset = &f2fs_kset;
> > +	init_completion(&sbi->s_stat_kobj_unregister);
> > +	err = kobject_init_and_add(&sbi->s_stat_kobj, &f2fs_stat_ktype,
> > +						&sbi->s_kobj, "stat");
> > +	if (err)
> > +		goto put_stat_kobj;
> >   	if (f2fs_proc_root)
> >   		sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);
> > @@ -962,6 +1009,13 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
> >   				victim_bits_seq_show, sb);
> >   	}
> >   	return 0;
> > +put_stat_kobj:
> > +	kobject_put(&sbi->s_stat_kobj);
> > +	wait_for_completion(&sbi->s_stat_kobj_unregister);
> > +put_sb_kobj:
> > +	kobject_put(&sbi->s_kobj);
> > +	wait_for_completion(&sbi->s_kobj_unregister);
> > +	return err;
> >   }
> >   void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
> > @@ -973,6 +1027,11 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
> >   		remove_proc_entry("victim_bits", sbi->s_proc);
> >   		remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
> >   	}
> > +
> > +	kobject_del(&sbi->s_stat_kobj);
> > +	kobject_put(&sbi->s_stat_kobj);
> > +	wait_for_completion(&sbi->s_stat_kobj_unregister);
> > +
> >   	kobject_del(&sbi->s_kobj);
> >   	kobject_put(&sbi->s_kobj);
> >   	wait_for_completion(&sbi->s_kobj_unregister);
> > 

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: introduce a new per-sb directory in sysfs
Date: Fri, 4 Dec 2020 10:23:40 -0800	[thread overview]
Message-ID: <X8p+rK6wQsXdcG33@google.com> (raw)
In-Reply-To: <af26ca56-1dbf-e59b-b7b0-63ce817fd94d@huawei.com>

On 12/03, Chao Yu wrote:
> Jaegeuk,
> 
> Can you comment on this patch?

Waiting for use-case? :)

> 
> On 2020/11/27 17:01, Chao Yu wrote:
> > Add a new directory 'stat' in path of /sys/fs/f2fs/<devname>/, later
> > we can add new readonly stat sysfs file into this directory, it will
> > make <devname> directory less mess.
> > 
> > Signed-off-by: Chao Yu <yuchao0@huawei.com>
> > ---
> >   fs/f2fs/f2fs.h  |  5 +++-
> >   fs/f2fs/sysfs.c | 69 +++++++++++++++++++++++++++++++++++++++++++++----
> >   2 files changed, 68 insertions(+), 6 deletions(-)
> > 
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index 0d38f2135016..a20059dece46 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -1510,9 +1510,12 @@ struct f2fs_sb_info {
> >   	unsigned int node_io_flag;
> >   	/* For sysfs suppport */
> > -	struct kobject s_kobj;
> > +	struct kobject s_kobj;			/* /sys/fs/f2fs/<devname> */
> >   	struct completion s_kobj_unregister;
> > +	struct kobject s_stat_kobj;		/* /sys/fs/f2fs/<devname>/stat */
> > +	struct completion s_stat_kobj_unregister;
> > +
> >   	/* For shrinker support */
> >   	struct list_head s_list;
> >   	int s_ndevs;				/* number of devices */
> > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> > index ec77ccfea923..8c63a6e61dfd 100644
> > --- a/fs/f2fs/sysfs.c
> > +++ b/fs/f2fs/sysfs.c
> > @@ -708,6 +708,11 @@ static struct attribute *f2fs_feat_attrs[] = {
> >   };
> >   ATTRIBUTE_GROUPS(f2fs_feat);
> > +static struct attribute *f2fs_stat_attrs[] = {
> > +	NULL,
> > +};
> > +ATTRIBUTE_GROUPS(f2fs_stat);
> > +
> >   static const struct sysfs_ops f2fs_attr_ops = {
> >   	.show	= f2fs_attr_show,
> >   	.store	= f2fs_attr_store,
> > @@ -736,6 +741,44 @@ static struct kobject f2fs_feat = {
> >   	.kset	= &f2fs_kset,
> >   };
> > +static ssize_t f2fs_stat_attr_show(struct kobject *kobj,
> > +				struct attribute *attr, char *buf)
> > +{
> > +	struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
> > +								s_stat_kobj);
> > +	struct f2fs_attr *a = container_of(attr, struct f2fs_attr, attr);
> > +
> > +	return a->show ? a->show(a, sbi, buf) : 0;
> > +}
> > +
> > +static ssize_t f2fs_stat_attr_store(struct kobject *kobj, struct attribute *attr,
> > +						const char *buf, size_t len)
> > +{
> > +	struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
> > +								s_stat_kobj);
> > +	struct f2fs_attr *a = container_of(attr, struct f2fs_attr, attr);
> > +
> > +	return a->store ? a->store(a, sbi, buf, len) : 0;
> > +}
> > +
> > +static void f2fs_stat_kobj_release(struct kobject *kobj)
> > +{
> > +	struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
> > +								s_stat_kobj);
> > +	complete(&sbi->s_stat_kobj_unregister);
> > +}
> > +
> > +static const struct sysfs_ops f2fs_stat_attr_ops = {
> > +	.show	= f2fs_stat_attr_show,
> > +	.store	= f2fs_stat_attr_store,
> > +};
> > +
> > +static struct kobj_type f2fs_stat_ktype = {
> > +	.default_groups = f2fs_stat_groups,
> > +	.sysfs_ops	= &f2fs_stat_attr_ops,
> > +	.release	= f2fs_stat_kobj_release,
> > +};
> > +
> >   static int __maybe_unused segment_info_seq_show(struct seq_file *seq,
> >   						void *offset)
> >   {
> > @@ -942,11 +985,15 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
> >   	init_completion(&sbi->s_kobj_unregister);
> >   	err = kobject_init_and_add(&sbi->s_kobj, &f2fs_sb_ktype, NULL,
> >   				"%s", sb->s_id);
> > -	if (err) {
> > -		kobject_put(&sbi->s_kobj);
> > -		wait_for_completion(&sbi->s_kobj_unregister);
> > -		return err;
> > -	}
> > +	if (err)
> > +		goto put_sb_kobj;
> > +
> > +	sbi->s_stat_kobj.kset = &f2fs_kset;
> > +	init_completion(&sbi->s_stat_kobj_unregister);
> > +	err = kobject_init_and_add(&sbi->s_stat_kobj, &f2fs_stat_ktype,
> > +						&sbi->s_kobj, "stat");
> > +	if (err)
> > +		goto put_stat_kobj;
> >   	if (f2fs_proc_root)
> >   		sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);
> > @@ -962,6 +1009,13 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
> >   				victim_bits_seq_show, sb);
> >   	}
> >   	return 0;
> > +put_stat_kobj:
> > +	kobject_put(&sbi->s_stat_kobj);
> > +	wait_for_completion(&sbi->s_stat_kobj_unregister);
> > +put_sb_kobj:
> > +	kobject_put(&sbi->s_kobj);
> > +	wait_for_completion(&sbi->s_kobj_unregister);
> > +	return err;
> >   }
> >   void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
> > @@ -973,6 +1027,11 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
> >   		remove_proc_entry("victim_bits", sbi->s_proc);
> >   		remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
> >   	}
> > +
> > +	kobject_del(&sbi->s_stat_kobj);
> > +	kobject_put(&sbi->s_stat_kobj);
> > +	wait_for_completion(&sbi->s_stat_kobj_unregister);
> > +
> >   	kobject_del(&sbi->s_kobj);
> >   	kobject_put(&sbi->s_kobj);
> >   	wait_for_completion(&sbi->s_kobj_unregister);
> > 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2020-12-04 18:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27  9:01 [PATCH] f2fs: introduce a new per-sb directory in sysfs Chao Yu
2020-11-27  9:01 ` [f2fs-dev] " Chao Yu
2020-12-03  8:56 ` Chao Yu
2020-12-03  8:56   ` [f2fs-dev] " Chao Yu
2020-12-04 18:23   ` Jaegeuk Kim [this message]
2020-12-04 18:23     ` Jaegeuk Kim
2020-12-05  1:29     ` Chao Yu
2020-12-05  1:29       ` [f2fs-dev] " Chao Yu
2020-12-05 20:42       ` Jaegeuk Kim
2020-12-05 20:42         ` [f2fs-dev] " Jaegeuk Kim

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=X8p+rK6wQsXdcG33@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.