From: Oleg Drokin Date: Thu, 21 May 2015 19:31:37 +0000 (-0400) Subject: staging/lustre/llite: Preparation to move /proc/fs/lustre/llite to sysfs X-Git-Tag: v4.2-rc1~88^2~520 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=fd0d04ba85f95169106701397417360541a983b3;p=karo-tx-linux.git staging/lustre/llite: Preparation to move /proc/fs/lustre/llite to sysfs Add necessary infrastructure, add support for mountpoint registration in /proc/fs/lustre/llite Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index bf8f1541546c..c4c758cac12a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -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) { diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index e759da3a1b5e..2aa2335685cb 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -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); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 83a9b85474e1..a3ecb61e5555 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -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); } diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index a494f6271fa0..8753560809fa 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -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();