From: bobijam Date: Thu, 30 Oct 2008 02:39:09 +0000 (+0000) Subject: Branch b1_8_gate X-Git-Tag: v1_7_130~1^140 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a5b04991d1af66a7a201f6dc0b335fa30dda2ec3;p=fs%2Flustre-release.git Branch b1_8_gate b=16887 i=pravin.shelar i=adilger Address LBUG, ASSERTION(client_stat->nid_exp_ref_count == 0) failed:count -1 * add client stat on obd_nid_stat after client stat is ready. * properly decrease exp_nid_stats' nid_exp_ref_count in lprocfs_exp_cleanup(). --- diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 7fcb81e..73be24a 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -142,8 +142,8 @@ cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root, return proc; } - -static ssize_t lprocfs_fops_read(struct file *f, char __user *buf, size_t size, loff_t *ppos) +static ssize_t lprocfs_fops_read(struct file *f, char __user *buf, size_t size, + loff_t *ppos) { struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode); char *page, *start = NULL; @@ -191,7 +191,8 @@ out: return rc; } -static ssize_t lprocfs_fops_write(struct file *f, const char __user *buf, size_t size, loff_t *ppos) +static ssize_t lprocfs_fops_write(struct file *f, const char __user *buf, + size_t size, loff_t *ppos) { struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode); int rc = -EIO; @@ -619,15 +620,15 @@ int lprocfs_rd_conn_uuid(char *page, char **start, off_t off, int count, #define flag2str(flag) \ if (imp->imp_##flag && max - len > 0) \ len += snprintf(str + len, max - len, " " #flag); - + /** * Append a space separated list of current set flags to str. */ -static int obd_import_flags2str(struct obd_import *imp, char *str, +static int obd_import_flags2str(struct obd_import *imp, char *str, int max) { int len = 0; - + if (imp->imp_obd->obd_no_recov) len += snprintf(str, max - len, " no_recov"); @@ -655,7 +656,7 @@ int lprocfs_rd_import(char *page, char **start, off_t off, int count, imp_state_name = ptlrpc_import_state_name(imp->imp_state); *eof = 1; - rc = snprintf(page, count, + rc = snprintf(page, count, "import: %s\n" " target: %s@%s\n" " state: %s\n" @@ -717,7 +718,6 @@ int lprocfs_rd_timeouts(char *page, char **start, off_t off, int count, "%-10s : %ld, "DHMS_FMT" ago\n", "last reply", imp->imp_last_reply_time, DHMS_VARS(&ts)); - cur = at_get(&imp->imp_at.iat_net_latency); worst = imp->imp_at.iat_net_latency.at_worst_ever; worstt = imp->imp_at.iat_net_latency.at_worst_time; @@ -1461,7 +1461,6 @@ void lprocfs_nid_stats_clear_write_cb(void *obj, void *data) return; } - int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, unsigned long count, void *data) { @@ -1473,7 +1472,8 @@ int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, 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); + 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); } @@ -1523,12 +1523,8 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) CFS_INIT_LIST_HEAD(&new_stat->nid_uuid_list); new_stat->nid = *nid; new_stat->nid_obd = exp->exp_obd; - new_stat->nid_exp_ref_count = 1; /* need live in hash after destroy export */ - - /* protect competitive add to list, not need locking on destroy */ - spin_lock(&obd->obd_nid_lock); - list_add(&new_stat->nid_list, &obd->obd_nid_stats); - spin_unlock(&obd->obd_nid_lock); + /* need live in hash after destroy export */ + new_stat->nid_exp_ref_count = 1; old_stat = lustre_hash_findadd_unique(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash); @@ -1599,6 +1595,11 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) exp->exp_nid_stats = new_stat; *newnid = 1; + /* protect competitive add to list, not need locking on destroy */ + spin_lock(&obd->obd_nid_lock); + list_add(&new_stat->nid_list, &obd->obd_nid_stats); + spin_unlock(&obd->obd_nid_lock); + RETURN(rc); destroy_new_ns: @@ -1606,9 +1607,6 @@ destroy_new_ns: OBD_FREE_PTR(new_ns_uuid); destroy_new: - spin_lock(&obd->obd_nid_lock); - list_del(&new_stat->nid_list); - spin_unlock(&obd->obd_nid_lock); OBD_FREE_PTR(new_stat); RETURN(rc); } @@ -1631,6 +1629,9 @@ int lprocfs_exp_cleanup(struct obd_export *exp) found = 1; list_del(&cursor->ns_uuid_list); OBD_FREE_PTR(cursor); + --stat->nid_exp_ref_count; + CDEBUG(D_INFO, "Put stat %p - %d\n", stat, + stat->nid_exp_ref_count); break; } } @@ -1639,9 +1640,6 @@ int lprocfs_exp_cleanup(struct obd_export *exp) CERROR("obd_export's client uuid %s are not found in its " "nid_stats list\n", exp->exp_client_uuid.uuid); - stat->nid_exp_ref_count--; - CDEBUG(D_INFO, "Put stat %p - %d\n", stat, stat->nid_exp_ref_count); - exp->exp_nid_stats = NULL; lprocfs_free_stats(&exp->exp_ops_stats); @@ -1696,7 +1694,8 @@ int lprocfs_write_frac_helper(const char *buffer, unsigned long count, return 0; } -int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mult) +int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, + int mult) { long decimal_val, frac_val; int prtn; @@ -1714,7 +1713,8 @@ int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mu temp_frac = frac_val * 10; buffer[prtn++] = '.'; - while (frac_bits < 2 && (temp_frac / mult) < 1 ) { /*only reserved 2bits fraction*/ + while (frac_bits < 2 && (temp_frac / mult) < 1 ) { + /*only reserved 2bits fraction*/ buffer[prtn++] ='0'; temp_frac *= 10; frac_bits++; @@ -1927,7 +1927,8 @@ int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off, obd->obd_recovery_end - obd->obd_recovery_start) <= 0) goto out; - if (lprocfs_obd_snprintf(&page, size, &len,"delayed_clients: %d/%d\n", + if (lprocfs_obd_snprintf(&page, size, &len, + "delayed_clients: %d/%d\n", obd->obd_delayed_clients, obd->obd_max_recoverable_clients) <= 0) goto out; @@ -2109,7 +2110,6 @@ int lprocfs_obd_wr_flush_stale_exports(struct file *file, const char *buffer, } EXPORT_SYMBOL(lprocfs_obd_wr_flush_stale_exports); - EXPORT_SYMBOL(lprocfs_register); EXPORT_SYMBOL(lprocfs_srch); EXPORT_SYMBOL(lprocfs_remove);