Whamcloud - gitweb
LU-12931 gnilnd: use time_after() to compare jiffies
[fs/lustre-release.git] / lustre / obdclass / lprocfs_jobstats.c
index dc1f6b2..e4aad7f 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-
 #include <obd_class.h>
 #include <lprocfs_status.h>
-#include <lustre/lustre_idl.h>
 
 #ifdef CONFIG_PROC_FS
 
@@ -67,7 +65,7 @@ struct job_stat {
        struct hlist_node       js_hash;        /* hash struct for this jobid */
        struct list_head        js_list;        /* on ojs_list, with ojs_lock */
        atomic_t                js_refcount;    /* num users of this struct */
-       char                    js_jobid[LUSTRE_JOBID_SIZE]; /* job name */
+       char                    js_jobid[LUSTRE_JOBID_SIZE]; /* job name + NUL*/
        time64_t                js_timestamp;   /* seconds of most recent stat*/
        struct lprocfs_stats    *js_stats;      /* per-job statistics */
        struct obd_job_stats    *js_jobstats;   /* for accessing ojs_lock */
@@ -254,7 +252,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, LUSTRE_JOBID_SIZE);
+       memcpy(job->js_jobid, jobid, sizeof(job->js_jobid));
        job->js_timestamp = ktime_get_real_seconds();
        job->js_jobstats = jobs;
        INIT_HLIST_NODE(&job->js_hash);
@@ -488,10 +486,6 @@ static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc;
 
-       rc = LPROCFS_ENTRY_CHECK(inode);
-       if (rc < 0)
-               return rc;
-
        rc = seq_open(file, &lprocfs_jobstats_seq_sops);
        if (rc)
                return rc;
@@ -626,45 +620,38 @@ int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
        RETURN(0);
 }
 EXPORT_SYMBOL(lprocfs_job_stats_init);
+#endif /* CONFIG_PROC_FS*/
 
-int lprocfs_job_interval_seq_show(struct seq_file *m, void *data)
+ssize_t job_cleanup_interval_show(struct kobject *kobj, struct attribute *attr,
+                                 char *buf)
 {
-       struct obd_device *obd = m->private;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
        struct obd_job_stats *stats;
 
-       if (obd == NULL)
-               return -ENODEV;
-
        stats = &obd->u.obt.obt_jobstats;
-       seq_printf(m, "%d\n", stats->ojs_cleanup_interval);
-       return 0;
+       return scnprintf(buf, PAGE_SIZE, "%d\n", stats->ojs_cleanup_interval);
 }
-EXPORT_SYMBOL(lprocfs_job_interval_seq_show);
+EXPORT_SYMBOL(job_cleanup_interval_show);
 
-ssize_t
-lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer,
-                               size_t count, loff_t *off)
+ssize_t job_cleanup_interval_store(struct kobject *kobj,
+                                  struct attribute *attr,
+                                  const char *buffer, size_t count)
 {
-       struct obd_device *obd;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
        struct obd_job_stats *stats;
+       unsigned int val;
        int rc;
-       __s64 val;
-
-       obd = ((struct seq_file *)file->private_data)->private;
-       if (obd == NULL)
-               return -ENODEV;
 
        stats = &obd->u.obt.obt_jobstats;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint(buffer, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > UINT_MAX)
-               return -ERANGE;
 
        stats->ojs_cleanup_interval = val;
        lprocfs_job_cleanup(stats, stats->ojs_cleanup_interval);
        return count;
 }
-EXPORT_SYMBOL(lprocfs_job_interval_seq_write);
-#endif /* CONFIG_PROC_FS*/
+EXPORT_SYMBOL(job_cleanup_interval_store);