Whamcloud - gitweb
LU-224 Move fail_loc handling from lustre to libcfs
[fs/lustre-release.git] / lustre / mdt / mdt_lproc.c
index 24932d9..8fa813d 100644 (file)
@@ -112,6 +112,8 @@ int mdt_procfs_init(struct mdt_device *mdt, const char *name)
                                    "clear", lprocfs_nid_stats_clear_read,
                                    lprocfs_nid_stats_clear_write, obd, NULL);
         rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST);
+        if (rc == 0)
+                mdt_stats_counter_init(obd->md_stats);
 
         RETURN(rc);
 }
@@ -154,8 +156,8 @@ static int lprocfs_rd_identity_expire(char *page, char **start, off_t off,
         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
         *eof = 1;
-        return snprintf(page, count, "%lu\n",
-                        mdt->mdt_identity_cache->uc_entry_expire / CFS_HZ);
+        return snprintf(page, count, "%u\n",
+                        mdt->mdt_identity_cache->uc_entry_expire);
 }
 
 static int lprocfs_wr_identity_expire(struct file *file, const char *buffer,
@@ -169,7 +171,7 @@ static int lprocfs_wr_identity_expire(struct file *file, const char *buffer,
         if (rc)
                 return rc;
 
-        mdt->mdt_identity_cache->uc_entry_expire = val * CFS_HZ;
+        mdt->mdt_identity_cache->uc_entry_expire = val;
         return count;
 }
 
@@ -181,8 +183,8 @@ static int lprocfs_rd_identity_acquire_expire(char *page, char **start,
         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
         *eof = 1;
-        return snprintf(page, count, "%lu\n",
-                        mdt->mdt_identity_cache->uc_acquire_expire / CFS_HZ);
+        return snprintf(page, count, "%u\n",
+                        mdt->mdt_identity_cache->uc_acquire_expire);
 }
 
 static int lprocfs_wr_identity_acquire_expire(struct file *file,
@@ -198,7 +200,7 @@ static int lprocfs_wr_identity_acquire_expire(struct file *file,
         if (rc)
                 return rc;
 
-        mdt->mdt_identity_cache->uc_acquire_expire = val * CFS_HZ;
+        mdt->mdt_identity_cache->uc_acquire_expire = val;
         return count;
 }
 
@@ -223,17 +225,18 @@ static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer,
         struct obd_device *obd = data;
         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
         struct upcall_cache *hash = mdt->mdt_identity_cache;
-        char kernbuf[UC_CACHE_UPCALL_MAXPATH] = { '\0' };
+        int rc;
+        char *kernbuf;
 
         if (count >= UC_CACHE_UPCALL_MAXPATH) {
                 CERROR("%s: identity upcall too long\n", obd->obd_name);
                 return -EINVAL;
         }
-
-        if (cfs_copy_from_user(kernbuf, buffer,
-                               min_t(unsigned long, count,
-                                     UC_CACHE_UPCALL_MAXPATH - 1)))
-                return -EFAULT;
+        OBD_ALLOC(kernbuf, count + 1);
+        if (kernbuf == NULL)
+                GOTO(failed, rc = -ENOMEM);
+        if (cfs_copy_from_user(kernbuf, buffer, count))
+                GOTO(failed, rc = -EFAULT);
 
         /* Remove any extraneous bits from the upcall (e.g. linefeeds) */
         cfs_write_lock(&hash->uc_upcall_rwlock);
@@ -249,7 +252,13 @@ static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer,
                       "cause unexpected \"EACCESS\"\n", obd->obd_name);
 
         CWARN("%s: identity upcall set to %s\n", obd->obd_name, hash->uc_upcall);
-        return count;
+        OBD_FREE(kernbuf, count + 1);
+        RETURN(count);
+
+ failed:
+        if (kernbuf)
+                OBD_FREE(kernbuf, count + 1);
+        RETURN(rc);
 }
 
 static int lprocfs_wr_identity_flush(struct file *file, const char *buffer,
@@ -813,8 +822,8 @@ void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars)
 
 void mdt_counter_incr(struct obd_export *exp, int opcode)
 {
-        if (exp->exp_obd && exp->exp_obd->obd_stats)
-                lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode);
+        if (exp->exp_obd && exp->exp_obd->md_stats)
+                lprocfs_counter_incr(exp->exp_obd->md_stats, opcode);
         if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
                 lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);