Whamcloud - gitweb
Branch HEAD
authorbobijam <bobijam>
Thu, 30 Oct 2008 02:18:07 +0000 (02:18 +0000)
committerbobijam <bobijam>
Thu, 30 Oct 2008 02:18:07 +0000 (02:18 +0000)
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().

lustre/obdclass/lprocfs_status.c

index 61a2fca..393c008 100644 (file)
@@ -206,7 +206,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;
@@ -644,15 +645,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");
 
@@ -680,7 +681,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"
@@ -742,7 +743,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;
@@ -1581,7 +1581,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);
         }
@@ -1633,11 +1634,6 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
         new_stat->nid_obd           = exp->exp_obd;
         new_stat->nid_exp_ref_count = 1; /* 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);
-
         old_stat = lustre_hash_findadd_unique(obd->obd_nid_stats_hash,
                                               nid, &new_stat->nid_hash);
         CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
@@ -1707,6 +1703,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:
@@ -1714,9 +1715,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);
 }
@@ -1739,6 +1737,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;
                 }
         }
@@ -1747,9 +1748,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_md_stats(exp->exp_obd);
 
@@ -1804,7 +1802,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;