*/
struct job_stat {
- cfs_hlist_node_t js_hash;
- cfs_list_t js_list;
- atomic_t js_refcount;
- char js_jobid[JOBSTATS_JOBID_SIZE];
- time_t js_timestamp; /* seconds */
- struct lprocfs_stats *js_stats;
- struct obd_job_stats *js_jobstats;
+ struct hlist_node js_hash;
+ struct list_head js_list;
+ atomic_t js_refcount;
+ char js_jobid[JOBSTATS_JOBID_SIZE];
+ time_t js_timestamp; /* seconds */
+ struct lprocfs_stats *js_stats;
+ struct obd_job_stats *js_jobstats;
};
static unsigned job_stat_hash(cfs_hash_t *hs, const void *key, unsigned mask)
return cfs_hash_djb2_hash(key, strlen(key), mask);
}
-static void *job_stat_key(cfs_hlist_node_t *hnode)
+static void *job_stat_key(struct hlist_node *hnode)
{
struct job_stat *job;
- job = cfs_hlist_entry(hnode, struct job_stat, js_hash);
+ job = hlist_entry(hnode, struct job_stat, js_hash);
return job->js_jobid;
}
-static int job_stat_keycmp(const void *key, cfs_hlist_node_t *hnode)
+static int job_stat_keycmp(const void *key, struct hlist_node *hnode)
{
struct job_stat *job;
- job = cfs_hlist_entry(hnode, struct job_stat, js_hash);
+ job = hlist_entry(hnode, struct job_stat, js_hash);
return (strlen(job->js_jobid) == strlen(key)) &&
!strncmp(job->js_jobid, key, strlen(key));
}
-static void *job_stat_object(cfs_hlist_node_t *hnode)
+static void *job_stat_object(struct hlist_node *hnode)
{
- return cfs_hlist_entry(hnode, struct job_stat, js_hash);
+ return hlist_entry(hnode, struct job_stat, js_hash);
}
-static void job_stat_get(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
+static void job_stat_get(cfs_hash_t *hs, struct hlist_node *hnode)
{
struct job_stat *job;
- job = cfs_hlist_entry(hnode, struct job_stat, js_hash);
+ job = hlist_entry(hnode, struct job_stat, js_hash);
atomic_inc(&job->js_refcount);
}
LASSERT(job->js_jobstats);
write_lock(&job->js_jobstats->ojs_lock);
- cfs_list_del_init(&job->js_list);
+ list_del_init(&job->js_list);
write_unlock(&job->js_jobstats->ojs_lock);
lprocfs_free_stats(&job->js_stats);
job_free(job);
}
-static void job_stat_put_locked(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
+static void job_stat_put_locked(cfs_hash_t *hs, struct hlist_node *hnode)
{
struct job_stat *job;
- job = cfs_hlist_entry(hnode, struct job_stat, js_hash);
+ job = hlist_entry(hnode, struct job_stat, js_hash);
job_putref(job);
}
-static void job_stat_exit(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
+static void job_stat_exit(cfs_hash_t *hs, struct hlist_node *hnode)
{
- CERROR("Should not have any items!");
+ CERROR("should not have any items\n");
}
static cfs_hash_ops_t job_stats_hash_ops = {
};
static int job_iter_callback(cfs_hash_t *hs, cfs_hash_bd_t *bd,
- cfs_hlist_node_t *hnode, void *data)
+ struct hlist_node *hnode, void *data)
{
time_t oldest = *((time_t *)data);
struct job_stat *job;
- job = cfs_hlist_entry(hnode, struct job_stat, js_hash);
+ job = hlist_entry(hnode, struct job_stat, js_hash);
if (!oldest || job->js_timestamp < oldest)
cfs_hash_bd_del_locked(hs, bd, hnode);
memcpy(job->js_jobid, jobid, JOBSTATS_JOBID_SIZE);
job->js_timestamp = cfs_time_current_sec();
job->js_jobstats = jobs;
- CFS_INIT_HLIST_NODE(&job->js_hash);
- CFS_INIT_LIST_HEAD(&job->js_list);
+ INIT_HLIST_NODE(&job->js_hash);
+ INIT_LIST_HEAD(&job->js_list);
atomic_set(&job->js_refcount, 1);
return job;
if (job2 != job) {
job_putref(job);
job = job2;
- /* We cannot LASSERT(!cfs_list_empty(&job->js_list)) here,
+ /* We cannot LASSERT(!list_empty(&job->js_list)) here,
* since we just lost the race for inserting "job" into the
* ojs_list, and some other thread is doing it _right_now_.
* Instead, be content the other thread is doing this, since
* "job2" was initialized in job_alloc() already. LU-2163 */
} else {
- LASSERT(cfs_list_empty(&job->js_list));
+ LASSERT(list_empty(&job->js_list));
write_lock(&stats->ojs_lock);
- cfs_list_add_tail(&job->js_list, &stats->ojs_list);
+ list_add_tail(&job->js_list, &stats->ojs_list);
write_unlock(&stats->ojs_lock);
}
cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback, &oldest);
cfs_hash_putref(stats->ojs_hash);
stats->ojs_hash = NULL;
- LASSERT(cfs_list_empty(&stats->ojs_list));
+ LASSERT(list_empty(&stats->ojs_list));
}
EXPORT_SYMBOL(lprocfs_job_stats_fini);
if (off == 0)
return SEQ_START_TOKEN;
off--;
- cfs_list_for_each_entry(job, &stats->ojs_list, js_list) {
+ list_for_each_entry(job, &stats->ojs_list, js_list) {
if (!off--)
return job;
}
{
struct obd_job_stats *stats = p->private;
struct job_stat *job;
- cfs_list_t *next;
+ struct list_head *next;
++*pos;
if (v == SEQ_START_TOKEN) {
}
return next == &stats->ojs_list ? NULL :
- cfs_list_entry(next, struct job_stat, js_list);
+ list_entry(next, struct job_stat, js_list);
}
/*
return 0;
}
-static ssize_t lprocfs_jobstats_seq_write(struct file *file, const char *buf,
+static ssize_t lprocfs_jobstats_seq_write(struct file *file,
+ const char __user *buf,
size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
int all = 0;
struct job_stat *job;
- if (!memcmp(buf, "clear", strlen("clear"))) {
- all = 1;
- } else if (len < JOBSTATS_JOBID_SIZE) {
- memset(jobid, 0, JOBSTATS_JOBID_SIZE);
- /* Trim '\n' if any */
- if (buf[len - 1] == '\n')
- memcpy(jobid, buf, len - 1);
- else
- memcpy(jobid, buf, len);
- } else {
+ if (len == 0 || len >= JOBSTATS_JOBID_SIZE)
return -EINVAL;
- }
+
+ if (copy_from_user(jobid, buf, len))
+ return -EFAULT;
+ jobid[len] = 0;
+
+ /* Trim '\n' if any */
+ if (jobid[len - 1] == '\n')
+ jobid[len - 1] = 0;
+
+ if (strcmp(jobid, "clear") == 0)
+ all = 1;
LASSERT(stats->ojs_hash);
if (all) {
if (stats->ojs_hash == NULL)
RETURN(-ENOMEM);
- CFS_INIT_LIST_HEAD(&stats->ojs_list);
+ INIT_LIST_HEAD(&stats->ojs_list);
rwlock_init(&stats->ojs_lock);
stats->ojs_cntr_num = cntr_num;
stats->ojs_cntr_init_fn = init_fn;
}
EXPORT_SYMBOL(lprocfs_rd_job_interval);
-int lprocfs_wr_job_interval(struct file *file, const char *buffer,
+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;