diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/obdclass/genops.c')
-rw-r--r-- | drivers/staging/lustre/lustre/obdclass/genops.c | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 66b56784f..978c3c5c4 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -156,7 +156,7 @@ EXPORT_SYMBOL(class_put_type); #define CLASS_MAX_NAME 1024 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, - struct lprocfs_vars *vars, const char *name, + const char *name, struct lu_device_type *ldt) { struct obd_type *type; @@ -171,13 +171,13 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, } rc = -ENOMEM; - OBD_ALLOC(type, sizeof(*type)); + type = kzalloc(sizeof(*type), GFP_NOFS); if (type == NULL) return rc; - OBD_ALLOC_PTR(type->typ_dt_ops); - OBD_ALLOC_PTR(type->typ_md_ops); - OBD_ALLOC(type->typ_name, strlen(name) + 1); + type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); + type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); + type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS); if (type->typ_dt_ops == NULL || type->typ_md_ops == NULL || @@ -191,11 +191,19 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, strcpy(type->typ_name, name); spin_lock_init(&type->obd_type_lock); - type->typ_procroot = lprocfs_register(type->typ_name, proc_lustre_root, - vars, type); - if (IS_ERR(type->typ_procroot)) { - rc = PTR_ERR(type->typ_procroot); - type->typ_procroot = NULL; + type->typ_debugfs_entry = ldebugfs_register(type->typ_name, + debugfs_lustre_root, + NULL, 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; + } + + type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj); + if (!type->typ_kobj) { + rc = -ENOMEM; goto failed; } @@ -213,13 +221,12 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, return 0; failed: - if (type->typ_name != NULL) - OBD_FREE(type->typ_name, strlen(name) + 1); - if (type->typ_md_ops != NULL) - OBD_FREE_PTR(type->typ_md_ops); - if (type->typ_dt_ops != NULL) - OBD_FREE_PTR(type->typ_dt_ops); - OBD_FREE(type, sizeof(*type)); + if (type->typ_kobj) + kobject_put(type->typ_kobj); + kfree(type->typ_name); + kfree(type->typ_md_ops); + kfree(type->typ_dt_ops); + kfree(type); return rc; } EXPORT_SYMBOL(class_register_type); @@ -237,14 +244,16 @@ int class_unregister_type(const char *name) CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt); /* This is a bad situation, let's make the best of it */ /* Remove ops, but leave the name for debugging */ - OBD_FREE_PTR(type->typ_dt_ops); - OBD_FREE_PTR(type->typ_md_ops); + kfree(type->typ_dt_ops); + kfree(type->typ_md_ops); return -EBUSY; } - if (type->typ_procroot) { - lprocfs_remove(&type->typ_procroot); - } + if (type->typ_kobj) + kobject_put(type->typ_kobj); + + if (!IS_ERR_OR_NULL(type->typ_debugfs_entry)) + ldebugfs_remove(&type->typ_debugfs_entry); if (type->typ_lu) lu_device_type_fini(type->typ_lu); @@ -252,12 +261,10 @@ int class_unregister_type(const char *name) spin_lock(&obd_types_lock); list_del(&type->typ_chain); spin_unlock(&obd_types_lock); - OBD_FREE(type->typ_name, strlen(name) + 1); - if (type->typ_dt_ops != NULL) - OBD_FREE_PTR(type->typ_dt_ops); - if (type->typ_md_ops != NULL) - OBD_FREE_PTR(type->typ_md_ops); - OBD_FREE(type, sizeof(*type)); + kfree(type->typ_name); + kfree(type->typ_dt_ops); + kfree(type->typ_md_ops); + kfree(type); return 0; } /* class_unregister_type */ EXPORT_SYMBOL(class_unregister_type); @@ -819,7 +826,7 @@ struct obd_export *class_new_export(struct obd_device *obd, struct cfs_hash *hash = NULL; int rc = 0; - OBD_ALLOC_PTR(export); + export = kzalloc(sizeof(*export), GFP_NOFS); if (!export) return ERR_PTR(-ENOMEM); @@ -904,7 +911,7 @@ exit_err: class_handle_unhash(&export->exp_handle); LASSERT(hlist_unhashed(&export->exp_uuid_hash)); obd_destroy_export(export); - OBD_FREE_PTR(export); + kfree(export); return ERR_PTR(rc); } EXPORT_SYMBOL(class_new_export); @@ -945,7 +952,7 @@ static void class_import_destroy(struct obd_import *imp) struct obd_import_conn, oic_item); list_del_init(&imp_conn->oic_item); ptlrpc_put_connection_superhack(imp_conn->oic_conn); - OBD_FREE(imp_conn, sizeof(*imp_conn)); + kfree(imp_conn); } LASSERT(imp->imp_sec == NULL); @@ -1008,7 +1015,7 @@ struct obd_import *class_new_import(struct obd_device *obd) { struct obd_import *imp; - OBD_ALLOC(imp, sizeof(*imp)); + imp = kzalloc(sizeof(*imp), GFP_NOFS); if (imp == NULL) return NULL; @@ -1811,7 +1818,7 @@ void *kuc_alloc(int payload_len, int transport, int type) struct kuc_hdr *lh; int len = kuc_len(payload_len); - OBD_ALLOC(lh, len); + lh = kzalloc(len, GFP_NOFS); if (lh == NULL) return ERR_PTR(-ENOMEM); @@ -1828,6 +1835,6 @@ EXPORT_SYMBOL(kuc_alloc); inline void kuc_free(void *p, int payload_len) { struct kuc_hdr *lh = kuc_ptr(p); - OBD_FREE(lh, kuc_len(payload_len)); + kfree(lh); } EXPORT_SYMBOL(kuc_free); |