X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Flprocfs_jobstats.c;h=d4438418c787d55918b54faab5f96d1b44d5a2a8;hb=79e65c81349f539aa2960a1889144ce71d91351e;hp=dab281b857e7f6430f0658f71913db5d62178b4a;hpb=bc71055256db623ba2062f8f299d8b603d89e0d9;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/lprocfs_jobstats.c b/lustre/obdclass/lprocfs_jobstats.c index dab281b..d443841 100644 --- a/lustre/obdclass/lprocfs_jobstats.c +++ b/lustre/obdclass/lprocfs_jobstats.c @@ -69,7 +69,7 @@ struct job_stat { cfs_hlist_node_t js_hash; cfs_list_t js_list; - cfs_atomic_t js_refcount; + atomic_t js_refcount; char js_jobid[JOBSTATS_JOBID_SIZE]; time_t js_timestamp; /* seconds */ struct lprocfs_stats *js_stats; @@ -105,7 +105,7 @@ static void job_stat_get(cfs_hash_t *hs, cfs_hlist_node_t *hnode) { struct job_stat *job; job = cfs_hlist_entry(hnode, struct job_stat, js_hash); - cfs_atomic_inc(&job->js_refcount); + atomic_inc(&job->js_refcount); } static void job_free(struct job_stat *job) @@ -204,7 +204,7 @@ static struct job_stat *job_alloc(char *jobid, struct obd_job_stats *jobs) job->js_jobstats = jobs; CFS_INIT_HLIST_NODE(&job->js_hash); CFS_INIT_LIST_HEAD(&job->js_list); - cfs_atomic_set(&job->js_refcount, 1); + atomic_set(&job->js_refcount, 1); return job; } @@ -416,20 +416,17 @@ struct seq_operations lprocfs_jobstats_seq_sops = { static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file) { - struct proc_dir_entry *dp = PDE(inode); struct seq_file *seq; int rc; - if (LPROCFS_ENTRY_AND_CHECK(dp)) + if (LPROCFS_ENTRY_CHECK(PDE(inode))) return -ENOENT; rc = seq_open(file, &lprocfs_jobstats_seq_sops); - if (rc) { - LPROCFS_EXIT(); + if (rc) return rc; - } seq = file->private_data; - seq->private = dp->data; + seq->private = PDE_DATA(inode); return 0; } @@ -522,19 +519,18 @@ int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num, stats->ojs_last_cleanup = cfs_time_current_sec(); LPROCFS_WRITE_ENTRY(); - entry = create_proc_entry("job_stats", 0644, obd->obd_proc_entry); + entry = proc_create_data("job_stats", 0644, obd->obd_proc_entry, + &lprocfs_jobstats_seq_fops, stats); LPROCFS_WRITE_EXIT(); - if (entry) { - entry->proc_fops = &lprocfs_jobstats_seq_fops; - entry->data = stats; - RETURN(0); - } else { + if (entry == NULL) { lprocfs_job_stats_fini(obd); RETURN(-ENOMEM); } + RETURN(0); } 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) { @@ -569,5 +565,36 @@ int lprocfs_wr_job_interval(struct file *file, const char *buffer, } 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; + struct obd_job_stats *stats; + + LASSERT(obd != NULL); + stats = &obd->u.obt.obt_jobstats; + return seq_printf(m, "%d\n", stats->ojs_cleanup_interval); +} +EXPORT_SYMBOL(lprocfs_job_interval_seq_show); + +ssize_t +lprocfs_job_interval_seq_write(struct file *file, const char *buffer, + size_t count, loff_t *off) +{ + struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + 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_job_interval_seq_write); #endif /* LPROCFS*/