struct obd_ops *typ_dt_ops;
struct md_ops *typ_md_ops;
struct proc_dir_entry *typ_procroot;
- struct proc_dir_entry *typ_procsym;
struct dentry *typ_debugfs_entry;
#ifdef HAVE_SERVER_SUPPORT
bool typ_sym_filter;
/* genops.c */
struct obd_export *class_conn2export(struct lustre_handle *);
#ifdef HAVE_SERVER_SUPPORT
-struct obd_type *class_setup_tunables(const char *name);
+struct obd_type *class_add_symlinks(const char *name, bool enable_proc);
#endif
int class_register_type(struct obd_ops *, struct md_ops *, bool enable_proc,
struct lprocfs_vars *module_vars,
static int __init lod_init(void)
{
- struct dentry *symlink;
- struct obd_type *type;
- struct qstr dname;
int rc;
rc = lu_kmem_init(lod_caches);
return rc;
}
- sym = class_setup_tunables(LUSTRE_LOV_NAME);
+ /* create "lov" entry for compatibility purposes */
+ sym = class_add_symlinks(LUSTRE_LOV_NAME, true);
if (IS_ERR(sym)) {
rc = PTR_ERR(sym);
/* does real "lov" already exist ? */
if (rc == -EEXIST)
- GOTO(try_proc, rc = 0);
- GOTO(no_lov, rc);
- }
-
- /* create "lov" entry for compatibility purposes */
- dname.name = "lov";
- dname.len = strlen(dname.name);
- dname.hash = ll_full_name_hash(debugfs_lustre_root, dname.name,
- dname.len);
- symlink = d_lookup(debugfs_lustre_root, &dname);
- if (!symlink) {
- symlink = debugfs_create_dir(dname.name, debugfs_lustre_root);
- if (IS_ERR_OR_NULL(symlink)) {
- rc = symlink ? PTR_ERR(symlink) : -ENOMEM;
- GOTO(no_lov, rc);
- }
- sym->typ_debugfs_entry = symlink;
- } else {
- dput(symlink);
+ rc = 0;
}
-try_proc:
- type = class_search_type(LUSTRE_LOV_NAME);
- if (type && type->typ_procroot)
- GOTO(no_lov, rc);
-
- type = class_search_type(LUSTRE_LOD_NAME);
- type->typ_procsym = lprocfs_register("lov", proc_lustre_root,
- NULL, NULL);
- if (IS_ERR(type->typ_procsym)) {
- CERROR("lod: can't create compat entry \"lov\": %d\n",
- (int)PTR_ERR(type->typ_procsym));
- type->typ_procsym = NULL;
- }
-no_lov:
return rc;
}
*/
int lod_procfs_init(struct lod_device *lod)
{
+ struct lprocfs_vars ldebugfs_obd_vars[] = { { NULL } };
struct obd_device *obd = lod2obd(lod);
- struct proc_dir_entry *lov_proc_dir;
struct obd_type *type;
struct kobject *lov;
int rc;
lod->lod_dt_dev.dd_ktype.default_attrs = lod_attrs;
rc = dt_tunables_init(&lod->lod_dt_dev, obd->obd_type, obd->obd_name,
- NULL);
+ ldebugfs_obd_vars);
if (rc) {
CERROR("%s: failed to setup DT tunables: %d\n",
obd->obd_name, rc);
}
lov = kset_find_obj(lustre_kset, "lov");
- if (lov) {
- rc = sysfs_create_link(lov, &lod->lod_dt_dev.dd_kobj,
- obd->obd_name);
- kobject_put(lov);
+ if (!lov) {
+ CERROR("%s: lov subsystem not found\n", obd->obd_name);
+ GOTO(out, rc = -ENODEV);
}
+ rc = sysfs_create_link(lov, &lod->lod_dt_dev.dd_kobj,
+ obd->obd_name);
+ if (rc)
+ CERROR("%s: failed to create LOV sysfs symlink\n",
+ obd->obd_name);
+ kobject_put(lov);
+
lod->lod_debugfs = ldebugfs_add_symlink(obd->obd_name, "lov",
"../lod/%s", obd->obd_name);
if (!lod->lod_debugfs)
CERROR("%s: failed to create LOV debugfs symlink\n",
obd->obd_name);
- /* If the real LOV is present which is the case for setups
- * with both server and clients on the same node then use
- * the LOV's proc root */
- type = class_search_type(LUSTRE_LOV_NAME);
- if (type != NULL && type->typ_procroot != NULL)
- lov_proc_dir = type->typ_procroot;
- else
- lov_proc_dir = obd->obd_type->typ_procsym;
-
- if (lov_proc_dir == NULL)
+ type = container_of(lov, struct obd_type, typ_kobj);
+ if (!type->typ_procroot)
RETURN(0);
/* for compatibility we link old procfs's LOV entries to lod ones */
- lod->lod_symlink = lprocfs_add_symlink(obd->obd_name, lov_proc_dir,
+ lod->lod_symlink = lprocfs_add_symlink(obd->obd_name,
+ type->typ_procroot,
"../lod/%s", obd->obd_name);
if (lod->lod_symlink == NULL)
CERROR("cannot create LOV symlink for /proc/fs/lustre/lod/%s\n",
static int __init lov_init(void)
{
- bool enable_proc = true;
- struct obd_type *type;
int rc;
ENTRY;
return -ENOMEM;
}
- type = class_search_type(LUSTRE_LOD_NAME);
- if (type != NULL && type->typ_procsym != NULL)
- enable_proc = false;
-
- rc = class_register_type(&lov_obd_ops, NULL, enable_proc, NULL,
+ rc = class_register_type(&lov_obd_ops, NULL, true, NULL,
LUSTRE_LOV_NAME, &lov_device_type);
-
if (rc) {
kmem_cache_destroy(lov_oinfo_slab);
lu_kmem_fini(lov_caches);
int lov_tunables_init(struct obd_device *obd)
{
struct lov_obd *lov = &obd->u.lov;
-#if defined(CONFIG_PROC_FS) && defined(HAVE_SERVER_SUPPORT)
- struct obd_type *type;
-#endif
int rc;
obd->obd_vars = lprocfs_lov_obd_vars;
-#if defined(CONFIG_PROC_FS) && defined(HAVE_SERVER_SUPPORT)
- /* If this is true then both client (lov) and server
- * (lod) are on the same node. The lod layer if loaded
- * first will register the lov proc directory. In that
- * case obd->obd_type->typ_procroot will be not set.
- * Instead we use type->typ_procsym as the parent.
- */
- type = class_search_type(LUSTRE_LOD_NAME);
- if (type && type->typ_procsym) {
- obd->obd_proc_entry = lprocfs_register(obd->obd_name,
- type->typ_procsym,
- obd->obd_vars, obd);
- if (IS_ERR(obd->obd_proc_entry)) {
- rc = PTR_ERR(obd->obd_proc_entry);
- CERROR("error %d setting up lprocfs for %s\n", rc,
- obd->obd_name);
- obd->obd_proc_entry = NULL;
- }
- }
-#endif
obd->obd_ktype.default_attrs = lov_attrs;
rc = lprocfs_obd_setup(obd, false);
if (rc)
};
#ifdef HAVE_SERVER_SUPPORT
-struct obd_type *class_setup_tunables(const char *name)
+struct obd_type *class_add_symlinks(const char *name, bool enable_proc)
{
+ struct dentry *symlink;
struct obd_type *type;
struct kobject *kobj;
int rc;
return ERR_PTR(-ENOMEM);
type->typ_kobj.kset = lustre_kset;
- kobject_init(&type->typ_kobj, &class_ktype);
- rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
- if (rc) {
+ rc = kobject_init_and_add(&type->typ_kobj, &class_ktype,
+ &lustre_kset->kobj, "%s", name);
+ if (rc)
+ return ERR_PTR(rc);
+
+ symlink = debugfs_create_dir(name, debugfs_lustre_root);
+ if (IS_ERR_OR_NULL(symlink)) {
+ rc = symlink ? PTR_ERR(symlink) : -ENOMEM;
kobject_put(&type->typ_kobj);
return ERR_PTR(rc);
}
+ type->typ_debugfs_entry = symlink;
+ type->typ_sym_filter = true;
+
+ if (enable_proc) {
+ type->typ_procroot = lprocfs_register(name, proc_lustre_root,
+ NULL, NULL);
+ if (IS_ERR(type->typ_procroot)) {
+ CERROR("%s: can't create compat proc entry: %d\n",
+ name, (int)PTR_ERR(type->typ_procroot));
+ type->typ_procroot = NULL;
+ }
+ }
+
return type;
}
-EXPORT_SYMBOL(class_setup_tunables);
+EXPORT_SYMBOL(class_add_symlinks);
#endif /* HAVE_SERVER_SUPPORT */
#define CLASS_MAX_NAME 1024
RETURN(-ENOMEM);
type->typ_kobj.kset = lustre_kset;
- rc = kobject_init_and_add(&type->typ_kobj, &class_ktype,
- &lustre_kset->kobj, "%s", name);
- if (rc)
- GOTO(failed, rc);
-
- type->typ_debugfs_entry = ldebugfs_register(name, debugfs_lustre_root,
- vars, type);
- if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) {
- rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
- : -ENOMEM;
- type->typ_debugfs_entry = NULL;
- GOTO(failed, rc);
- }
+ kobject_init(&type->typ_kobj, &class_ktype);
#ifdef HAVE_SERVER_SUPPORT
dir_exist:
#endif /* HAVE_SERVER_SUPPORT */
if (type->typ_dt_ops == NULL ||
type->typ_md_ops == NULL ||
type->typ_name == NULL)
- GOTO (failed, rc);
+ GOTO (failed, rc = -ENOMEM);
*(type->typ_dt_ops) = *dt_ops;
/* md_ops is optional */
strcpy(type->typ_name, name);
spin_lock_init(&type->obd_type_lock);
+#ifdef HAVE_SERVER_SUPPORT
+ if (type->typ_sym_filter)
+ goto setup_ldt;
+#endif
#ifdef CONFIG_PROC_FS
if (enable_proc && !type->typ_procroot) {
type->typ_procroot = lprocfs_register(type->typ_name,
}
}
#endif
+ type->typ_debugfs_entry = ldebugfs_register(name, debugfs_lustre_root,
+ vars, type);
+ if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) {
+ rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
+ : -ENOMEM;
+ type->typ_debugfs_entry = NULL;
+ GOTO(failed, rc);
+ }
+
+ rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
+ if (rc)
+ GOTO(failed, rc);
+#ifdef HAVE_SERVER_SUPPORT
+setup_ldt:
+#endif
if (ldt) {
type->typ_lu = ldt;
rc = lu_device_type_init(ldt);
#ifdef CONFIG_PROC_FS
if (type->typ_procroot != NULL)
remove_proc_subtree(type->typ_name, proc_lustre_root);
- if (type->typ_procsym != NULL)
- lprocfs_remove(&type->typ_procsym);
#endif
#ifdef HAVE_SERVER_SUPPORT
if (type->typ_sym_filter)
int osc_tunables_init(struct obd_device *obd)
{
-#if defined(CONFIG_PROC_FS) && defined(HAVE_SERVER_SUPPORT)
- struct obd_type *type;
-#endif
int rc;
obd->obd_vars = lprocfs_osc_obd_vars;
-#if defined(CONFIG_PROC_FS) && defined(HAVE_SERVER_SUPPORT)
- /* If this is true then both client (osc) and server (osp) are on the
- * same node. The osp layer if loaded first will register the osc proc
- * directory. In that case this obd_device will be attached its proc
- * tree to type->typ_procsym instead of obd->obd_type->typ_procroot.
- */
- type = class_search_type(LUSTRE_OSP_NAME);
- if (type && type->typ_procsym) {
- obd->obd_proc_entry = lprocfs_register(obd->obd_name,
- type->typ_procsym,
- obd->obd_vars, obd);
- if (IS_ERR(obd->obd_proc_entry)) {
- rc = PTR_ERR(obd->obd_proc_entry);
- CERROR("error %d setting up lprocfs for %s\n", rc,
- obd->obd_name);
- obd->obd_proc_entry = NULL;
- }
- }
-#endif
obd->obd_ktype.default_attrs = osc_attrs;
rc = lprocfs_obd_setup(obd, false);
if (rc)
static int __init osc_init(void)
{
- bool enable_proc = true;
- struct obd_type *type;
unsigned int reqpool_size;
unsigned int reqsize;
int rc;
if (rc)
RETURN(rc);
- type = class_search_type(LUSTRE_OSP_NAME);
- if (type != NULL && type->typ_procsym != NULL)
- enable_proc = false;
-
- rc = class_register_type(&osc_obd_ops, NULL, enable_proc, NULL,
+ rc = class_register_type(&osc_obd_ops, NULL, true, NULL,
LUSTRE_OSC_NAME, &osc_device_type);
if (rc)
GOTO(out_kmem, rc);
*/
static int __init osp_init(void)
{
- struct dentry *symlink;
- struct obd_type *type;
- struct qstr dname;
int rc;
rc = lu_kmem_init(osp_caches);
if (rc)
return rc;
- rc = class_register_type(&osp_obd_device_ops, NULL, true, NULL,
+ rc = class_register_type(&osp_obd_device_ops, NULL, false, NULL,
LUSTRE_OSP_NAME, &osp_device_type);
if (rc != 0) {
lu_kmem_fini(osp_caches);
return rc;
}
- sym = class_setup_tunables(LUSTRE_OSC_NAME);
+ /* create "osc" entry for compatibility purposes */
+ sym = class_add_symlinks(LUSTRE_OSC_NAME, false);
if (IS_ERR(sym)) {
rc = PTR_ERR(sym);
/* does real "osc" already exist ? */
if (rc == -EEXIST)
- GOTO(try_proc, rc = 0);
- GOTO(no_osc, rc);
- }
-
- /* create "osc" entry for compatibility purposes */
- dname.name = "osc";
- dname.len = strlen(dname.name);
- dname.hash = ll_full_name_hash(debugfs_lustre_root, dname.name,
- dname.len);
- symlink = d_lookup(debugfs_lustre_root, &dname);
- if (!symlink) {
- symlink = debugfs_create_dir(dname.name, debugfs_lustre_root);
- if (IS_ERR_OR_NULL(symlink)) {
- rc = symlink ? PTR_ERR(symlink) : -ENOMEM;
- GOTO(no_osc, rc);
- }
- sym->typ_debugfs_entry = symlink;
- } else {
- dput(symlink);
+ rc = 0;
}
-try_proc:
- type = class_search_type(LUSTRE_OSC_NAME);
- if (type != NULL && type->typ_procroot != NULL)
- GOTO(no_osc, rc);
-
- type = class_search_type(LUSTRE_OSP_NAME);
- type->typ_procsym = lprocfs_register("osc", proc_lustre_root,
- NULL, NULL);
- if (IS_ERR(type->typ_procsym)) {
- CERROR("osp: can't create compat entry \"osc\": %d\n",
- (int) PTR_ERR(type->typ_procsym));
- type->typ_procsym = NULL;
- }
-no_osc:
return rc;
}