Whamcloud - gitweb
LU-5275 lprocfs: reduce scope of params_tree.h
[fs/lustre-release.git] / lustre / obdclass / lprocfs_jobstats.c
index 05b378e..6bb1661 100644 (file)
@@ -19,7 +19,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Niu Yawei <niu@whamcloud.com>
@@ -30,9 +30,6 @@
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
 
 #include <obd_class.h>
 #include <lprocfs_status.h>
@@ -70,7 +67,7 @@ struct job_stat {
        struct hlist_node       js_hash;
        struct list_head        js_list;
        atomic_t                js_refcount;
-       char                    js_jobid[JOBSTATS_JOBID_SIZE];
+       char                    js_jobid[LUSTRE_JOBID_SIZE];
        time_t                  js_timestamp; /* seconds */
        struct lprocfs_stats    *js_stats;
        struct obd_job_stats    *js_jobstats;
@@ -199,7 +196,7 @@ static struct job_stat *job_alloc(char *jobid, struct obd_job_stats *jobs)
 
        jobs->ojs_cntr_init_fn(job->js_stats);
 
-       memcpy(job->js_jobid, jobid, JOBSTATS_JOBID_SIZE);
+       memcpy(job->js_jobid, jobid, LUSTRE_JOBID_SIZE);
        job->js_timestamp = cfs_time_current_sec();
        job->js_jobstats = jobs;
        INIT_HLIST_NODE(&job->js_hash);
@@ -223,9 +220,9 @@ int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
        if (!jobid || !strlen(jobid))
                RETURN(-EINVAL);
 
-       if (strlen(jobid) >= JOBSTATS_JOBID_SIZE) {
+       if (strlen(jobid) >= LUSTRE_JOBID_SIZE) {
                CERROR("Invalid jobid size (%lu), expect(%d)\n",
-                      (unsigned long)strlen(jobid) + 1, JOBSTATS_JOBID_SIZE);
+                      (unsigned long)strlen(jobid) + 1, LUSTRE_JOBID_SIZE);
                RETURN(-EINVAL);
        }
 
@@ -407,7 +404,7 @@ static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v)
        return 0;
 }
 
-struct seq_operations lprocfs_jobstats_seq_sops = {
+static const struct seq_operations lprocfs_jobstats_seq_sops = {
        start: lprocfs_jobstats_seq_start,
        stop:  lprocfs_jobstats_seq_stop,
        next:  lprocfs_jobstats_seq_next,
@@ -419,8 +416,9 @@ static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc;
 
-       if (LPROCFS_ENTRY_CHECK(PDE(inode)))
-               return -ENOENT;
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               return rc;
 
        rc = seq_open(file, &lprocfs_jobstats_seq_sops);
        if (rc)
@@ -436,11 +434,11 @@ static ssize_t lprocfs_jobstats_seq_write(struct file *file,
 {
        struct seq_file *seq = file->private_data;
        struct obd_job_stats *stats = seq->private;
-       char jobid[JOBSTATS_JOBID_SIZE];
+       char jobid[LUSTRE_JOBID_SIZE];
        int all = 0;
        struct job_stat *job;
 
-       if (len == 0 || len >= JOBSTATS_JOBID_SIZE)
+       if (len == 0 || len >= LUSTRE_JOBID_SIZE)
                return -EINVAL;
 
        if (copy_from_user(jobid, buf, len))
@@ -475,7 +473,7 @@ static ssize_t lprocfs_jobstats_seq_write(struct file *file,
        return len;
 }
 
-struct file_operations lprocfs_jobstats_seq_fops = {
+static const struct file_operations lprocfs_jobstats_seq_fops = {
        .owner   = THIS_MODULE,
        .open    = lprocfs_jobstats_seq_open,
        .read    = seq_read,
@@ -532,42 +530,6 @@ int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
 }
 EXPORT_SYMBOL(lprocfs_job_stats_init);
 
-#ifndef HAVE_ONLY_PROCFS_SEQ
-int lprocfs_rd_job_interval(char *page, char **start, off_t off,
-                           int count, int *eof, void *data)
-{
-       struct obd_device *obd = (struct obd_device *)data;
-       struct obd_job_stats *stats;
-
-       LASSERT(obd != NULL);
-       stats = &obd->u.obt.obt_jobstats;
-       *eof = 1;
-       return snprintf(page, count, "%d\n", stats->ojs_cleanup_interval);
-}
-EXPORT_SYMBOL(lprocfs_rd_job_interval);
-
-int lprocfs_wr_job_interval(struct file *file, const char __user *buffer,
-                           unsigned long count, void *data)
-{
-       struct obd_device *obd = (struct obd_device *)data;
-       struct obd_job_stats *stats;
-       int val, rc;
-
-       LASSERT(obd != NULL);
-       stats = &obd->u.obt.obt_jobstats;
-
-       rc = lprocfs_write_helper(buffer, count, &val);
-       if (rc)
-               return rc;
-
-       stats->ojs_cleanup_interval = val;
-       lprocfs_job_cleanup(stats, true);
-
-       return count;
-
-}
-EXPORT_SYMBOL(lprocfs_wr_job_interval);
-#endif
 int lprocfs_job_interval_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;