From ae7c0f4833a65b7648cceaf1a60503a89e057f0f Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 30 May 2015 23:27:00 -0400 Subject: [PATCH] staging/lustre/llite: Move all remaining procfs entries to debugfs This moves all remaining procfs handling in llite layer to debugfs. Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/llite/llite_internal.h | 27 ++++++----- .../staging/lustre/lustre/llite/llite_lib.c | 13 +++-- .../staging/lustre/lustre/llite/lproc_llite.c | 48 +++++++++++-------- drivers/staging/lustre/lustre/llite/super25.c | 20 ++++---- drivers/staging/lustre/lustre/llite/vvp_dev.c | 21 ++++---- 5 files changed, 68 insertions(+), 61 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index e180912d0e08..b30eb85a53c9 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -465,7 +465,7 @@ struct ll_sb_info { struct obd_uuid ll_sb_uuid; struct obd_export *ll_md_exp; struct obd_export *ll_dt_exp; - struct proc_dir_entry* ll_proc_root; + struct dentry *ll_debugfs_entry; struct lu_fid ll_root_fid; /* root object fid */ int ll_flags; @@ -636,7 +636,7 @@ struct lov_stripe_md; extern spinlock_t inode_lock; -extern struct proc_dir_entry *proc_lustre_fs_root; +extern struct dentry *llite_root; extern struct kset *llite_kset; static inline struct inode *ll_info2i(struct ll_inode_info *lli) @@ -664,20 +664,25 @@ struct ll_ra_read *ll_ra_read_get(struct file *f); /* llite/lproc_llite.c */ #if defined (CONFIG_PROC_FS) -int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc); -void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi); +int ldebugfs_register_mountpoint(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc); +void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw); -#else -static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc){return 0;} -static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {} +#else /* CONFIG_PROC_FS */ +static inline +int ldebugfs_register_mountpoint(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc) +{ return 0; } static inline -void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {} +void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) +{} +static inline +void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) +{} static inline void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) { memset(lvars, 0, sizeof(*lvars)); @@ -685,7 +690,7 @@ static inline void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) static inline void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw) {} -#endif +#endif /* CONFIG_PROC_FS */ /* llite/dir.c */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 4c9fd4acedea..25139885b5a7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -57,7 +57,7 @@ #include "llite_internal.h" struct kmem_cache *ll_file_data_slab; -struct proc_dir_entry *proc_lustre_fs_root; +struct dentry *llite_root; struct kset *llite_kset; static LIST_HEAD(ll_super_blocks); @@ -184,11 +184,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, return -ENOMEM; } - if (proc_lustre_fs_root) { - err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb, - dt, md); + if (llite_root != NULL) { + err = ldebugfs_register_mountpoint(llite_root, sb, dt, md); if (err < 0) - CERROR("could not register mount in /proc/fs/lustre\n"); + CERROR("could not register mount in /lustre/llite\n"); } /* indicate the features supported by this client */ @@ -601,7 +600,7 @@ out_md: out: kfree(data); kfree(osfs); - lprocfs_unregister_mountpoint(sbi); + ldebugfs_unregister_mountpoint(sbi); return err; } @@ -682,7 +681,7 @@ static void client_common_put_super(struct super_block *sb) * see LU-2543. */ obd_zombie_barrier(); - lprocfs_unregister_mountpoint(sbi); + ldebugfs_unregister_mountpoint(sbi); obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 2c84bed3f6ce..486dca6077de 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -950,12 +950,13 @@ static const char *ra_stat_string[] = { [RA_STAT_WRONG_GRAB_PAGE] = "wrong page from grab_cache_page", }; -int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc) +int ldebugfs_register_mountpoint(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; + struct dentry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; @@ -976,30 +977,32 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, lsi->lsi_lmd->lmd_profile, sb); - sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL); - if (IS_ERR(sbi->ll_proc_root)) { - err = PTR_ERR(sbi->ll_proc_root); - sbi->ll_proc_root = NULL; + dir = ldebugfs_register(name, parent, NULL, NULL); + if (IS_ERR_OR_NULL(dir)) { + err = dir ? PTR_ERR(dir) : -ENOMEM; + sbi->ll_debugfs_entry = NULL; return err; } + sbi->ll_debugfs_entry = dir; - rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444, - &vvp_dump_pgcache_file_ops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "dump_page_cache", 0444, + &vvp_dump_pgcache_file_ops, sbi); if (rc) CWARN("Error adding the dump_page_cache file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats", 0644, - &ll_rw_extents_stats_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "extents_stats", 0644, + &ll_rw_extents_stats_fops, sbi); if (rc) CWARN("Error adding the extent_stats file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats_per_process", - 0644, &ll_rw_extents_stats_pp_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, + "extents_stats_per_process", + 0644, &ll_rw_extents_stats_pp_fops, sbi); if (rc) CWARN("Error adding the extents_stats_per_process file\n"); - rc = lprocfs_seq_create(sbi->ll_proc_root, "offset_stats", 0644, - &ll_rw_offset_stats_fops, sbi); + rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "offset_stats", 0644, + &ll_rw_offset_stats_fops, sbi); if (rc) CWARN("Error adding the offset_stats file\n"); @@ -1025,7 +1028,8 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, (type & LPROCFS_CNTR_AVGMINMAX), llite_opcode_table[id].opname, ptr); } - err = lprocfs_register_stats(sbi->ll_proc_root, "stats", sbi->ll_stats); + err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "stats", + sbi->ll_stats); if (err) goto out; @@ -1039,13 +1043,15 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++) lprocfs_counter_init(sbi->ll_ra_stats, id, 0, ra_stat_string[id], "pages"); - err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats", + + err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "read_ahead_stats", sbi->ll_ra_stats); if (err) goto out; - err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb); + err = ldebugfs_add_vars(sbi->ll_debugfs_entry, + lprocfs_llite_obd_vars, sb); if (err) goto out; @@ -1071,17 +1077,17 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, obd->obd_type->typ_name); out: if (err) { - lprocfs_remove(&sbi->ll_proc_root); + ldebugfs_remove(&sbi->ll_debugfs_entry); lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } return err; } -void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) +void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) { - if (sbi->ll_proc_root) { - lprocfs_remove(&sbi->ll_proc_root); + if (sbi->ll_debugfs_entry) { + ldebugfs_remove(&sbi->ll_debugfs_entry); kobject_put(&sbi->ll_kobj); wait_for_completion(&sbi->ll_kobj_unregister); lprocfs_free_stats(&sbi->ll_ra_stats); diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 8753560809fa..e4020ce8cb7b 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -89,7 +89,6 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); static int __init init_lustre_lite(void) { - struct proc_dir_entry *entry; lnet_process_id_t lnet_id; struct timeval tv; int i, rc, seed[2]; @@ -128,20 +127,17 @@ static int __init init_lustre_lite(void) if (ll_rmtperm_hash_cachep == NULL) goto out_cache; - entry = lprocfs_register("llite", proc_lustre_root, NULL, NULL); - if (IS_ERR(entry)) { - rc = PTR_ERR(entry); - CERROR("cannot register '/proc/fs/lustre/llite': rc = %d\n", - rc); + llite_root = debugfs_create_dir("llite", debugfs_lustre_root); + if (IS_ERR_OR_NULL(llite_root)) { + rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; + llite_root = NULL; goto out_cache; } - proc_lustre_fs_root = entry; - llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); if (!llite_kset) { rc = -ENOMEM; - goto out_proc; + goto out_debugfs; } cfs_get_random_bytes(seed, sizeof(seed)); @@ -184,8 +180,8 @@ out_capa: ll_capa_thread_stop(); out_sysfs: kset_unregister(llite_kset); -out_proc: - lprocfs_remove(&proc_lustre_fs_root); +out_debugfs: + debugfs_remove(llite_root); out_cache: if (ll_inode_cachep != NULL) kmem_cache_destroy(ll_inode_cachep); @@ -208,7 +204,7 @@ static void __exit exit_lustre_lite(void) lustre_register_kill_super_cb(NULL); lustre_register_client_process_config(NULL); - lprocfs_remove(&proc_lustre_fs_root); + debugfs_remove(llite_root); kset_unregister(llite_kset); ll_xattr_fini(); diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index fde41d7c5e3d..6d9622acb44f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -253,7 +253,7 @@ int cl_sb_fini(struct super_block *sb) /**************************************************************************** * - * /proc/fs/lustre/llite/$MNT/dump_page_cache + * debugfs/lustre/llite/$MNT/dump_page_cache * ****************************************************************************/ @@ -526,16 +526,17 @@ static struct seq_operations vvp_pgcache_ops = { static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp) { - struct ll_sb_info *sbi = PDE_DATA(inode); - struct seq_file *seq; - int result; + struct seq_file *seq; + int rc; - result = seq_open(filp, &vvp_pgcache_ops); - if (result == 0) { - seq = filp->private_data; - seq->private = sbi; - } - return result; + rc = seq_open(filp, &vvp_pgcache_ops); + if (rc) + return rc; + + seq = filp->private_data; + seq->private = inode->i_private ?: PDE_DATA(inode); + + return 0; } const struct file_operations vvp_dump_pgcache_file_ops = { -- 2.39.2