return 0;
}
+struct proc_dir_entry *lprocfs_add_symlink(const char *name,
+ struct proc_dir_entry *parent, const char *dest)
+{
+ struct proc_dir_entry *entry;
+
+ if (parent == NULL || dest == NULL)
+ return NULL;
+
+ entry = proc_symlink(name, parent, dest);
+ if (entry == NULL)
+ CERROR("LprocFS: Could not create symbolic link from %s to %s",
+ name, dest);
+ return entry;
+}
+
static ssize_t lprocfs_fops_read(struct file *f, char __user *buf,
size_t size, loff_t *ppos)
{
}
}
+void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent)
+{
+ LASSERT(parent != NULL);
+ remove_proc_entry(name, parent);
+}
+
struct proc_dir_entry *lprocfs_register(const char *name,
struct proc_dir_entry *parent,
struct lprocfs_vars *list, void *data)
enum lprocfs_stats_flags flags)
{
struct lprocfs_stats *stats;
- struct lprocfs_percpu *percpu;
unsigned int percpusize;
- unsigned int i;
+ unsigned int i, j;
unsigned int num_cpu;
if (num == 0)
stats->ls_flags = 0;
}
- percpusize = offsetof(typeof(*percpu), lp_cntr[num]);
+ percpusize = offsetof(struct lprocfs_percpu, lp_cntr[num]);
if (num_cpu > 1)
percpusize = L1_CACHE_ALIGN(percpusize);
- stats->ls_percpu_size = num_cpu * percpusize;
- OBD_ALLOC(stats->ls_percpu[0], stats->ls_percpu_size);
+ for (i = 0; i < num_cpu; i++) {
+ OBD_ALLOC(stats->ls_percpu[i], percpusize);
+ if (stats->ls_percpu[i] == NULL) {
+ for (j = 0; j < i; j++) {
+ OBD_FREE(stats->ls_percpu[j], percpusize);
+ stats->ls_percpu[j] = NULL;
+ }
+ break;
+ }
+ }
if (stats->ls_percpu[0] == NULL) {
OBD_FREE(stats, offsetof(typeof(*stats),
ls_percpu[num_cpu]));
}
stats->ls_num = num;
- for (i = 1; i < num_cpu; i++)
- stats->ls_percpu[i] = (void *)(stats->ls_percpu[i - 1]) +
- percpusize;
-
return stats;
}
{
struct lprocfs_stats *stats = *statsh;
unsigned int num_cpu;
+ unsigned int percpusize;
+ unsigned int i;
if (stats == NULL || stats->ls_num == 0)
return;
else
num_cpu = num_possible_cpus();
- OBD_FREE(stats->ls_percpu[0], stats->ls_percpu_size);
+ percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
+ if (num_cpu > 1)
+ percpusize = L1_CACHE_ALIGN(percpusize);
+ for (i = 0; i < num_cpu; i++)
+ OBD_FREE(stats->ls_percpu[i], percpusize);
OBD_FREE(stats, offsetof(typeof(*stats), ls_percpu[num_cpu]));
}
atomic_inc(&percpu_cntr->lc_cntl.la_entry);
percpu_cntr->lc_count = 0;
percpu_cntr->lc_sum = 0;
- percpu_cntr->lc_min = ~(__u64)0;
+ percpu_cntr->lc_min = LC_MIN_INIT;
percpu_cntr->lc_max = 0;
percpu_cntr->lc_sumsquare = 0;
atomic_inc(&percpu_cntr->lc_cntl.la_exit);
{
struct lprocfs_stats *stats = p->private;
struct lprocfs_counter *cntr = v;
- struct lprocfs_counter t, ret = { .lc_min = ~(__u64)0 };
+ struct lprocfs_counter t, ret = { .lc_min = LC_MIN_INIT };
int i, idx, rc;
unsigned int num_cpu;
ret.lc_sumsquare += t.lc_sumsquare;
}
- rc = seq_printf(p, "%-25s "LPU64" samples [%s]", cntr->lc_name,
+ rc = seq_printf(p, "%-25s "LPD64" samples [%s]", cntr->lc_name,
ret.lc_count, cntr->lc_units);
if (rc < 0)
goto out;
if ((cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) && (ret.lc_count > 0)) {
- rc = seq_printf(p, " "LPU64" "LPU64" "LPU64,
+ rc = seq_printf(p, " "LPD64" "LPD64" "LPD64,
ret.lc_min, ret.lc_max, ret.lc_sum);
if (rc < 0)
goto out;
if (cntr->lc_config & LPROCFS_CNTR_STDDEV)
- rc = seq_printf(p, " "LPU64, ret.lc_sumsquare);
+ rc = seq_printf(p, " "LPD64, ret.lc_sumsquare);
if (rc < 0)
goto out;
}
c->lc_config = conf;
c->lc_count = 0;
c->lc_sum = 0;
- c->lc_min = ~(__u64)0;
+ c->lc_min = LC_MIN_INIT;
c->lc_max = 0;
c->lc_name = name;
c->lc_units = units;
GOTO(destroy_new, rc = 0);
}
/* not found - create */
- tmp->nid_proc = proc_mkdir(libcfs_nid2str(*nid),
- obd->obd_proc_exports_entry);
+ tmp->nid_proc = lprocfs_register(libcfs_nid2str(*nid),
+ obd->obd_proc_exports_entry, NULL, NULL);
if (!tmp->nid_proc) {
CERROR("Error making export directory for"
" nid %s\n", libcfs_nid2str(*nid));
goto out;
if (lprocfs_obd_snprintf(&page, size, &len, "time remaining: %lu\n",
- CURRENT_SECONDS >= obd->obd_recovery_end ? 0 :
- obd->obd_recovery_end - CURRENT_SECONDS) <= 0)
+ cfs_time_current_sec() >= obd->obd_recovery_end ? 0 :
+ obd->obd_recovery_end - cfs_time_current_sec()) <= 0)
goto out;
if(lprocfs_obd_snprintf(&page, size, &len, "connected_clients: %d/%d\n",
EXPORT_SYMBOL(lprocfs_register);
EXPORT_SYMBOL(lprocfs_srch);
EXPORT_SYMBOL(lprocfs_remove);
+EXPORT_SYMBOL(lprocfs_remove_proc_entry);
EXPORT_SYMBOL(lprocfs_add_vars);
EXPORT_SYMBOL(lprocfs_obd_setup);
EXPORT_SYMBOL(lprocfs_obd_cleanup);
EXPORT_SYMBOL(lprocfs_add_simple);
+EXPORT_SYMBOL(lprocfs_add_symlink);
EXPORT_SYMBOL(lprocfs_free_per_client_stats);
EXPORT_SYMBOL(lprocfs_alloc_stats);
EXPORT_SYMBOL(lprocfs_free_stats);