Whamcloud - gitweb
LU-2484 obd: add md_stats to MDC and LMV devices
[fs/lustre-release.git] / lustre / mgs / mgs_fs.c
index 6d237c4..3f31626 100644 (file)
 #include "mgs_internal.h"
 
 int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp,
-                          void *localdata)
-
+                         void *localdata)
 {
-        lnet_nid_t *client_nid = localdata;
-        int rc, newnid;
-        ENTRY;
-
-        rc = lprocfs_exp_setup(exp, client_nid, &newnid);
-        if (rc) {
-                /* Mask error for already created
-                 * /proc entries */
-                if (rc == -EALREADY)
-                        rc = 0;
-                RETURN(rc);
-        }
-        if (newnid) {
-                struct nid_stat *tmp = exp->exp_nid_stats;
-                int num_stats = 0;
-
-                num_stats = (sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) +
-                            LPROC_MGS_LAST - 1;
-                tmp->nid_stats = lprocfs_alloc_stats(num_stats,
-                                                     LPROCFS_STATS_FLAG_NOPERCPU);
-                if (tmp->nid_stats == NULL)
-                        return -ENOMEM;
-                lprocfs_init_ops_stats(LPROC_MGS_LAST, tmp->nid_stats);
-                mgs_stats_counter_init(tmp->nid_stats);
-                rc = lprocfs_register_stats(tmp->nid_proc, "stats",
-                                            tmp->nid_stats);
-                if (rc)
-                        GOTO(clean, rc);
-
-                rc = lprocfs_nid_ldlm_stats_init(tmp);
-                if (rc)
-                        GOTO(clean, rc);
+       lnet_nid_t *client_nid = localdata;
+       struct nid_stat *tmp;
+       int rc, is_new_nid;
+       ENTRY;
+
+       rc = lprocfs_exp_setup(exp, client_nid, &is_new_nid);
+       if (rc != 0) {
+               /* Mask error for already created /proc entries */
+               if (rc == -EALREADY)
+                       rc = 0;
+               GOTO(out, rc = 0);
         }
-        RETURN(0);
-clean:
-        return rc;
+
+       if (!is_new_nid)
+               GOTO(out, rc = 0);
+
+       tmp = exp->exp_nid_stats;
+       tmp->nid_stats = lprocfs_alloc_stats(NUM_OBD_STATS + LPROC_MGS_LAST,
+                                            LPROCFS_STATS_FLAG_NOPERCPU);
+       if (tmp->nid_stats == NULL)
+               GOTO(out, rc = -ENOMEM);
+
+       lprocfs_init_ops_stats(LPROC_MGS_LAST, tmp->nid_stats);
+       mgs_stats_counter_init(tmp->nid_stats);
+       rc = lprocfs_register_stats(tmp->nid_proc, "stats", tmp->nid_stats);
+       if (rc != 0)
+               GOTO(out, rc);
+
+       rc = lprocfs_nid_ldlm_stats_init(tmp);
+       if (rc != 0)
+               GOTO(out, rc);
+
+       RETURN(0);
+out:
+       return rc;
 }
 
 /**