From patchwork Fri Apr 29 02:01:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 8976381 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1BBC99F1C1 for ; Fri, 29 Apr 2016 02:01:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35612201CE for ; Fri, 29 Apr 2016 02:01:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03A85202E9 for ; Fri, 29 Apr 2016 02:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752760AbcD2CBt (ORCPT ); Thu, 28 Apr 2016 22:01:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:36955 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752244AbcD2CBs (ORCPT ); Thu, 28 Apr 2016 22:01:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E5FFCAC60 for ; Fri, 29 Apr 2016 02:01:46 +0000 (UTC) From: Goldwyn Rodrigues To: linux-fsdevel@vger.kernel.org Cc: Goldwyn Rodrigues Subject: [PoC 5/7] ocfs2: Use the sb's kset Date: Thu, 28 Apr 2016 21:01:20 -0500 Message-Id: <1461895282-4941-6-git-send-email-rgoldwyn@suse.de> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1461895282-4941-1-git-send-email-rgoldwyn@suse.de> References: <1461895282-4941-1-git-send-email-rgoldwyn@suse.de> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Goldwyn Rodrigues This is just for demonstration. The original ocfs2_kset has been used to create ocfs2_stack. Not the ideal way to do it. Signed-off-by: Goldwyn Rodrigues --- fs/ocfs2/Makefile | 3 ++- fs/ocfs2/stackglue.c | 3 +-- fs/ocfs2/super.c | 8 ++++---- fs/ocfs2/sysfs.c | 26 ++++++++++++++++++++++++++ fs/ocfs2/sysfs.h | 8 ++++++++ 5 files changed, 41 insertions(+), 7 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/stackglue.c b/fs/ocfs2/stackglue.c index 13219ed..f9b45b3 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c @@ -640,8 +640,7 @@ static void ocfs2_sysfs_exit(void) static int ocfs2_sysfs_init(void) { int ret; - - ocfs2_kset = kset_create_and_add("ocfs2", NULL, fs_kobj); + ocfs2_kset = kset_create_and_add("ocfs2_stack", NULL, fs_kobj); if (!ocfs2_kset) return -ENOMEM; diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index d7cae33..b899cde 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//filecheck */ - ocfs2_filecheck_create_sysfs(sb); + /* Create sysfs entries */ + ocfs2_sysfs_sb_init(sb); return status; @@ -1232,7 +1233,7 @@ static struct file_system_type ocfs2_fs_type = { .name = "ocfs2", .mount = ocfs2_mount, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE, + .fs_flags = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE|FS_CREATE_SYSFS, .next = NULL }; MODULE_ALIAS_FS("ocfs2"); @@ -1653,7 +1654,6 @@ static void ocfs2_put_super(struct super_block *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..1e57e6c --- /dev/null +++ b/fs/ocfs2/sysfs.c @@ -0,0 +1,26 @@ +#include +#include "ocfs2.h" +#include "sysfs.h" + +static ssize_t slot_num_show(struct super_block *sb, + struct super_block_attribute *attr, + char *buf) +{ + struct ocfs2_super *osb = OCFS2_SB(sb); + return sprintf(buf, "%d\n", osb->slot_num); +} + +static SB_ATTR_RO(slot_num); +static struct attribute *ocfs2_sb_attrs[] = { + &sb_attr_slot_num.attr, + NULL +}; + +int ocfs2_sysfs_sb_init(struct super_block *sb) +{ + sb->s_attr = ocfs2_sb_attrs; + return 0; + +} + + diff --git a/fs/ocfs2/sysfs.h b/fs/ocfs2/sysfs.h new file mode 100644 index 0000000..328f9c749 --- /dev/null +++ b/fs/ocfs2/sysfs.h @@ -0,0 +1,8 @@ + + +#ifndef _SYS_H +#define _SYS_H + +int ocfs2_sysfs_sb_init(struct super_block *sb); + +#endif