From d9528a30a8361a1af1f436129e2eb9165a3cbc5b Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 30 May 2015 23:27:04 -0400 Subject: [PATCH] staging/lustre/obd: Remove nid_stats tracking This nid_stats tracking only makes sense on the server side, on the client there are no other clients to keep track of anyway. Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/dt_object.h | 1 - .../lustre/lustre/include/lprocfs_status.h | 15 --- .../staging/lustre/lustre/include/lu_object.h | 2 - .../lustre/lustre/include/lustre_export.h | 29 ------ drivers/staging/lustre/lustre/include/obd.h | 3 - .../staging/lustre/lustre/include/obd_class.h | 18 ---- .../lustre/lustre/obdclass/lprocfs_status.c | 96 ------------------- .../lustre/lustre/obdclass/obd_config.c | 80 ---------------- 8 files changed, 244 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h index be4c7d95e788..866d04b2814b 100644 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ b/drivers/staging/lustre/lustre/include/dt_object.h @@ -58,7 +58,6 @@ #include "../../include/linux/libcfs/libcfs.h" struct seq_file; -struct proc_dir_entry; struct lustre_cfg; struct thandle; diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 4b8c265d8fe1..6a77ea8ec62e 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -558,7 +558,6 @@ extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index, extern void lprocfs_free_obd_stats(struct obd_device *obddev); extern void lprocfs_free_md_stats(struct obd_device *obddev); struct obd_export; -struct nid_stat; extern int lprocfs_add_clear_entry(struct obd_device *obd, struct proc_dir_entry *entry); extern int lprocfs_exp_cleanup(struct obd_export *exp); @@ -573,11 +572,6 @@ extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, extern struct dentry * ldebugfs_add_symlink(const char *name, struct dentry *parent, const char *format, ...); -extern void lprocfs_free_per_client_stats(struct obd_device *obd); -extern int -lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data); -extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data); extern int ldebugfs_register_stats(struct dentry *parent, const char *name, @@ -909,15 +903,6 @@ static inline struct proc_dir_entry * lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops) {return 0; } -static inline void lprocfs_free_per_client_stats(struct obd_device *obd) -{ return; } -static inline -int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data) -{return count;} -static inline -int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) -{ return 0; } static inline struct proc_dir_entry * lprocfs_register(const char *name, struct proc_dir_entry *parent, diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index c8cc48f00026..e1d72a7a5c2d 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -43,7 +43,6 @@ #include "lu_ref.h" struct seq_file; -struct proc_dir_entry; struct lustre_cfg; struct lprocfs_stats; @@ -277,7 +276,6 @@ struct lu_device { * Stack this device belongs to. */ struct lu_site *ld_site; - struct proc_dir_entry *ld_proc_entry; /** \todo XXX: temporary back pointer into obd. */ struct obd_device *ld_obd; diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 9c06a49f12a4..3b992b42fd91 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -106,34 +106,6 @@ struct mgs_export_data { spinlock_t med_lock; /* protect med_clients */ }; -/** - * per-NID statistics structure. - * It tracks access patterns to this export on a per-client-NID basis - */ -struct nid_stat { - lnet_nid_t nid; - struct hlist_node nid_hash; - struct list_head nid_list; - struct obd_device *nid_obd; - struct proc_dir_entry *nid_proc; - struct lprocfs_stats *nid_stats; - struct lprocfs_stats *nid_ldlm_stats; - atomic_t nid_exp_ref_count; /* for obd_nid_stats_hash - exp_nid_stats */ -}; - -#define nidstat_getref(nidstat) \ -do { \ - atomic_inc(&(nidstat)->nid_exp_ref_count); \ -} while (0) - -#define nidstat_putref(nidstat) \ -do { \ - atomic_dec(&(nidstat)->nid_exp_ref_count); \ - LASSERTF(atomic_read(&(nidstat)->nid_exp_ref_count) >= 0, \ - "stat %p nid_exp_ref_count < 0\n", nidstat); \ -} while (0) - enum obd_option { OBD_OPT_FORCE = 0x0001, OBD_OPT_FAILOVER = 0x0002, @@ -190,7 +162,6 @@ struct obd_export { * exp_lock protect its change */ struct obd_import *exp_imp_reverse; - struct nid_stat *exp_nid_stats; struct lprocfs_stats *exp_md_stats; /** Active connection */ struct ptlrpc_connection *exp_connection; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 708a4cfb4659..55452e562bd4 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -845,9 +845,6 @@ struct obd_device { struct cfs_hash *obd_uuid_hash; /* nid-export hash body */ struct cfs_hash *obd_nid_hash; - /* nid stats body */ - struct cfs_hash *obd_nid_stats_hash; - struct list_head obd_nid_stats; atomic_t obd_refcount; wait_queue_head_t obd_refcount_waitq; struct list_head obd_exports; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 98b397e139a8..63f5224ecb97 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -378,10 +378,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) OBD_COUNTER_OFFSET(op); \ LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \ lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \ - if ((export)->exp_nid_stats != NULL && \ - (export)->exp_nid_stats->nid_stats != NULL) \ - lprocfs_counter_incr( \ - (export)->exp_nid_stats->nid_stats, coffset);\ } #define MD_COUNTER_OFFSET(op) \ @@ -418,20 +414,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) #define EXP_MD_COUNTER_INCREMENT(exp, op) #endif -static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat *tmp) -{ - /* Always add in ldlm_stats */ - tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC - ,LPROCFS_STATS_FLAG_NOPERCPU); - if (tmp->nid_ldlm_stats == NULL) - return -ENOMEM; - - lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats); - - return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats", - tmp->nid_ldlm_stats); -} - #define OBD_CHECK_MD_OP(obd, op, err) \ do { \ if (!OBT(obd) || !MDP((obd), op)) { \ diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 3ef5474fcd34..f44c74611d3b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1106,46 +1106,6 @@ int lprocfs_obd_cleanup(struct obd_device *obd) } EXPORT_SYMBOL(lprocfs_obd_cleanup); -static void lprocfs_free_client_stats(struct nid_stat *client_stat) -{ - CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat, - client_stat->nid_proc, client_stat->nid_stats); - - LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0, - "nid %s:count %d\n", libcfs_nid2str(client_stat->nid), - atomic_read(&client_stat->nid_exp_ref_count)); - - if (client_stat->nid_proc) - lprocfs_remove(&client_stat->nid_proc); - - if (client_stat->nid_stats) - lprocfs_free_stats(&client_stat->nid_stats); - - if (client_stat->nid_ldlm_stats) - lprocfs_free_stats(&client_stat->nid_ldlm_stats); - - kfree(client_stat); - return; - -} - -void lprocfs_free_per_client_stats(struct obd_device *obd) -{ - struct cfs_hash *hash = obd->obd_nid_stats_hash; - struct nid_stat *stat; - - /* we need extra list - because hash_exit called to early */ - /* not need locking because all clients is died */ - while (!list_empty(&obd->obd_nid_stats)) { - stat = list_entry(obd->obd_nid_stats.next, - struct nid_stat, nid_list); - list_del_init(&stat->nid_list); - cfs_hash_del(hash, &stat->nid, &stat->nid_hash); - lprocfs_free_client_stats(stat); - } -} -EXPORT_SYMBOL(lprocfs_free_per_client_stats); - int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid) { struct lprocfs_counter *cntr; @@ -1679,64 +1639,8 @@ void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) } EXPORT_SYMBOL(lprocfs_init_ldlm_stats); -int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) -{ - seq_printf(m, "%s\n", - "Write into this file to clear all nid stats and stale nid entries"); - return 0; -} -EXPORT_SYMBOL(lprocfs_nid_stats_clear_read); - -static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data) -{ - struct nid_stat *stat = obj; - - CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count)); - if (atomic_read(&stat->nid_exp_ref_count) == 1) { - /* object has only hash references. */ - spin_lock(&stat->nid_obd->obd_nid_lock); - list_move(&stat->nid_list, data); - spin_unlock(&stat->nid_obd->obd_nid_lock); - return 1; - } - /* we has reference to object - only clear data*/ - if (stat->nid_stats) - lprocfs_clear_stats(stat->nid_stats); - - return 0; -} - -int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - struct nid_stat *client_stat; - LIST_HEAD(free_list); - - cfs_hash_cond_del(obd->obd_nid_stats_hash, - lprocfs_nid_stats_clear_write_cb, &free_list); - - while (!list_empty(&free_list)) { - client_stat = list_entry(free_list.next, struct nid_stat, - nid_list); - list_del_init(&client_stat->nid_list); - lprocfs_free_client_stats(client_stat); - } - - return count; -} -EXPORT_SYMBOL(lprocfs_nid_stats_clear_write); - int lprocfs_exp_cleanup(struct obd_export *exp) { - struct nid_stat *stat = exp->exp_nid_stats; - - if (!stat || !exp->exp_obd) - return 0; - - nidstat_putref(exp->exp_nid_stats); - exp->exp_nid_stats = NULL; - return 0; } EXPORT_SYMBOL(lprocfs_exp_cleanup); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 0bda9c56f148..19d4eb045b1b 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -49,7 +49,6 @@ static cfs_hash_ops_t uuid_hash_ops; static cfs_hash_ops_t nid_hash_ops; -static cfs_hash_ops_t nid_stat_hash_ops; /*********** string parsing utils *********/ @@ -383,7 +382,6 @@ int class_attach(struct lustre_cfg *lcfg) INIT_LIST_HEAD(&obd->obd_unlinked_exports); INIT_LIST_HEAD(&obd->obd_delayed_exports); INIT_LIST_HEAD(&obd->obd_exports_timed); - INIT_LIST_HEAD(&obd->obd_nid_stats); spin_lock_init(&obd->obd_nid_lock); spin_lock_init(&obd->obd_dev_lock); mutex_init(&obd->obd_dev_mutex); @@ -486,7 +484,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_starting = 1; obd->obd_uuid_hash = NULL; obd->obd_nid_hash = NULL; - obd->obd_nid_stats_hash = NULL; spin_unlock(&obd->obd_dev_lock); /* create an uuid-export lustre hash */ @@ -515,19 +512,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_hash; } - /* create a nid-stats lustre hash */ - obd->obd_nid_stats_hash = cfs_hash_create("NID_STATS", - HASH_NID_STATS_CUR_BITS, - HASH_NID_STATS_MAX_BITS, - HASH_NID_STATS_BKT_BITS, 0, - CFS_HASH_MIN_THETA, - CFS_HASH_MAX_THETA, - &nid_stat_hash_ops, CFS_HASH_DEFAULT); - if (!obd->obd_nid_stats_hash) { - err = -ENOMEM; - goto err_hash; - } - exp = class_new_export(obd, &obd->obd_uuid); if (IS_ERR(exp)) { err = PTR_ERR(exp); @@ -567,10 +551,6 @@ err_hash: cfs_hash_putref(obd->obd_nid_hash); obd->obd_nid_hash = NULL; } - if (obd->obd_nid_stats_hash) { - cfs_hash_putref(obd->obd_nid_stats_hash); - obd->obd_nid_stats_hash = NULL; - } obd->obd_starting = 0; CERROR("setup %s failed (%d)\n", obd->obd_name, err); return err; @@ -694,12 +674,6 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_nid_hash = NULL; } - /* destroy a nid-stats hash body */ - if (obd->obd_nid_stats_hash) { - cfs_hash_putref(obd->obd_nid_stats_hash); - obd->obd_nid_stats_hash = NULL; - } - class_decref(obd, "setup", obd); obd->obd_set_up = 0; @@ -1893,57 +1867,3 @@ static cfs_hash_ops_t nid_hash_ops = { .hs_get = nid_export_get, .hs_put_locked = nid_export_put_locked, }; - - -/* - * nid<->nidstats hash operations - */ - -static void * -nidstats_key(struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - - return &ns->nid; -} - -static int -nidstats_keycmp(const void *key, struct hlist_node *hnode) -{ - return *(lnet_nid_t *)nidstats_key(hnode) == *(lnet_nid_t *)key; -} - -static void * -nidstats_object(struct hlist_node *hnode) -{ - return hlist_entry(hnode, struct nid_stat, nid_hash); -} - -static void -nidstats_get(struct cfs_hash *hs, struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - nidstat_getref(ns); -} - -static void -nidstats_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) -{ - struct nid_stat *ns; - - ns = hlist_entry(hnode, struct nid_stat, nid_hash); - nidstat_putref(ns); -} - -static cfs_hash_ops_t nid_stat_hash_ops = { - .hs_hash = nid_hash, - .hs_key = nidstats_key, - .hs_keycmp = nidstats_keycmp, - .hs_object = nidstats_object, - .hs_get = nidstats_get, - .hs_put_locked = nidstats_put_locked, -}; -- 2.30.2