diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 8aeed92cac36bd9eaf518bc1480d95f719f0b620..45ef4a7971d9499444f97ea8d877282d617965d4 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -364,6 +364,8 @@ extern int lprocfs_exp_cleanup(struct obd_export *exp); 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); @@ -384,6 +386,8 @@ extern cfs_proc_dir_entry_t *lprocfs_register(const char *name, 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); @@ -596,6 +600,9 @@ static inline int lprocfs_add_simple(struct proc_dir_entry *root, 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 @@ -614,6 +621,8 @@ static inline int lprocfs_add_vars(cfs_proc_dir_entry_t *root, 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, diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 56b8d1a0b54117b7ce94f1cd5fa891b1f6b5e3fb..50a476e5d41ae50eeca6a177e2415c6adac64113 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -613,8 +613,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, 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)); @@ -643,36 +642,31 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, 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, diff --git a/lustre/llite/super25.c b/lustre/llite/super25.c index 75b538ca7a29c2eee3be3fa408b400777fde9218..af2c97a5a6ae91f16ff3fe765bc63262dd238004 100644 --- a/lustre/llite/super25.c +++ b/lustre/llite/super25.c @@ -132,7 +132,7 @@ static int __init init_lustre_lite(void) } 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); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index e482f4a6c2158a5015eea17996f9fe7d09f5cfbc..fed558fe4b262b5339aa22428b032a0d2ea3e4fb 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -1009,14 +1009,10 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) 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, diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index d594d203f007402fb0254e3ed852bb509999f74e..a7ee2ef7339d806e1cd9cb3307e1cf77e8304375 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -191,8 +191,8 @@ static int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, 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.", @@ -760,14 +760,12 @@ static int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) 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 diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 228890800fbc56b71c7e404f0762a562999f4767..bc1ac9f0fca356223b6368a29ce30382c85ff7c3 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -2012,8 +2012,15 @@ static int mds_setup(struct obd_device *obd, struct lustre_cfg* lcfg) 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); @@ -2280,7 +2287,7 @@ static int mds_cleanup(struct obd_device *obd) 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); diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index f5586c26a2ce14cca7b8e9cd8b40eaf36001fc5d..4e3eae3f6940ca9f52e81869595080cc8eddfba2 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -84,8 +84,23 @@ int lproc_mgs_setup(struct obd_device *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; } @@ -194,7 +209,8 @@ int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb) 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; } diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c index 3e08cd221623854b13291bacb1c83bb4843a4d15..2215132813f36fa356de3b178cfd493bb895a3a0 100644 --- a/lustre/obdclass/linux/linux-module.c +++ b/lustre/obdclass/linux/linux-module.c @@ -405,24 +405,16 @@ struct file_operations obd_device_list_fops = { 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 diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 9afb4dd1c2275f41d7a90ab16fda5ab548f24625..adfd37428abb382ae3d819f0756e12541eb448cc 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -116,6 +116,21 @@ int lprocfs_add_simple(struct proc_dir_entry *root, char *name, 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) { @@ -319,6 +334,12 @@ void lprocfs_remove(struct proc_dir_entry **rooth) } } +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) @@ -1334,8 +1355,8 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) 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)); @@ -1745,10 +1766,12 @@ EXPORT_SYMBOL(lprocfs_obd_wr_recovery_maxtime); 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); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index bcec97d1cbc218384f03973f23a817e47c908733..59e533e3801e4345527953e668e7e0750f795776 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -187,7 +187,6 @@ static int filter_export_stats_init(struct obd_device *obd, void *client_nid) { struct filter_export_data *fed = &exp->exp_filter_data; - struct proc_dir_entry *brw_entry; int rc, newnid = 0; ENTRY; @@ -210,14 +209,11 @@ static int filter_export_stats_init(struct obd_device *obd, 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) @@ -2112,8 +2108,15 @@ static int filter_setup(struct obd_device *obd, struct lustre_cfg* lcfg) "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", @@ -2126,7 +2129,7 @@ static int filter_setup(struct obd_device *obd, struct lustre_cfg* lcfg) 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); @@ -2389,7 +2392,7 @@ static int filter_cleanup(struct obd_device *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); diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index c9b534765edab28bf1b872d504f8b64558f629d5..29c4cfc304563a9e848110a65291831abcdf859a 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -441,7 +441,8 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, .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, @@ -452,12 +453,10 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, 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)