ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 1/5] ocfs2: Provisions for sysfs entries
Date: Wed, 11 May 2016 07:04:29 -0500	[thread overview]
Message-ID: <57331FCD.3030206@suse.com> (raw)
In-Reply-To: <57330F0C.8080102@huawei.com>



On 05/11/2016 05:53 AM, Joseph Qi wrote:
> On 2016/5/11 1:52, Goldwyn Rodrigues wrote:
>> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>>
>> This adds /sys/fs/ocfs2/<s_id> to the sys filesystem. This
>> is done by adding the kobj into the ocfs2_super. All other
>> files are added in this directory.
>>
>> Introduce ocfs2_sb_attr which encompasses the store() and show() functions.
>> Move all the important data structures with respect to filechecks
>> to ocfs2_super.
>>
>> More superblock information should move in here.
>>
>> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
>> ---
>>   fs/ocfs2/Makefile |  3 +-
>>   fs/ocfs2/ocfs2.h  |  4 +++
>>   fs/ocfs2/super.c  |  7 +++--
>>   fs/ocfs2/sysfs.c  | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   fs/ocfs2/sysfs.h  |  9 ++++++
>>   5 files changed, 111 insertions(+), 4 deletions(-)
>>   create mode 100644 fs/ocfs2/sysfs.c
>>   create mode 100644 fs/ocfs2/sysfs.h
>>
>> diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
>> index e27e652..716ed45 100644
>> --- a/fs/ocfs2/Makefile
>> +++ b/fs/ocfs2/Makefile
>> @@ -41,7 +41,8 @@ ocfs2-objs := \
>>   	quota_local.o		\
>>   	quota_global.o		\
>>   	xattr.o			\
>> -	acl.o	\
>> +	acl.o			\
>> +	sysfs.o			\
>>   	filecheck.o
>>
>>   ocfs2_stackglue-objs := stackglue.o
>> diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
>> index e63af7d..8e66cdf 100644
>> --- a/fs/ocfs2/ocfs2.h
>> +++ b/fs/ocfs2/ocfs2.h
>> @@ -37,6 +37,7 @@
>>   #include <linux/mutex.h>
>>   #include <linux/lockdep.h>
>>   #include <linux/jbd2.h>
>> +#include <linux/kobject.h>
>>
>>   /* For union ocfs2_dlm_lksb */
>>   #include "stackglue.h"
>> @@ -472,6 +473,9 @@ struct ocfs2_super
>>   	 * workqueue and schedule on our own.
>>   	 */
>>   	struct workqueue_struct *ocfs2_wq;
>> +
>> +	struct kobject kobj;
>> +	struct completion kobj_unregister;
>>   };
>>
>>   #define OCFS2_SB(sb)	    ((struct ocfs2_super *)(sb)->s_fs_info)
>> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
>> index d7cae33..96b7a9f 100644
>> --- a/fs/ocfs2/super.c
>> +++ b/fs/ocfs2/super.c
>> @@ -75,6 +75,7 @@
>>
>>   #include "buffer_head_io.h"
>>   #include "filecheck.h"
>> +#include "sysfs.h"
>>
>>   static struct kmem_cache *ocfs2_inode_cachep;
>>   struct kmem_cache *ocfs2_dquot_cachep;
>> @@ -1200,8 +1201,8 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
>>   	/* Start this when the mount is almost sure of being successful */
>>   	ocfs2_orphan_scan_start(osb);
>>
>> -	/* Create filecheck sysfile /sys/fs/ocfs2/<devname>/filecheck */
>> -	ocfs2_filecheck_create_sysfs(sb);
>> +	/* Create sysfs entries */
>> +	ocfs2_sysfs_sb_init(sb);
>>
>>   	return status;
>>
>> @@ -1651,9 +1652,9 @@ static void ocfs2_put_super(struct super_block *sb)
>>   {
>>   	trace_ocfs2_put_super(sb);
>>
>> +	ocfs2_sysfs_sb_exit(sb);
>>   	ocfs2_sync_blockdev(sb);
>>   	ocfs2_dismount_volume(sb, 0);
>> -	ocfs2_filecheck_remove_sysfs(sb);
>>   }
>>
>>   static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
>> diff --git a/fs/ocfs2/sysfs.c b/fs/ocfs2/sysfs.c
>> new file mode 100644
>> index 0000000..f0b7435
>> --- /dev/null
>> +++ b/fs/ocfs2/sysfs.c
>> @@ -0,0 +1,92 @@
>> +#include "ocfs2.h"
>> +#include "sysfs.h"
>> +
>> +struct ocfs2_sb_attr {
>> +	struct attribute attr;
>> +	ssize_t (*show)(struct ocfs2_super *, struct ocfs2_sb_attr *,
>> +			char *buf);
>> +	ssize_t (*store)(struct ocfs2_super *, struct ocfs2_sb_attr *,
>> +			const char *buf, size_t count);
>> +};
>> +
>> +#define OCFS2_SB_ATTR(_name, _mode) \
>> +struct ocfs2_sb_attr sb_attr_##_name = __ATTR(name, _mode, _show, _store)
>> +
>> +#define OCFS2_SB_ATTR_RO(_name) \
>> +struct ocfs2_sb_attr sb_attr_##_name = __ATTR_RO(_name)
>> +
>> +static ssize_t ocfs2_sb_attr_show(struct kobject *kobj,
>> +		struct attribute *attr, char *buf)
>> +{
>> +	struct ocfs2_sb_attr *oa =
>> +		container_of(attr, struct ocfs2_sb_attr, attr);
>> +	struct ocfs2_super *osb = container_of(kobj, struct ocfs2_super, kobj);
>> +	if (!oa->show)
>> +		return -EIO;
>> +
>> +	return oa->show(osb, oa, buf);
>> +}
>> +
>> +static ssize_t ocfs2_sb_attr_store(struct kobject *kobj,
>> +		struct attribute *attr, const char *buf, size_t count)
>> +{
>> +	struct ocfs2_sb_attr *oa =
>> +		container_of(attr, struct ocfs2_sb_attr, attr);
>> +	struct ocfs2_super *osb = container_of(kobj, struct ocfs2_super, kobj);
>> +	if (!oa->show)
> Should it be "!oa->store" here?
>

Yes, you are right. Thanks for pointing it out. I will fix this.

-- 
Goldwyn

  reply	other threads:[~2016-05-11 12:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-10 17:52 [Ocfs2-devel] [PATCH 0/5] ocfs2: sysfs and cleanup Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 1/5] ocfs2: Provisions for sysfs entries Goldwyn Rodrigues
2016-05-11 10:53   ` Joseph Qi
2016-05-11 12:04     ` Goldwyn Rodrigues [this message]
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 2/5] Use the sysfs interface for creating filecheck files Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 3/5] Generate uevents for errors Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 4/5] ocfs2: Disallow duplicate entries in the list Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 5/5] Fix files when an inode is written in file_fix Goldwyn Rodrigues
2016-05-11  1:58 ` [Ocfs2-devel] [PATCH 0/5] ocfs2: sysfs and cleanup Gang He
  -- strict thread matches above, loose matches on Subject: below --
2016-05-26  3:10 [Ocfs2-devel] [PATCH v2 " Goldwyn Rodrigues
2016-05-26  3:10 ` [Ocfs2-devel] [PATCH 1/5] ocfs2: Provisions for sysfs entries Goldwyn Rodrigues
2016-05-30  7:53   ` Gang He
     [not found]   ` <574C61E7020000F9000391D6@suse.com>
2016-05-31 12:40     ` Goldwyn Rodrigues
2016-06-01  2:34       ` Gang He

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=57331FCD.3030206@suse.com \
    --to=rgoldwyn@suse.com \
    --cc=ocfs2-devel@oss.oracle.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;
as well as URLs for NNTP newsgroup(s).