OSDN Git Service

staging/lustre/llite: Preparation to move /proc/fs/lustre/llite to sysfs
authorOleg Drokin <green@linuxhacker.ru>
Thu, 21 May 2015 19:31:37 +0000 (15:31 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 01:48:02 +0000 (10:48 +0900)
Add necessary infrastructure, add support for mountpoint
registration in /proc/fs/lustre/llite

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/llite/llite_internal.h
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/llite/lproc_llite.c
drivers/staging/lustre/lustre/llite/super25.c

index bf8f154..c4c758c 100644 (file)
@@ -518,6 +518,9 @@ struct ll_sb_info {
        struct rmtacl_ctl_table   ll_rct;
        struct eacl_table        ll_et;
        __kernel_fsid_t           ll_fsid;
+       struct kobject           ll_kobj; /* sysfs object */
+       struct super_block      *ll_sb; /* struct super_block (for sysfs code)*/
+       struct completion        ll_kobj_unregister;
 };
 
 #define LL_DEFAULT_MAX_RW_CHUNK      (32 * 1024 * 1024)
@@ -639,6 +642,7 @@ struct lov_stripe_md;
 extern spinlock_t inode_lock;
 
 extern struct proc_dir_entry *proc_lustre_fs_root;
+extern struct kset *llite_kset;
 
 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
 {
index e759da3..2aa2335 100644 (file)
@@ -58,6 +58,7 @@
 
 struct kmem_cache *ll_file_data_slab;
 struct proc_dir_entry *proc_lustre_fs_root;
+struct kset *llite_kset;
 
 static LIST_HEAD(ll_super_blocks);
 static DEFINE_SPINLOCK(ll_sb_lock);
@@ -66,7 +67,7 @@ static DEFINE_SPINLOCK(ll_sb_lock);
 #define log2(n) ffz(~(n))
 #endif
 
-static struct ll_sb_info *ll_init_sbi(void)
+static struct ll_sb_info *ll_init_sbi(struct super_block *sb)
 {
        struct ll_sb_info *sbi = NULL;
        unsigned long pages;
@@ -134,6 +135,8 @@ static struct ll_sb_info *ll_init_sbi(void)
        atomic_set(&sbi->ll_agl_total, 0);
        sbi->ll_flags |= LL_SBI_AGL_ENABLED;
 
+       sbi->ll_sb = sb;
+
        return sbi;
 }
 
@@ -919,7 +922,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
        try_module_get(THIS_MODULE);
 
        /* client additional sb info */
-       lsi->lsi_llsbi = sbi = ll_init_sbi();
+       lsi->lsi_llsbi = sbi = ll_init_sbi(sb);
        if (!sbi) {
                module_put(THIS_MODULE);
                kfree(cfg);
index 83a9b85..a3ecb61 100644 (file)
@@ -872,6 +872,23 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
 
 #define MAX_STRING_SIZE 128
 
+static struct attribute *llite_attrs[] = {
+       NULL,
+};
+
+static void llite_sb_release(struct kobject *kobj)
+{
+       struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+                                             ll_kobj);
+       complete(&sbi->ll_kobj_unregister);
+}
+
+static struct kobj_type llite_ktype = {
+       .default_attrs  = llite_attrs,
+       .sysfs_ops      = &lustre_sysfs_ops,
+       .release        = llite_sb_release,
+};
+
 static const struct llite_file_opcode {
        __u32       opcode;
        __u32       type;
@@ -1064,6 +1081,13 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
        if (err)
                goto out;
 
+       sbi->ll_kobj.kset = llite_kset;
+       init_completion(&sbi->ll_kobj_unregister);
+       err = kobject_init_and_add(&sbi->ll_kobj, &llite_ktype, NULL,
+                                  "%s", name);
+       if (err)
+               goto out;
+
        /* MDC info */
        obd = class_name2obd(mdc);
 
@@ -1124,6 +1148,8 @@ void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi)
 {
        if (sbi->ll_proc_root) {
                lprocfs_remove(&sbi->ll_proc_root);
+               kobject_put(&sbi->ll_kobj);
+               wait_for_completion(&sbi->ll_kobj_unregister);
                lprocfs_free_stats(&sbi->ll_ra_stats);
                lprocfs_free_stats(&sbi->ll_stats);
        }
index a494f62..8753560 100644 (file)
@@ -138,6 +138,12 @@ static int __init init_lustre_lite(void)
 
        proc_lustre_fs_root = entry;
 
+       llite_kset = kset_create_and_add("llite", NULL, lustre_kobj);
+       if (!llite_kset) {
+               rc = -ENOMEM;
+               goto out_proc;
+       }
+
        cfs_get_random_bytes(seed, sizeof(seed));
 
        /* Nodes with small feet have little entropy. The NID for this
@@ -155,7 +161,7 @@ static int __init init_lustre_lite(void)
        setup_timer(&ll_capa_timer, ll_capa_timer_callback, 0);
        rc = ll_capa_thread_start();
        if (rc != 0)
-               goto out_proc;
+               goto out_sysfs;
 
        rc = vvp_global_init();
        if (rc != 0)
@@ -176,6 +182,8 @@ out_vvp:
 out_capa:
        del_timer(&ll_capa_timer);
        ll_capa_thread_stop();
+out_sysfs:
+       kset_unregister(llite_kset);
 out_proc:
        lprocfs_remove(&proc_lustre_fs_root);
 out_cache:
@@ -201,6 +209,7 @@ static void __exit exit_lustre_lite(void)
        lustre_register_client_process_config(NULL);
 
        lprocfs_remove(&proc_lustre_fs_root);
+       kset_unregister(llite_kset);
 
        ll_xattr_fini();
        vvp_global_fini();