diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/lov/lov_dev.c')
-rw-r--r-- | drivers/staging/lustre/lustre/lov/lov_dev.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 3733fdc88c8c..532ef87dfb44 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -142,8 +142,8 @@ static void *lov_key_init(const struct lu_context *ctx, { struct lov_thread_info *info; - info = kmem_cache_alloc(lov_thread_kmem, GFP_NOFS | __GFP_ZERO); - if (info != NULL) + info = kmem_cache_zalloc(lov_thread_kmem, GFP_NOFS); + if (info) INIT_LIST_HEAD(&info->lti_closure.clc_list); else info = ERR_PTR(-ENOMEM); @@ -170,8 +170,8 @@ static void *lov_session_key_init(const struct lu_context *ctx, { struct lov_session *info; - info = kmem_cache_alloc(lov_session_kmem, GFP_NOFS | __GFP_ZERO); - if (info == NULL) + info = kmem_cache_zalloc(lov_session_kmem, GFP_NOFS); + if (!info) info = ERR_PTR(-ENOMEM); return info; } @@ -199,15 +199,15 @@ static struct lu_device *lov_device_fini(const struct lu_env *env, int i; struct lov_device *ld = lu2lov_dev(d); - LASSERT(ld->ld_lov != NULL); - if (ld->ld_target == NULL) + LASSERT(ld->ld_lov); + if (!ld->ld_target) return NULL; lov_foreach_target(ld, i) { struct lovsub_device *lsd; lsd = ld->ld_target[i]; - if (lsd != NULL) { + if (lsd) { cl_stack_fini(env, lovsub2cl_dev(lsd)); ld->ld_target[i] = NULL; } @@ -222,8 +222,8 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, int i; int rc = 0; - LASSERT(d->ld_site != NULL); - if (ld->ld_target == NULL) + LASSERT(d->ld_site); + if (!ld->ld_target) return rc; lov_foreach_target(ld, i) { @@ -232,7 +232,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, struct lov_tgt_desc *desc; desc = ld->ld_lov->lov_tgts[i]; - if (desc == NULL) + if (!desc) continue; cl = cl_type_setup(env, d->ld_site, &lovsub_device_type, @@ -261,8 +261,8 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev, struct lov_req *lr; int result; - lr = kmem_cache_alloc(lov_req_kmem, GFP_NOFS | __GFP_ZERO); - if (lr != NULL) { + lr = kmem_cache_zalloc(lov_req_kmem, GFP_NOFS); + if (lr) { cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops); result = 0; } else @@ -282,9 +282,9 @@ static void lov_emerg_free(struct lov_device_emerg **emrg, int nr) struct lov_device_emerg *em; em = emrg[i]; - if (em != NULL) { + if (em) { LASSERT(em->emrg_page_list.pl_nr == 0); - if (em->emrg_env != NULL) + if (em->emrg_env) cl_env_put(em->emrg_env, &em->emrg_refcheck); kfree(em); } @@ -300,7 +300,7 @@ static struct lu_device *lov_device_free(const struct lu_env *env, cl_device_fini(lu2cl_dev(d)); kfree(ld->ld_target); - if (ld->ld_emrg != NULL) + if (ld->ld_emrg) lov_emerg_free(ld->ld_emrg, nr); kfree(ld); return NULL; @@ -311,7 +311,7 @@ static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev, { struct lov_device *ld = lu2lov_dev(dev); - if (ld->ld_target[index] != NULL) { + if (ld->ld_target[index]) { cl_stack_fini(env, lovsub2cl_dev(ld->ld_target[index])); ld->ld_target[index] = NULL; } @@ -324,17 +324,17 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr) int result; emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS); - if (emerg == NULL) + if (!emerg) return ERR_PTR(-ENOMEM); for (result = i = 0; i < nr && result == 0; i++) { struct lov_device_emerg *em; em = kzalloc(sizeof(*em), GFP_NOFS); - if (em != NULL) { + if (em) { emerg[i] = em; cl_page_list_init(&em->emrg_page_list); em->emrg_env = cl_env_alloc(&em->emrg_refcheck, - LCT_REMEMBER|LCT_NOREF); + LCT_REMEMBER | LCT_NOREF); if (!IS_ERR(em->emrg_env)) em->emrg_env->le_ctx.lc_cookie = 0x2; else { @@ -370,7 +370,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) return PTR_ERR(emerg); newd = kcalloc(tgt_size, sz, GFP_NOFS); - if (newd != NULL) { + if (newd) { mutex_lock(&dev->ld_mutex); if (sub_size > 0) { memcpy(newd, dev->ld_target, sub_size * sz); @@ -379,7 +379,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) dev->ld_target = newd; dev->ld_target_nr = tgt_size; - if (dev->ld_emrg != NULL) + if (dev->ld_emrg) lov_emerg_free(dev->ld_emrg, sub_size); dev->ld_emrg = emerg; mutex_unlock(&dev->ld_mutex); @@ -404,8 +404,6 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, obd_getref(obd); tgt = obd->u.lov.lov_tgts[index]; - LASSERT(tgt != NULL); - LASSERT(tgt->ltd_obd != NULL); if (!tgt->ltd_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid)); @@ -414,7 +412,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, rc = lov_expand_targets(env, ld); if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) { - LASSERT(dev->ld_site != NULL); + LASSERT(dev->ld_site); cl = cl_type_setup(env, dev->ld_site, &lovsub_device_type, tgt->ltd_obd->obd_lu_dev); @@ -492,7 +490,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, /* setup the LOV OBD */ obd = class_name2obd(lustre_cfg_string(cfg, 0)); - LASSERT(obd != NULL); + LASSERT(obd); rc = lov_setup(obd, cfg); if (rc) { lov_device_free(env, d); |