diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/obdclass/genops.c')
-rw-r--r-- | drivers/staging/lustre/lustre/obdclass/genops.c | 109 |
1 files changed, 54 insertions, 55 deletions
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 228c44c37c4a..cf97b8f06764 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -42,6 +42,7 @@ #define DEBUG_SUBSYSTEM S_CLASS #include "../include/obd_class.h" #include "../include/lprocfs_status.h" +#include "../include/lustre_kernelcomm.h" spinlock_t obd_types_lock; @@ -68,18 +69,17 @@ static struct obd_device *obd_device_alloc(void) { struct obd_device *obd; - obd = kmem_cache_alloc(obd_device_cachep, GFP_NOFS | __GFP_ZERO); - if (obd != NULL) + obd = kmem_cache_zalloc(obd_device_cachep, GFP_NOFS); + if (obd) obd->obd_magic = OBD_DEVICE_MAGIC; return obd; } static void obd_device_free(struct obd_device *obd) { - LASSERT(obd != NULL); LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC, "obd %p obd_magic %08x != %08x\n", obd, obd->obd_magic, OBD_DEVICE_MAGIC); - if (obd->obd_namespace != NULL) { + if (obd->obd_namespace) { CERROR("obd %p: namespace %p was not properly cleaned up (obd_force=%d)!\n", obd, obd->obd_namespace, obd->obd_force); LBUG(); @@ -112,15 +112,6 @@ static struct obd_type *class_get_type(const char *name) if (!type) { const char *modname = name; - if (strcmp(modname, "obdfilter") == 0) - modname = "ofd"; - - if (strcmp(modname, LUSTRE_LWP_NAME) == 0) - modname = LUSTRE_OSP_NAME; - - if (!strncmp(modname, LUSTRE_MDS_NAME, strlen(LUSTRE_MDS_NAME))) - modname = LUSTRE_MDT_NAME; - if (!request_module("%s", modname)) { CDEBUG(D_INFO, "Loaded module '%s'\n", modname); type = class_search_type(name); @@ -202,7 +193,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, goto failed; } - if (ldt != NULL) { + if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); if (rc != 0) @@ -364,7 +355,7 @@ void class_release_dev(struct obd_device *obd) obd, obd->obd_magic, OBD_DEVICE_MAGIC); LASSERTF(obd == obd_devs[obd->obd_minor], "obd %p != obd_devs[%d] %p\n", obd, obd->obd_minor, obd_devs[obd->obd_minor]); - LASSERT(obd_type != NULL); + LASSERT(obd_type); CDEBUG(D_INFO, "Release obd device %s at %d obd_type name =%s\n", obd->obd_name, obd->obd_minor, obd->obd_type->typ_name); @@ -390,7 +381,8 @@ int class_name2dev(const char *name) if (obd && strcmp(name, obd->obd_name) == 0) { /* Make sure we finished attaching before we give - out any references */ + * out any references + */ LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); if (obd->obd_attached) { read_unlock(&obd_dev_lock); @@ -465,11 +457,12 @@ struct obd_device *class_num2obd(int num) EXPORT_SYMBOL(class_num2obd); /* Search for a client OBD connected to tgt_uuid. If grp_uuid is - specified, then only the client with that uuid is returned, - otherwise any client connected to the tgt is returned. */ + * specified, then only the client with that uuid is returned, + * otherwise any client connected to the tgt is returned. + */ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, - const char *typ_name, - struct obd_uuid *grp_uuid) + const char *typ_name, + struct obd_uuid *grp_uuid) { int i; @@ -497,9 +490,10 @@ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, EXPORT_SYMBOL(class_find_client_obd); /* Iterate the obd_device list looking devices have grp_uuid. Start - searching at *next, and if a device is found, the next index to look - at is saved in *next. If next is NULL, then the first matching device - will always be returned. */ + * searching at *next, and if a device is found, the next index to look + * at is saved in *next. If next is NULL, then the first matching device + * will always be returned. + */ struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next) { int i; @@ -588,21 +582,21 @@ int obd_init_caches(void) { LASSERT(!obd_device_cachep); obd_device_cachep = kmem_cache_create("ll_obd_dev_cache", - sizeof(struct obd_device), - 0, 0, NULL); + sizeof(struct obd_device), + 0, 0, NULL); if (!obd_device_cachep) goto out; LASSERT(!obdo_cachep); obdo_cachep = kmem_cache_create("ll_obdo_cache", sizeof(struct obdo), - 0, 0, NULL); + 0, 0, NULL); if (!obdo_cachep) goto out; LASSERT(!import_cachep); import_cachep = kmem_cache_create("ll_import_cache", - sizeof(struct obd_import), - 0, 0, NULL); + sizeof(struct obd_import), + 0, 0, NULL); if (!import_cachep) goto out; @@ -658,7 +652,7 @@ static void class_export_destroy(struct obd_export *exp) struct obd_device *obd = exp->exp_obd; LASSERT_ATOMIC_ZERO(&exp->exp_refcount); - LASSERT(obd != NULL); + LASSERT(obd); CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp, exp->exp_client_uuid.uuid, obd->obd_name); @@ -698,7 +692,6 @@ EXPORT_SYMBOL(class_export_get); void class_export_put(struct obd_export *exp) { - LASSERT(exp != NULL); LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, LI_POISON); CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp, atomic_read(&exp->exp_refcount) - 1); @@ -718,7 +711,8 @@ EXPORT_SYMBOL(class_export_put); /* Creates a new export, adds it to the hash table, and returns a * pointer to it. The refcount is 2: one for the hash reference, and - * one for the pointer returned by this function. */ + * one for the pointer returned by this function. + */ struct obd_export *class_new_export(struct obd_device *obd, struct obd_uuid *cluuid) { @@ -834,7 +828,7 @@ EXPORT_SYMBOL(class_unlink_export); static void class_import_destroy(struct obd_import *imp) { CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp, - imp->imp_obd->obd_name); + imp->imp_obd->obd_name); LASSERT_ATOMIC_ZERO(&imp->imp_refcount); @@ -844,7 +838,7 @@ static void class_import_destroy(struct obd_import *imp) struct obd_import_conn *imp_conn; imp_conn = list_entry(imp->imp_conn_list.next, - struct obd_import_conn, oic_item); + struct obd_import_conn, oic_item); list_del_init(&imp_conn->oic_item); ptlrpc_put_connection_superhack(imp_conn->oic_conn); kfree(imp_conn); @@ -901,8 +895,9 @@ static void init_imp_at(struct imp_at *at) at_init(&at->iat_net_latency, 0, 0); for (i = 0; i < IMP_AT_MAX_PORTALS; i++) { /* max service estimates are tracked on the server side, so - don't use the AT history here, just use the last reported - val. (But keep hist for proc histogram, worst_ever) */ + * don't use the AT history here, just use the last reported + * val. (But keep hist for proc histogram, worst_ever) + */ at_init(&at->iat_service_estimate[i], INITIAL_CONNECT_TIMEOUT, AT_FLG_NOHIST); } @@ -941,7 +936,8 @@ struct obd_import *class_new_import(struct obd_device *obd) init_imp_at(&imp->imp_at); /* the default magic is V2, will be used in connect RPC, and - * then adjusted according to the flags in request/reply. */ + * then adjusted according to the flags in request/reply. + */ imp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2; return imp; @@ -950,7 +946,7 @@ EXPORT_SYMBOL(class_new_import); void class_destroy_import(struct obd_import *import) { - LASSERT(import != NULL); + LASSERT(import); LASSERT(import != LP_POISON); class_handle_unhash(&import->imp_handle); @@ -970,8 +966,7 @@ void __class_export_add_lock_ref(struct obd_export *exp, struct ldlm_lock *lock) LASSERT(lock->l_exp_refs_nr >= 0); - if (lock->l_exp_refs_target != NULL && - lock->l_exp_refs_target != exp) { + if (lock->l_exp_refs_target && lock->l_exp_refs_target != exp) { LCONSOLE_WARN("setting export %p for lock %p which already has export %p\n", exp, lock, lock->l_exp_refs_target); } @@ -1005,17 +1000,18 @@ EXPORT_SYMBOL(__class_export_del_lock_ref); #endif /* A connection defines an export context in which preallocation can - be managed. This releases the export pointer reference, and returns - the export handle, so the export refcount is 1 when this function - returns. */ + * be managed. This releases the export pointer reference, and returns + * the export handle, so the export refcount is 1 when this function + * returns. + */ int class_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid) { struct obd_export *export; - LASSERT(conn != NULL); - LASSERT(obd != NULL); - LASSERT(cluuid != NULL); + LASSERT(conn); + LASSERT(obd); + LASSERT(cluuid); export = class_new_export(obd, cluuid); if (IS_ERR(export)) @@ -1035,7 +1031,8 @@ EXPORT_SYMBOL(class_connect); * and if disconnect really need * 2 - removing from hash * 3 - in client_unlink_export - * The export pointer passed to this function can destroyed */ + * The export pointer passed to this function can destroyed + */ int class_disconnect(struct obd_export *export) { int already_disconnected; @@ -1052,7 +1049,8 @@ int class_disconnect(struct obd_export *export) /* class_cleanup(), abort_recovery(), and class_fail_export() * all end up in here, and if any of them race we shouldn't - * call extra class_export_puts(). */ + * call extra class_export_puts(). + */ if (already_disconnected) goto no_disconn; @@ -1092,7 +1090,8 @@ void class_fail_export(struct obd_export *exp) /* Most callers into obd_disconnect are removing their own reference * (request, for example) in addition to the one from the hash table. - * We don't have such a reference here, so make one. */ + * We don't have such a reference here, so make one. + */ class_export_get(exp); rc = obd_disconnect(exp); if (rc) @@ -1126,29 +1125,29 @@ static void obd_zombie_impexp_cull(void) import = NULL; if (!list_empty(&obd_zombie_imports)) { import = list_entry(obd_zombie_imports.next, - struct obd_import, - imp_zombie_chain); + struct obd_import, + imp_zombie_chain); list_del_init(&import->imp_zombie_chain); } export = NULL; if (!list_empty(&obd_zombie_exports)) { export = list_entry(obd_zombie_exports.next, - struct obd_export, - exp_obd_chain); + struct obd_export, + exp_obd_chain); list_del_init(&export->exp_obd_chain); } spin_unlock(&obd_zombie_impexp_lock); - if (import != NULL) { + if (import) { class_import_destroy(import); spin_lock(&obd_zombie_impexp_lock); zombies_count--; spin_unlock(&obd_zombie_impexp_lock); } - if (export != NULL) { + if (export) { class_export_destroy(export); spin_lock(&obd_zombie_impexp_lock); zombies_count--; @@ -1156,7 +1155,7 @@ static void obd_zombie_impexp_cull(void) } cond_resched(); - } while (import != NULL || export != NULL); + } while (import || export); } static struct completion obd_zombie_start; |