Whamcloud - gitweb
LU-39 ASSERTION(atomic_read(&client_stat->nid_exp_ref_count) == 0)
authorBobi Jam <bobijam@whamcloud.com>
Tue, 22 Mar 2011 03:01:52 +0000 (11:01 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 23 Mar 2011 04:31:11 +0000 (21:31 -0700)
In lprocfs_exp_setup(), we need release old stats in all cases.

Bugzilla: 23499
Change-Id: Ida40ffe82a12e213779e344da92f5e3e437f8c8b
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/350
Tested-by: Hudson
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lprocfs_status.h
lustre/mdt/mdt_fs.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mgs/mgs_fs.c
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_internal.h
lustre/obdclass/lprocfs_status.c
lustre/obdfilter/filter.c

index 7c55f20..9ce1985 100644 (file)
@@ -440,7 +440,7 @@ struct nid_stat;
 extern int lprocfs_add_clear_entry(struct obd_device * obd,
                                    cfs_proc_dir_entry_t *entry);
 extern int lprocfs_exp_setup(struct obd_export *exp,
 extern int lprocfs_add_clear_entry(struct obd_device * obd,
                                    cfs_proc_dir_entry_t *entry);
 extern int lprocfs_exp_setup(struct obd_export *exp,
-                             lnet_nid_t *peer_nid, int reconnect, int *newnid);
+                             lnet_nid_t *peer_nid, int *newnid);
 extern int lprocfs_exp_cleanup(struct obd_export *exp);
 extern cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
                                                 char *name,
 extern int lprocfs_exp_cleanup(struct obd_export *exp);
 extern cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
                                                 char *name,
@@ -761,7 +761,7 @@ struct obd_export;
 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
 { return 0; }
 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid,
 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
 { return 0; }
 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid,
-                                    int reconnect, int *newnid)
+                                    int *newnid)
 { return 0; }
 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
 { return 0; }
 { return 0; }
 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
 { return 0; }
index b0ba74e..3996b80 100644 (file)
 
 int mdt_export_stats_init(struct obd_device *obd,
                           struct obd_export *exp,
 
 int mdt_export_stats_init(struct obd_device *obd,
                           struct obd_export *exp,
-                          int               reconnect,
                           void              *localdata)
 {
         lnet_nid_t *client_nid = localdata;
         int        rc, newnid;
         ENTRY;
 
                           void              *localdata)
 {
         lnet_nid_t *client_nid = localdata;
         int        rc, newnid;
         ENTRY;
 
-        rc = lprocfs_exp_setup(exp, client_nid, reconnect, &newnid);
+        rc = lprocfs_exp_setup(exp, client_nid, &newnid);
         if (rc) {
                 /* Mask error for already created
                  * /proc entries */
         if (rc) {
                 /* Mask error for already created
                  * /proc entries */
index 1cb5d07..0a86137 100644 (file)
@@ -5035,7 +5035,7 @@ static int mdt_obd_connect(const struct lu_env *env,
                 memcpy(lcd->lcd_uuid, cluuid, sizeof lcd->lcd_uuid);
                 rc = mdt_client_new(env, mdt);
                 if (rc == 0)
                 memcpy(lcd->lcd_uuid, cluuid, sizeof lcd->lcd_uuid);
                 rc = mdt_client_new(env, mdt);
                 if (rc == 0)
-                        mdt_export_stats_init(obd, lexp, 0, localdata);
+                        mdt_export_stats_init(obd, lexp, localdata);
         }
 
 out:
         }
 
 out:
@@ -5074,7 +5074,7 @@ static int mdt_obd_reconnect(const struct lu_env *env,
 
         rc = mdt_connect_internal(exp, mdt_dev(obd->obd_lu_dev), data);
         if (rc == 0)
 
         rc = mdt_connect_internal(exp, mdt_dev(obd->obd_lu_dev), data);
         if (rc == 0)
-                mdt_export_stats_init(obd, exp, 1, localdata);
+                mdt_export_stats_init(obd, exp, localdata);
 
         RETURN(rc);
 }
 
         RETURN(rc);
 }
@@ -5234,7 +5234,7 @@ static void mdt_allow_cli(struct mdt_device *m, unsigned int flag)
         if (cfs_test_bit(MDT_FL_CFGLOG, &m->mdt_state) &&
             cfs_test_bit(MDT_FL_SYNCED, &m->mdt_state)) {
                 struct obd_device *obd = m->mdt_md_dev.md_lu_dev.ld_obd;
         if (cfs_test_bit(MDT_FL_CFGLOG, &m->mdt_state) &&
             cfs_test_bit(MDT_FL_SYNCED, &m->mdt_state)) {
                 struct obd_device *obd = m->mdt_md_dev.md_lu_dev.ld_obd;
+
                 /* Open for clients */
                 if (obd->obd_no_conn) {
                         cfs_spin_lock(&obd->obd_dev_lock);
                 /* Open for clients */
                 if (obd->obd_no_conn) {
                         cfs_spin_lock(&obd->obd_dev_lock);
index e84628f..44aa75b 100644 (file)
@@ -576,7 +576,6 @@ int mdt_client_new(const struct lu_env *env,
 
 int mdt_export_stats_init(struct obd_device *obd,
                           struct obd_export *exp,
 
 int mdt_export_stats_init(struct obd_device *obd,
                           struct obd_export *exp,
-                          int reconnect,
                           void *client_nid);
 
 int mdt_pin(struct mdt_thread_info* info);
                           void *client_nid);
 
 int mdt_pin(struct mdt_thread_info* info);
index 29bd959..54ac63d 100644 (file)
 #include "mgs_internal.h"
 
 int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp,
 #include "mgs_internal.h"
 
 int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp,
-                          int reconnect, void *localdata)
+                          void *localdata)
 
 {
         lnet_nid_t *client_nid = localdata;
         int rc, newnid;
         ENTRY;
 
 
 {
         lnet_nid_t *client_nid = localdata;
         int rc, newnid;
         ENTRY;
 
-        rc = lprocfs_exp_setup(exp, client_nid, reconnect, &newnid);
+        rc = lprocfs_exp_setup(exp, client_nid, &newnid);
         if (rc) {
                 /* Mask error for already created
                  * /proc entries */
         if (rc) {
                 /* Mask error for already created
                  * /proc entries */
index 770cab8..e0b8469 100644 (file)
@@ -90,7 +90,7 @@ static int mgs_connect(const struct lu_env *env,
                 data->ocd_version = LUSTRE_VERSION_CODE;
         }
 
                 data->ocd_version = LUSTRE_VERSION_CODE;
         }
 
-        rc = mgs_export_stats_init(obd, lexp, 0, localdata);
+        rc = mgs_export_stats_init(obd, lexp, localdata);
 
         if (rc) {
                 class_disconnect(lexp);
 
         if (rc) {
                 class_disconnect(lexp);
@@ -119,7 +119,7 @@ static int mgs_reconnect(const struct lu_env *env,
                 data->ocd_version = LUSTRE_VERSION_CODE;
         }
 
                 data->ocd_version = LUSTRE_VERSION_CODE;
         }
 
-        RETURN(mgs_export_stats_init(obd, exp, 1, localdata));
+        RETURN(mgs_export_stats_init(obd, exp, localdata));
 }
 
 static int mgs_disconnect(struct obd_export *exp)
 }
 
 static int mgs_disconnect(struct obd_export *exp)
index 35534d0..ae3c424 100644 (file)
@@ -115,7 +115,7 @@ void mgs_revoke_lock(struct obd_device *obd, struct fs_db *fsdb);
 
 /* mgs_fs.c */
 int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp,
 
 /* mgs_fs.c */
 int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp,
-                          int reconnect, void *localdata);
+                          void *localdata);
 int mgs_client_free(struct obd_export *exp);
 int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt);
 int mgs_fs_cleanup(struct obd_device *obddev);
 int mgs_client_free(struct obd_export *exp);
 int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt);
 int mgs_fs_cleanup(struct obd_device *obddev);
index a6981db..67351d7 100644 (file)
@@ -1134,8 +1134,8 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat)
                client_stat->nid_brw_stats);
 
         LASSERTF(cfs_atomic_read(&client_stat->nid_exp_ref_count) == 0,
                client_stat->nid_brw_stats);
 
         LASSERTF(cfs_atomic_read(&client_stat->nid_exp_ref_count) == 0,
-                 "count %d\n",
-                 cfs_atomic_read(&client_stat->nid_exp_ref_count));
+                 "nid %s:count %d\n", libcfs_nid2str(client_stat->nid),
+                 atomic_read(&client_stat->nid_exp_ref_count));
 
         cfs_hlist_del_init(&client_stat->nid_hash);
 
 
         cfs_hlist_del_init(&client_stat->nid_hash);
 
@@ -1815,8 +1815,7 @@ int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
 }
 EXPORT_SYMBOL(lprocfs_nid_stats_clear_write);
 
 }
 EXPORT_SYMBOL(lprocfs_nid_stats_clear_write);
 
-int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int reconnect,
-                      int *newnid)
+int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
 {
         struct nid_stat *new_stat, *old_stat;
         struct obd_device *obd = NULL;
 {
         struct nid_stat *new_stat, *old_stat;
         struct obd_device *obd = NULL;
@@ -1856,15 +1855,16 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int reconnect,
                old_stat, libcfs_nid2str(*nid),
                cfs_atomic_read(&new_stat->nid_exp_ref_count));
 
                old_stat, libcfs_nid2str(*nid),
                cfs_atomic_read(&new_stat->nid_exp_ref_count));
 
+        /* We need to release old stats because lprocfs_exp_cleanup() hasn't
+         * been and will never be called. */
+        if (exp->exp_nid_stats) {
+                nidstat_putref(exp->exp_nid_stats);
+                exp->exp_nid_stats = NULL;
+        }
+
         /* Return -EALREADY here so that we know that the /proc
          * entry already has been created */
         if (old_stat != new_stat) {
         /* Return -EALREADY here so that we know that the /proc
          * entry already has been created */
         if (old_stat != new_stat) {
-                /* if this connects to the existing export of same nid,
-                 * we need to release old stats for obd_disconnect won't
-                 * balance the reference gotten in "cfs_hash_findadd_uinque" */
-                if (reconnect && exp->exp_nid_stats)
-                        nidstat_putref(old_stat);
-
                 exp->exp_nid_stats = old_stat;
                 GOTO(destroy_new, rc = -EALREADY);
         }
                 exp->exp_nid_stats = old_stat;
                 GOTO(destroy_new, rc = -EALREADY);
         }
index 18a247b..501652d 100644 (file)
@@ -241,7 +241,6 @@ static int lprocfs_init_rw_stats(struct obd_device *obd,
    plus the procfs overhead :( */
 static int filter_export_stats_init(struct obd_device *obd,
                                     struct obd_export *exp,
    plus the procfs overhead :( */
 static int filter_export_stats_init(struct obd_device *obd,
                                     struct obd_export *exp,
-                                    int reconnect,
                                     void *client_nid)
 {
         int rc, newnid = 0;
                                     void *client_nid)
 {
         int rc, newnid = 0;
@@ -251,7 +250,7 @@ static int filter_export_stats_init(struct obd_device *obd,
                 /* Self-export gets no proc entry */
                 RETURN(0);
 
                 /* Self-export gets no proc entry */
                 RETURN(0);
 
-        rc = lprocfs_exp_setup(exp, client_nid, reconnect, &newnid);
+        rc = lprocfs_exp_setup(exp, client_nid, &newnid);
         if (rc) {
                 /* Mask error for already created
                  * /proc entries */
         if (rc) {
                 /* Mask error for already created
                  * /proc entries */
@@ -869,7 +868,7 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp)
                 fed = &exp->exp_filter_data;
                 *fed->fed_ted.ted_lcd = *lcd;
                 fed->fed_group = 0; /* will be assigned at connect */
                 fed = &exp->exp_filter_data;
                 *fed->fed_ted.ted_lcd = *lcd;
                 fed->fed_group = 0; /* will be assigned at connect */
-                filter_export_stats_init(obd, exp, 0, NULL);
+                filter_export_stats_init(obd, exp, NULL);
                 rc = filter_client_add(obd, exp, cl_idx);
                 /* can't fail for existing client */
                 LASSERTF(rc == 0, "rc = %d\n", rc);
                 rc = filter_client_add(obd, exp, cl_idx);
                 /* can't fail for existing client */
                 LASSERTF(rc == 0, "rc = %d\n", rc);
@@ -2749,7 +2748,7 @@ static int filter_reconnect(const struct lu_env *env,
 
         rc = filter_connect_internal(exp, data, 1);
         if (rc == 0)
 
         rc = filter_connect_internal(exp, data, 1);
         if (rc == 0)
-                filter_export_stats_init(obd, exp, 1, localdata);
+                filter_export_stats_init(obd, exp, localdata);
 
         RETURN(rc);
 }
 
         RETURN(rc);
 }
@@ -2780,7 +2779,7 @@ static int filter_connect(const struct lu_env *env,
         if (rc)
                 GOTO(cleanup, rc);
 
         if (rc)
                 GOTO(cleanup, rc);
 
-        filter_export_stats_init(obd, lexp, 0, localdata);
+        filter_export_stats_init(obd, lexp, localdata);
         if (obd->obd_replayable) {
                 struct lsd_client_data *lcd = lexp->exp_target_data.ted_lcd;
                 LASSERT(lcd);
         if (obd->obd_replayable) {
                 struct lsd_client_data *lcd = lexp->exp_target_data.ted_lcd;
                 LASSERT(lcd);