extern int lprocfs_add_simple(struct proc_dir_entry *root,
char *name, read_proc_t *read_proc,
write_proc_t *write_proc, void *data);
+extern struct proc_dir_entry *lprocfs_add_symlink(const char *name,
+ struct proc_dir_entry *parent, const char *dest);
extern void lprocfs_free_per_client_stats(struct obd_device *obd);
extern int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
unsigned long count, void *data);
void *data);
extern void lprocfs_remove(cfs_proc_dir_entry_t **root);
+extern void lprocfs_remove_proc_entry(const char *name,
+ struct proc_dir_entry *parent);
extern cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *root,
const char *name);
write_proc_t *write_proc,
void *data)
{return 0; }
+static inline struct proc_dir_entry *lprocfs_add_symlink(const char *name,
+ struct proc_dir_entry *parent, const char *dest)
+{return NULL; }
static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
{}
static inline
struct lprocfs_vars *var,
void *data) { return 0; }
static inline void lprocfs_remove(cfs_proc_dir_entry_t **root) {};
+static inline void lprocfs_remove_proc_entry(const char *name,
+ struct proc_dir_entry *parent) {};
static inline cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *head,
const char *name) {return 0;}
static inline int lprocfs_obd_setup(struct obd_device *dev,
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct obd_device *obd;
char name[MAX_STRING_SIZE + 1], *ptr;
- int err, id, len;
- struct proc_dir_entry *entry;
+ int err, id, len, rc;
ENTRY;
memset(lvars, 0, sizeof(lvars));
RETURN(err);
}
- entry = create_proc_entry("dump_page_cache", 0444, sbi->ll_proc_root);
- if (entry == NULL)
- GOTO(out, err = -ENOMEM);
- entry->proc_fops = &llite_dump_pgcache_fops;
- entry->data = sbi;
- entry = create_proc_entry("read_ahead_stats", 0644, sbi->ll_proc_root);
- if (entry == NULL)
- GOTO(out, err = -ENOMEM);
- entry->proc_fops = &ll_ra_stats_fops;
- entry->data = sbi;
-
- entry = create_proc_entry("extents_stats", 0644, sbi->ll_proc_root);
- if (entry == NULL)
- GOTO(out, err = -ENOMEM);
- entry->proc_fops = &ll_rw_extents_stats_fops;
- entry->data = sbi;
-
- entry = create_proc_entry("extents_stats_per_process", 0644,
- sbi->ll_proc_root);
- if (entry == NULL)
- GOTO(out, err = -ENOMEM);
- entry->proc_fops = &ll_rw_extents_stats_pp_fops;
- entry->data = sbi;
-
- entry = create_proc_entry("offset_stats", 0644, sbi->ll_proc_root);
- if (entry == NULL)
- GOTO(out, err = -ENOMEM);
- entry->proc_fops = &ll_rw_offset_stats_fops;
- entry->data = sbi;
+ rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444,
+ &llite_dump_pgcache_fops, sbi);
+ if (rc)
+ CWARN("Error adding the dump_page_cache file\n");
+
+ rc = lprocfs_seq_create(sbi->ll_proc_root, "read_ahead_stats", 0644,
+ &ll_ra_stats_fops, sbi);
+ if (rc)
+ CWARN("Error adding the read_ahead_stats file\n");
+
+ rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats", 0644,
+ &ll_rw_extents_stats_fops, sbi);
+ if (rc)
+ CWARN("Error adding the extent_stats file\n");
+
+ rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats_per_process",
+ 0644, &ll_rw_extents_stats_pp_fops, sbi);
+ if (rc)
+ CWARN("Error adding the extents_stats_per_process file\n");
+
+ rc = lprocfs_seq_create(sbi->ll_proc_root, "offset_stats", 0644,
+ &ll_rw_offset_stats_fops, sbi);
+ if (rc)
+ CWARN("Error adding the offset_stats file\n");
/* File operations stats */
sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES,
}
proc_lustre_fs_root = proc_lustre_root ?
- proc_mkdir("llite", proc_lustre_root) : NULL;
+ lprocfs_register("llite", proc_lustre_root, NULL, NULL) : NULL;
ll_register_cache(&ll_cache_definition);
lprocfs_obd_setup(obd, lvars.obd_vars);
#ifdef LPROCFS
{
- struct proc_dir_entry *entry;
-
- entry = create_proc_entry("target_obd_status", 0444,
- obd->obd_proc_entry);
- if (entry != NULL) {
- entry->proc_fops = &lmv_proc_target_fops;
- entry->data = obd;
- }
+ rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd_status",
+ 0444, &lmv_proc_target_fops, obd);
+ if (rc)
+ CWARN("Error adding the target_obd_status file\n");
}
#endif
rc = fld_client_init(&lmv->lmv_fld, obd->obd_name,
snprintf(name, MAX_STRING_SIZE, "../../../%s/%s",
osc_obd->obd_type->typ_name,
osc_obd->obd_name);
- osc_symlink = proc_symlink(osc_obd->obd_name, lov_proc_dir,
- name);
+ osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, lov_proc_dir,
+ name);
if (osc_symlink == NULL) {
CERROR("could not register LOV target "
"/proc/fs/lustre/%s/%s/target_obds/%s.",
lprocfs_obd_setup(obd, lvars.obd_vars);
#ifdef LPROCFS
{
- cfs_proc_dir_entry_t *entry;
+ int rc;
- entry = create_proc_entry("target_obd", 0444,
- obd->obd_proc_entry);
- if (entry != NULL) {
- entry->proc_fops = &lov_proc_target_fops;
- entry->data = obd;
- }
+ rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
+ 0444, &lov_proc_target_fops, obd);
+ if (rc)
+ CWARN("Error adding the target_obd file\n");
}
#endif
lprocfs_alloc_obd_stats(obd, LPROC_MDS_LAST) == 0) {
/* Init private stats here */
mds_stats_counter_init(obd->obd_stats);
- obd->obd_proc_exports_entry = proc_mkdir("exports",
- obd->obd_proc_entry);
+ obd->obd_proc_exports_entry = lprocfs_register("exports",
+ obd->obd_proc_entry,
+ NULL, NULL);
+ if (IS_ERR(obd->obd_proc_exports_entry)) {
+ rc = PTR_ERR(obd->obd_proc_exports_entry);
+ CERROR("error %d setting up lprocfs for %s\n",
+ rc, "exports");
+ obd->obd_proc_exports_entry = NULL;
+ }
}
rc = mds_fs_setup(obd, mnt);
we just need to drop our ref */
class_export_put(mds->mds_osc_exp);
- remove_proc_entry("clear", obd->obd_proc_exports_entry);
+ lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
lprocfs_free_per_client_stats(obd);
lprocfs_free_obd_stats(obd);
lprocfs_obd_cleanup(obd);
rc = lprocfs_obd_seq_create(obd, "filesystems", 0444,
&mgs_fs_fops, obd);
- mgs->mgs_proc_live = proc_mkdir("live", obd->obd_proc_entry);
- obd->obd_proc_exports_entry = proc_mkdir("exports", obd->obd_proc_entry);
+
+ mgs->mgs_proc_live = lprocfs_register("live", obd->obd_proc_entry,
+ NULL, NULL);
+ if (IS_ERR(mgs->mgs_proc_live)) {
+ rc = PTR_ERR(mgs->mgs_proc_live);
+ CERROR("error %d setting up lprocfs for %s\n", rc, "live");
+ mgs->mgs_proc_live = NULL;
+ }
+
+ obd->obd_proc_exports_entry = lprocfs_register("exports",
+ obd->obd_proc_entry,
+ NULL, NULL);
+ if (IS_ERR(obd->obd_proc_exports_entry)) {
+ rc = PTR_ERR(obd->obd_proc_exports_entry);
+ CERROR("error %d setting up lprocfs for %s\n", rc, "exports");
+ obd->obd_proc_exports_entry = NULL;
+ }
return rc;
}
if (!mgs->mgs_proc_live)
return 0;
- remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live);
+
+ lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live);
return 0;
}
int class_procfs_init(void)
{
#ifdef __KERNEL__
- struct proc_dir_entry *entry;
+ int rc;
ENTRY;
obd_sysctl_init();
- proc_lustre_root = proc_mkdir("lustre", proc_root_fs);
- if (!proc_lustre_root) {
- printk(KERN_ERR
- "LustreError: error registering /proc/fs/lustre\n");
- RETURN(-ENOMEM);
- }
- proc_version = lprocfs_add_vars(proc_lustre_root, lprocfs_base, NULL);
- entry = create_proc_entry("devices", 0444, proc_lustre_root);
- if (entry == NULL) {
- CERROR("error registering /proc/fs/lustre/devices\n");
- lprocfs_remove(&proc_lustre_root);
- RETURN(-ENOMEM);
- }
- entry->proc_fops = &obd_device_list_fops;
+ proc_lustre_root = lprocfs_register("lustre", proc_root_fs,
+ lprocfs_base, NULL);
+ rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444,
+ &obd_device_list_fops, NULL);
+ if (rc)
+ CERROR("error adding /proc/fs/lustre/devices file\n");
#else
ENTRY;
#endif
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)
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));
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);
void *client_nid)
{
struct filter_export_data *fed = &exp->exp_filter_data;
- struct proc_dir_entry *brw_entry;
int rc, newnid = 0;
ENTRY;
RETURN(-ENOMEM);
init_brw_stats(tmp->nid_brw_stats);
-
- brw_entry = create_proc_entry("brw_stats", 0644,
- exp->exp_nid_stats->nid_proc);
- if (brw_entry == NULL)
- RETURN(-ENOMEM);
-
- brw_entry->proc_fops = &filter_per_nid_stats_fops;
- brw_entry->data = exp->exp_nid_stats;
+ rc = lprocfs_seq_create(exp->exp_nid_stats->nid_proc, "brw_stats",
+ 0644, &filter_per_nid_stats_fops,
+ exp->exp_nid_stats);
+ if (rc)
+ CWARN("Error adding the brw_stats file\n");
rc = lprocfs_init_rw_stats(obd, &exp->exp_nid_stats->nid_stats);
if (rc)
"write_bytes", "bytes");
lproc_filter_attach_seqstat(obd);
- obd->obd_proc_exports_entry = proc_mkdir("exports",
- obd->obd_proc_entry);
+ obd->obd_proc_exports_entry = lprocfs_register("exports",
+ obd->obd_proc_entry,
+ NULL, NULL);
+ if (IS_ERR(obd->obd_proc_exports_entry)) {
+ rc = PTR_ERR(obd->obd_proc_exports_entry);
+ CERROR("error %d setting up lprocfs for %s\n",
+ rc, "exports");
+ obd->obd_proc_exports_entry = NULL;
+ }
}
if (obd->obd_proc_exports_entry)
lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
OBD_PAGE_FREE(page);
if (rc) {
- remove_proc_entry("clear", obd->obd_proc_exports_entry);
+ lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
lprocfs_free_per_client_stats(obd);
lprocfs_free_obd_stats(obd);
lprocfs_obd_cleanup(obd);
}
}
- remove_proc_entry("clear", obd->obd_proc_exports_entry);
+ lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
lprocfs_free_per_client_stats(obd);
lprocfs_free_obd_stats(obd);
lprocfs_obd_cleanup(obd);
.llseek = seq_lseek,
.release = lprocfs_seq_release,
};
- struct proc_dir_entry *req_history;
+
+ int rc;
ptlrpc_lprocfs_register(entry, svc->srv_name,
"stats", &svc->srv_procroot,
lprocfs_add_vars(svc->srv_procroot, lproc_vars, NULL);
- req_history = create_proc_entry("req_history", 0400,
- svc->srv_procroot);
- if (req_history != NULL) {
- req_history->data = svc;
- req_history->proc_fops = &req_history_fops;
- }
+ rc = lprocfs_seq_create(svc->srv_procroot, "req_history",
+ 0400, &req_history_fops, svc);
+ if (rc)
+ CWARN("Error adding the req_history file\n");
}
void ptlrpc_lprocfs_register_obd(struct obd_device *obddev)