Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00697c43 authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman
Browse files

staging/lustre/lov: Adjust NULL comparison codestyle



All instances of "x == NULL" are changed to "!x" and
"x != NULL" to "x"
Also removed some redundant assertions.

Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 15d9f520
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -651,7 +651,7 @@ static inline struct lov_session *lov_env_session(const struct lu_env *env)
	struct lov_session *ses;
	struct lov_session *ses;


	ses = lu_context_key_get(env->le_ses, &lov_session_key);
	ses = lu_context_key_get(env->le_ses, &lov_session_key);
	LASSERT(ses != NULL);
	LASSERT(ses);
	return ses;
	return ses;
}
}


@@ -759,7 +759,7 @@ static inline struct lovsub_lock *cl2sub_lock(const struct cl_lock *lock)
	const struct cl_lock_slice *slice;
	const struct cl_lock_slice *slice;


	slice = cl_lock_at(lock, &lovsub_device_type);
	slice = cl_lock_at(lock, &lovsub_device_type);
	LASSERT(slice != NULL);
	LASSERT(slice);
	return cl2lovsub_lock(slice);
	return cl2lovsub_lock(slice);
}
}


@@ -817,7 +817,7 @@ static inline struct lov_thread_info *lov_env_info(const struct lu_env *env)
	struct lov_thread_info *info;
	struct lov_thread_info *info;


	info = lu_context_key_get(&env->le_ctx, &lov_key);
	info = lu_context_key_get(&env->le_ctx, &lov_key);
	LASSERT(info != NULL);
	LASSERT(info);
	return info;
	return info;
}
}


+19 −21
Original line number Original line Diff line number Diff line
@@ -143,7 +143,7 @@ static void *lov_key_init(const struct lu_context *ctx,
	struct lov_thread_info *info;
	struct lov_thread_info *info;


	info = kmem_cache_alloc(lov_thread_kmem, GFP_NOFS | __GFP_ZERO);
	info = kmem_cache_alloc(lov_thread_kmem, GFP_NOFS | __GFP_ZERO);
	if (info != NULL)
	if (info)
		INIT_LIST_HEAD(&info->lti_closure.clc_list);
		INIT_LIST_HEAD(&info->lti_closure.clc_list);
	else
	else
		info = ERR_PTR(-ENOMEM);
		info = ERR_PTR(-ENOMEM);
@@ -171,7 +171,7 @@ static void *lov_session_key_init(const struct lu_context *ctx,
	struct lov_session *info;
	struct lov_session *info;


	info = kmem_cache_alloc(lov_session_kmem, GFP_NOFS | __GFP_ZERO);
	info = kmem_cache_alloc(lov_session_kmem, GFP_NOFS | __GFP_ZERO);
	if (info == NULL)
	if (!info)
		info = ERR_PTR(-ENOMEM);
		info = ERR_PTR(-ENOMEM);
	return info;
	return info;
}
}
@@ -199,15 +199,15 @@ static struct lu_device *lov_device_fini(const struct lu_env *env,
	int i;
	int i;
	struct lov_device *ld = lu2lov_dev(d);
	struct lov_device *ld = lu2lov_dev(d);


	LASSERT(ld->ld_lov != NULL);
	LASSERT(ld->ld_lov);
	if (ld->ld_target == NULL)
	if (!ld->ld_target)
		return NULL;
		return NULL;


	lov_foreach_target(ld, i) {
	lov_foreach_target(ld, i) {
		struct lovsub_device *lsd;
		struct lovsub_device *lsd;


		lsd = ld->ld_target[i];
		lsd = ld->ld_target[i];
		if (lsd != NULL) {
		if (lsd) {
			cl_stack_fini(env, lovsub2cl_dev(lsd));
			cl_stack_fini(env, lovsub2cl_dev(lsd));
			ld->ld_target[i] = NULL;
			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 i;
	int rc = 0;
	int rc = 0;


	LASSERT(d->ld_site != NULL);
	LASSERT(d->ld_site);
	if (ld->ld_target == NULL)
	if (!ld->ld_target)
		return rc;
		return rc;


	lov_foreach_target(ld, i) {
	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;
		struct lov_tgt_desc  *desc;


		desc = ld->ld_lov->lov_tgts[i];
		desc = ld->ld_lov->lov_tgts[i];
		if (desc == NULL)
		if (!desc)
			continue;
			continue;


		cl = cl_type_setup(env, d->ld_site, &lovsub_device_type,
		cl = cl_type_setup(env, d->ld_site, &lovsub_device_type,
@@ -262,7 +262,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev,
	int result;
	int result;


	lr = kmem_cache_alloc(lov_req_kmem, GFP_NOFS | __GFP_ZERO);
	lr = kmem_cache_alloc(lov_req_kmem, GFP_NOFS | __GFP_ZERO);
	if (lr != NULL) {
	if (lr) {
		cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops);
		cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops);
		result = 0;
		result = 0;
	} else
	} else
@@ -282,9 +282,9 @@ static void lov_emerg_free(struct lov_device_emerg **emrg, int nr)
		struct lov_device_emerg *em;
		struct lov_device_emerg *em;


		em = emrg[i];
		em = emrg[i];
		if (em != NULL) {
		if (em) {
			LASSERT(em->emrg_page_list.pl_nr == 0);
			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);
				cl_env_put(em->emrg_env, &em->emrg_refcheck);
			kfree(em);
			kfree(em);
		}
		}
@@ -300,7 +300,7 @@ static struct lu_device *lov_device_free(const struct lu_env *env,


	cl_device_fini(lu2cl_dev(d));
	cl_device_fini(lu2cl_dev(d));
	kfree(ld->ld_target);
	kfree(ld->ld_target);
	if (ld->ld_emrg != NULL)
	if (ld->ld_emrg)
		lov_emerg_free(ld->ld_emrg, nr);
		lov_emerg_free(ld->ld_emrg, nr);
	kfree(ld);
	kfree(ld);
	return NULL;
	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);
	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]));
		cl_stack_fini(env, lovsub2cl_dev(ld->ld_target[index]));
		ld->ld_target[index] = NULL;
		ld->ld_target[index] = NULL;
	}
	}
@@ -324,13 +324,13 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr)
	int result;
	int result;


	emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS);
	emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS);
	if (emerg == NULL)
	if (!emerg)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);
	for (result = i = 0; i < nr && result == 0; i++) {
	for (result = i = 0; i < nr && result == 0; i++) {
		struct lov_device_emerg *em;
		struct lov_device_emerg *em;


		em = kzalloc(sizeof(*em), GFP_NOFS);
		em = kzalloc(sizeof(*em), GFP_NOFS);
		if (em != NULL) {
		if (em) {
			emerg[i] = em;
			emerg[i] = em;
			cl_page_list_init(&em->emrg_page_list);
			cl_page_list_init(&em->emrg_page_list);
			em->emrg_env = cl_env_alloc(&em->emrg_refcheck,
			em->emrg_env = cl_env_alloc(&em->emrg_refcheck,
@@ -370,7 +370,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev)
			return PTR_ERR(emerg);
			return PTR_ERR(emerg);


		newd = kcalloc(tgt_size, sz, GFP_NOFS);
		newd = kcalloc(tgt_size, sz, GFP_NOFS);
		if (newd != NULL) {
		if (newd) {
			mutex_lock(&dev->ld_mutex);
			mutex_lock(&dev->ld_mutex);
			if (sub_size > 0) {
			if (sub_size > 0) {
				memcpy(newd, dev->ld_target, sub_size * sz);
				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    = newd;
			dev->ld_target_nr = tgt_size;
			dev->ld_target_nr = tgt_size;


			if (dev->ld_emrg != NULL)
			if (dev->ld_emrg)
				lov_emerg_free(dev->ld_emrg, sub_size);
				lov_emerg_free(dev->ld_emrg, sub_size);
			dev->ld_emrg = emerg;
			dev->ld_emrg = emerg;
			mutex_unlock(&dev->ld_mutex);
			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);
	obd_getref(obd);


	tgt = obd->u.lov.lov_tgts[index];
	tgt = obd->u.lov.lov_tgts[index];
	LASSERT(tgt != NULL);
	LASSERT(tgt->ltd_obd != NULL);


	if (!tgt->ltd_obd->obd_set_up) {
	if (!tgt->ltd_obd->obd_set_up) {
		CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid));
		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);
	rc = lov_expand_targets(env, ld);
	if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) {
	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,
		cl = cl_type_setup(env, dev->ld_site, &lovsub_device_type,
				   tgt->ltd_obd->obd_lu_dev);
				   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 */
	/* setup the LOV OBD */
	obd = class_name2obd(lustre_cfg_string(cfg, 0));
	obd = class_name2obd(lustre_cfg_string(cfg, 0));
	LASSERT(obd != NULL);
	LASSERT(obd);
	rc = lov_setup(obd, cfg);
	rc = lov_setup(obd, cfg);
	if (rc) {
	if (rc) {
		lov_device_free(env, d);
		lov_device_free(env, d);
+2 −2
Original line number Original line Diff line number Diff line
@@ -101,7 +101,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size)


	for (i = 0; i < stripe_count; i++) {
	for (i = 0; i < stripe_count; i++) {
		loi = kmem_cache_alloc(lov_oinfo_slab, GFP_NOFS | __GFP_ZERO);
		loi = kmem_cache_alloc(lov_oinfo_slab, GFP_NOFS | __GFP_ZERO);
		if (loi == NULL)
		if (!loi)
			goto err;
			goto err;
		lsm->lsm_oinfo[i] = loi;
		lsm->lsm_oinfo[i] = loi;
	}
	}
@@ -167,7 +167,7 @@ static void lov_tgt_maxbytes(struct lov_tgt_desc *tgt, __u64 *stripe_maxbytes)
{
{
	struct obd_import *imp = tgt->ltd_obd->u.cli.cl_import;
	struct obd_import *imp = tgt->ltd_obd->u.cli.cl_import;


	if (imp == NULL || !tgt->ltd_active) {
	if (!imp || !tgt->ltd_active) {
		*stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES;
		*stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES;
		return;
		return;
	}
	}
+0 −1
Original line number Original line Diff line number Diff line
@@ -114,7 +114,6 @@ void lov_finish_set(struct lov_request_set *set);


static inline void lov_get_reqset(struct lov_request_set *set)
static inline void lov_get_reqset(struct lov_request_set *set)
{
{
	LASSERT(set != NULL);
	LASSERT(atomic_read(&set->set_refcount) > 0);
	LASSERT(atomic_read(&set->set_refcount) > 0);
	atomic_inc(&set->set_refcount);
	atomic_inc(&set->set_refcount);
}
}
+14 −16
Original line number Original line Diff line number Diff line
@@ -60,7 +60,7 @@ static inline void lov_sub_exit(struct lov_io_sub *sub)
static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio,
static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio,
			    struct lov_io_sub *sub)
			    struct lov_io_sub *sub)
{
{
	if (sub->sub_io != NULL) {
	if (sub->sub_io) {
		if (sub->sub_io_initialized) {
		if (sub->sub_io_initialized) {
			lov_sub_enter(sub);
			lov_sub_enter(sub);
			cl_io_fini(sub->sub_env, sub->sub_io);
			cl_io_fini(sub->sub_env, sub->sub_io);
@@ -74,7 +74,7 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio,
			kfree(sub->sub_io);
			kfree(sub->sub_io);
		sub->sub_io = NULL;
		sub->sub_io = NULL;
	}
	}
	if (sub->sub_env != NULL && !IS_ERR(sub->sub_env)) {
	if (!IS_ERR_OR_NULL(sub->sub_env)) {
		if (!sub->sub_borrowed)
		if (!sub->sub_borrowed)
			cl_env_put(sub->sub_env, &sub->sub_refcheck);
			cl_env_put(sub->sub_env, &sub->sub_refcheck);
		sub->sub_env = NULL;
		sub->sub_env = NULL;
@@ -143,11 +143,11 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
	int stripe = sub->sub_stripe;
	int stripe = sub->sub_stripe;
	int result;
	int result;


	LASSERT(sub->sub_io == NULL);
	LASSERT(!sub->sub_io);
	LASSERT(sub->sub_env == NULL);
	LASSERT(!sub->sub_env);
	LASSERT(sub->sub_stripe < lio->lis_stripe_count);
	LASSERT(sub->sub_stripe < lio->lis_stripe_count);


	if (unlikely(lov_r0(lov)->lo_sub[stripe] == NULL))
	if (unlikely(!lov_r0(lov)->lo_sub[stripe]))
		return -EIO;
		return -EIO;


	result = 0;
	result = 0;
@@ -252,7 +252,6 @@ static int lov_page_stripe(const struct cl_page *page)
	subobj = lu2lovsub(
	subobj = lu2lovsub(
		lu_object_locate(page->cp_child->cp_obj->co_lu.lo_header,
		lu_object_locate(page->cp_child->cp_obj->co_lu.lo_header,
				 &lovsub_device_type));
				 &lovsub_device_type));
	LASSERT(subobj != NULL);
	return subobj->lso_index;
	return subobj->lso_index;
}
}


@@ -263,9 +262,9 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio,
	struct cl_page       *page = slice->cpl_page;
	struct cl_page       *page = slice->cpl_page;
	int stripe;
	int stripe;


	LASSERT(lio->lis_cl.cis_io != NULL);
	LASSERT(lio->lis_cl.cis_io);
	LASSERT(cl2lov(slice->cpl_obj) == lio->lis_object);
	LASSERT(cl2lov(slice->cpl_obj) == lio->lis_object);
	LASSERT(lsm != NULL);
	LASSERT(lsm);
	LASSERT(lio->lis_nr_subios > 0);
	LASSERT(lio->lis_nr_subios > 0);


	stripe = lov_page_stripe(page);
	stripe = lov_page_stripe(page);
@@ -278,7 +277,7 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
	struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
	struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
	int result;
	int result;


	LASSERT(lio->lis_object != NULL);
	LASSERT(lio->lis_object);


	/*
	/*
	 * Need to be optimized, we can't afford to allocate a piece of memory
	 * Need to be optimized, we can't afford to allocate a piece of memory
@@ -288,7 +287,7 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
		libcfs_kvzalloc(lsm->lsm_stripe_count *
		libcfs_kvzalloc(lsm->lsm_stripe_count *
				sizeof(lio->lis_subs[0]),
				sizeof(lio->lis_subs[0]),
				GFP_NOFS);
				GFP_NOFS);
	if (lio->lis_subs != NULL) {
	if (lio->lis_subs) {
		lio->lis_nr_subios = lio->lis_stripe_count;
		lio->lis_nr_subios = lio->lis_stripe_count;
		lio->lis_single_subio_index = -1;
		lio->lis_single_subio_index = -1;
		lio->lis_active_subios = 0;
		lio->lis_active_subios = 0;
@@ -304,7 +303,6 @@ static void lov_io_slice_init(struct lov_io *lio,
	io->ci_result = 0;
	io->ci_result = 0;
	lio->lis_object = obj;
	lio->lis_object = obj;


	LASSERT(obj->lo_lsm != NULL);
	lio->lis_stripe_count = obj->lo_lsm->lsm_stripe_count;
	lio->lis_stripe_count = obj->lo_lsm->lsm_stripe_count;


	switch (io->ci_type) {
	switch (io->ci_type) {
@@ -358,7 +356,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
	struct lov_object *lov = cl2lov(ios->cis_obj);
	struct lov_object *lov = cl2lov(ios->cis_obj);
	int i;
	int i;


	if (lio->lis_subs != NULL) {
	if (lio->lis_subs) {
		for (i = 0; i < lio->lis_nr_subios; i++)
		for (i = 0; i < lio->lis_nr_subios; i++)
			lov_io_sub_fini(env, lio, &lio->lis_subs[i]);
			lov_io_sub_fini(env, lio, &lio->lis_subs[i]);
		kvfree(lio->lis_subs);
		kvfree(lio->lis_subs);
@@ -395,7 +393,7 @@ static int lov_io_iter_init(const struct lu_env *env,
					   endpos, &start, &end))
					   endpos, &start, &end))
			continue;
			continue;


		if (unlikely(lov_r0(lio->lis_object)->lo_sub[stripe] == NULL)) {
		if (unlikely(!lov_r0(lio->lis_object)->lo_sub[stripe])) {
			if (ios->cis_io->ci_type == CIT_READ ||
			if (ios->cis_io->ci_type == CIT_READ ||
			    ios->cis_io->ci_type == CIT_WRITE ||
			    ios->cis_io->ci_type == CIT_WRITE ||
			    ios->cis_io->ci_type == CIT_FAULT)
			    ios->cis_io->ci_type == CIT_FAULT)
@@ -601,13 +599,13 @@ static int lov_io_submit(const struct lu_env *env,
		return rc;
		return rc;
	}
	}


	LASSERT(lio->lis_subs != NULL);
	LASSERT(lio->lis_subs);
	if (alloc) {
	if (alloc) {
		stripes_qin =
		stripes_qin =
			libcfs_kvzalloc(sizeof(*stripes_qin) *
			libcfs_kvzalloc(sizeof(*stripes_qin) *
					lio->lis_nr_subios,
					lio->lis_nr_subios,
					GFP_NOFS);
					GFP_NOFS);
		if (stripes_qin == NULL)
		if (!stripes_qin)
			return -ENOMEM;
			return -ENOMEM;


		for (stripe = 0; stripe < lio->lis_nr_subios; stripe++)
		for (stripe = 0; stripe < lio->lis_nr_subios; stripe++)
@@ -955,7 +953,7 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,
	struct lov_io *lio = lov_env_io(env);
	struct lov_io *lio = lov_env_io(env);
	int result;
	int result;


	LASSERT(lov->lo_lsm != NULL);
	LASSERT(lov->lo_lsm);
	lio->lis_object = lov;
	lio->lis_object = lov;


	switch (io->ci_type) {
	switch (io->ci_type) {
Loading