Commit 7f1ae4c0 authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman

staging/lustre/osc: Adjust NULL comparison codestyle

All instances of "x == NULL" are changed to "!x" and
"x != NULL" to "x"

Also remove some redundant assertions.
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7ae59eda
......@@ -381,7 +381,7 @@ static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
DECLARE_CKSUM_NAME;
if (obd == NULL)
if (!obd)
return 0;
for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
......@@ -406,7 +406,7 @@ static ssize_t osc_checksum_type_seq_write(struct file *file,
DECLARE_CKSUM_NAME;
char kernbuf[10];
if (obd == NULL)
if (!obd)
return 0;
if (count > sizeof(kernbuf) - 1)
......
......@@ -472,7 +472,7 @@ static inline struct osc_thread_info *osc_env_info(const struct lu_env *env)
struct osc_thread_info *info;
info = lu_context_key_get(&env->le_ctx, &osc_key);
LASSERT(info != NULL);
LASSERT(info);
return info;
}
......@@ -481,7 +481,7 @@ static inline struct osc_session *osc_env_session(const struct lu_env *env)
struct osc_session *ses;
ses = lu_context_key_get(env->le_ses, &osc_session_key);
LASSERT(ses != NULL);
LASSERT(ses);
return ses;
}
......
......@@ -123,7 +123,7 @@ static void *osc_key_init(const struct lu_context *ctx,
struct osc_thread_info *info;
info = kmem_cache_alloc(osc_thread_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL)
if (!info)
info = ERR_PTR(-ENOMEM);
return info;
}
......@@ -148,7 +148,7 @@ static void *osc_session_init(const struct lu_context *ctx,
struct osc_session *info;
info = kmem_cache_alloc(osc_session_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL)
if (!info)
info = ERR_PTR(-ENOMEM);
return info;
}
......@@ -228,7 +228,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env,
/* Setup OSC OBD */
obd = class_name2obd(lustre_cfg_string(cfg, 0));
LASSERT(obd != NULL);
LASSERT(obd);
rc = osc_setup(obd, cfg);
if (rc) {
osc_device_free(env, d);
......
......@@ -73,7 +73,7 @@ static struct osc_page *osc_cl_page_osc(struct cl_page *page)
const struct cl_page_slice *slice;
slice = cl_page_at(page, &osc_device_type);
LASSERT(slice != NULL);
LASSERT(slice);
return cl2osc_page(slice);
}
......@@ -135,7 +135,7 @@ static int osc_io_submit(const struct lu_env *env,
/* Top level IO. */
io = page->cp_owner;
LASSERT(io != NULL);
LASSERT(io);
opg = osc_cl_page_osc(page);
oap = &opg->ops_oap;
......@@ -266,7 +266,7 @@ static int osc_io_prepare_write(const struct lu_env *env,
* This implements OBD_BRW_CHECK logic from old client.
*/
if (imp == NULL || imp->imp_invalid)
if (!imp || imp->imp_invalid)
result = -EIO;
if (result == 0 && oio->oi_lockless)
/* this page contains `invalid' data, but who cares?
......@@ -349,7 +349,7 @@ static int trunc_check_cb(const struct lu_env *env, struct cl_io *io,
__u64 start = *(__u64 *)cbdata;
slice = cl_page_at(page, &osc_device_type);
LASSERT(slice != NULL);
LASSERT(slice);
ops = cl2osc_page(slice);
oap = &ops->ops_oap;
......@@ -500,7 +500,7 @@ static void osc_io_setattr_end(const struct lu_env *env,
__u64 size = io->u.ci_setattr.sa_attr.lvb_size;
osc_trunc_check(env, io, oio, size);
if (oio->oi_trunc != NULL) {
if (oio->oi_trunc) {
osc_cache_truncate_end(env, oio, cl2osc(obj));
oio->oi_trunc = NULL;
}
......@@ -754,7 +754,7 @@ static void osc_req_attr_set(const struct lu_env *env,
opg = osc_cl_page_osc(apage);
apage = opg->ops_cl.cpl_page; /* now apage is a sub-page */
lock = cl_lock_at_page(env, apage->cp_obj, apage, NULL, 1, 1);
if (lock == NULL) {
if (!lock) {
struct cl_object_header *head;
struct cl_lock *scan;
......@@ -770,10 +770,9 @@ static void osc_req_attr_set(const struct lu_env *env,
}
olck = osc_lock_at(lock);
LASSERT(olck != NULL);
LASSERT(ergo(opg->ops_srvlock, olck->ols_lock == NULL));
LASSERT(ergo(opg->ops_srvlock, !olck->ols_lock));
/* check for lockless io. */
if (olck->ols_lock != NULL) {
if (olck->ols_lock) {
oa->o_handle = olck->ols_lock->l_remote_handle;
oa->o_valid |= OBD_MD_FLHANDLE;
}
......@@ -804,7 +803,7 @@ int osc_req_init(const struct lu_env *env, struct cl_device *dev,
int result;
or = kmem_cache_alloc(osc_req_kmem, GFP_NOFS | __GFP_ZERO);
if (or != NULL) {
if (or) {
cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops);
result = 0;
} else
......
......@@ -79,7 +79,7 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle)
struct ldlm_lock *lock;
lock = ldlm_handle2lock(handle);
if (lock != NULL)
if (lock)
LDLM_LOCK_PUT(lock);
return lock;
}
......@@ -94,42 +94,40 @@ static int osc_lock_invariant(struct osc_lock *ols)
int handle_used = lustre_handle_is_used(&ols->ols_handle);
if (ergo(osc_lock_is_lockless(ols),
ols->ols_locklessable && ols->ols_lock == NULL))
ols->ols_locklessable && !ols->ols_lock))
return 1;
/*
* If all the following "ergo"s are true, return 1, otherwise 0
*/
if (!ergo(olock != NULL, handle_used))
if (!ergo(olock, handle_used))
return 0;
if (!ergo(olock != NULL,
olock->l_handle.h_cookie == ols->ols_handle.cookie))
if (!ergo(olock, olock->l_handle.h_cookie == ols->ols_handle.cookie))
return 0;
if (!ergo(handle_used,
ergo(lock != NULL && olock != NULL, lock == olock) &&
ergo(lock == NULL, olock == NULL)))
ergo(lock && olock, lock == olock) &&
ergo(!lock, !olock)))
return 0;
/*
* Check that ->ols_handle and ->ols_lock are consistent, but
* take into account that they are set at the different time.
*/
if (!ergo(ols->ols_state == OLS_CANCELLED,
olock == NULL && !handle_used))
!olock && !handle_used))
return 0;
/*
* DLM lock is destroyed only after we have seen cancellation
* ast.
*/
if (!ergo(olock != NULL && ols->ols_state < OLS_CANCELLED,
((olock->l_flags & LDLM_FL_DESTROYED) == 0)))
if (!ergo(olock && ols->ols_state < OLS_CANCELLED,
((olock->l_flags & LDLM_FL_DESTROYED) == 0)))
return 0;
if (!ergo(ols->ols_state == OLS_GRANTED,
olock != NULL &&
olock->l_req_mode == olock->l_granted_mode &&
ols->ols_hold))
olock && olock->l_req_mode == olock->l_granted_mode &&
ols->ols_hold))
return 0;
return 1;
}
......@@ -149,7 +147,7 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck)
spin_lock(&osc_ast_guard);
dlmlock = olck->ols_lock;
if (dlmlock == NULL) {
if (!dlmlock) {
spin_unlock(&osc_ast_guard);
return;
}
......@@ -247,7 +245,7 @@ static void osc_lock_fini(const struct lu_env *env,
* lock is destroyed immediately after upcall.
*/
osc_lock_unhold(ols);
LASSERT(ols->ols_lock == NULL);
LASSERT(!ols->ols_lock);
LASSERT(atomic_read(&ols->ols_pageref) == 0 ||
atomic_read(&ols->ols_pageref) == _PAGEREF_MAGIC);
......@@ -292,7 +290,7 @@ static struct osc_lock *osc_ast_data_get(struct ldlm_lock *dlm_lock)
lock_res_and_lock(dlm_lock);
spin_lock(&osc_ast_guard);
olck = dlm_lock->l_ast_data;
if (olck != NULL) {
if (olck) {
struct cl_lock *lock = olck->ols_cl.cls_lock;
/*
* If osc_lock holds a reference on ldlm lock, return it even
......@@ -359,7 +357,6 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck,
__u64 size;
dlmlock = olck->ols_lock;
LASSERT(dlmlock != NULL);
/* re-grab LVB from a dlm lock under DLM spin-locks. */
*lvb = *(struct ost_lvb *)dlmlock->l_lvb_data;
......@@ -444,12 +441,12 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck)
struct ldlm_lock *dlmlock;
dlmlock = ldlm_handle2lock_long(&olck->ols_handle, 0);
LASSERT(dlmlock != NULL);
LASSERT(dlmlock);
lock_res_and_lock(dlmlock);
spin_lock(&osc_ast_guard);
LASSERT(dlmlock->l_ast_data == olck);
LASSERT(olck->ols_lock == NULL);
LASSERT(!olck->ols_lock);
olck->ols_lock = dlmlock;
spin_unlock(&osc_ast_guard);
......@@ -508,10 +505,10 @@ static int osc_lock_upcall(void *cookie, int errcode)
struct ldlm_lock *dlmlock;
dlmlock = ldlm_handle2lock(&olck->ols_handle);
if (dlmlock != NULL) {
if (dlmlock) {
lock_res_and_lock(dlmlock);
spin_lock(&osc_ast_guard);
LASSERT(olck->ols_lock == NULL);
LASSERT(!olck->ols_lock);
dlmlock->l_ast_data = NULL;
olck->ols_handle.cookie = 0ULL;
spin_unlock(&osc_ast_guard);
......@@ -634,7 +631,7 @@ static int osc_dlm_blocking_ast0(const struct lu_env *env,
cancel = 0;
olck = osc_ast_data_get(dlmlock);
if (olck != NULL) {
if (olck) {
lock = olck->ols_cl.cls_lock;
cl_lock_mutex_get(env, lock);
LINVRNT(osc_lock_invariant(olck));
......@@ -786,17 +783,17 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock,
env = cl_env_nested_get(&nest);
if (!IS_ERR(env)) {
olck = osc_ast_data_get(dlmlock);
if (olck != NULL) {
if (olck) {
lock = olck->ols_cl.cls_lock;
cl_lock_mutex_get(env, lock);
/*
* ldlm_handle_cp_callback() copied LVB from request
* to lock->l_lvb_data, store it in osc_lock.
*/
LASSERT(dlmlock->l_lvb_data != NULL);
LASSERT(dlmlock->l_lvb_data);
lock_res_and_lock(dlmlock);
olck->ols_lvb = *(struct ost_lvb *)dlmlock->l_lvb_data;
if (olck->ols_lock == NULL) {
if (!olck->ols_lock) {
/*
* upcall (osc_lock_upcall()) hasn't yet been
* called. Do nothing now, upcall will bind
......@@ -850,7 +847,7 @@ static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data)
* environment.
*/
olck = osc_ast_data_get(dlmlock);
if (olck != NULL) {
if (olck) {
lock = olck->ols_cl.cls_lock;
/* Do not grab the mutex of cl_lock for glimpse.
* See LU-1274 for details.
......@@ -1074,7 +1071,7 @@ static int osc_lock_enqueue_wait(const struct lu_env *env,
} else {
CDEBUG(D_DLMTRACE, "lock %p is conflicted with %p, will wait\n",
lock, conflict);
LASSERT(lock->cll_conflict == NULL);
LASSERT(!lock->cll_conflict);
lu_ref_add(&conflict->cll_reference, "cancel-wait",
lock);
lock->cll_conflict = conflict;
......@@ -1197,7 +1194,7 @@ static int osc_lock_wait(const struct lu_env *env,
}
LASSERT(equi(olck->ols_state >= OLS_UPCALL_RECEIVED &&
lock->cll_error == 0, olck->ols_lock != NULL));
lock->cll_error == 0, olck->ols_lock));
return lock->cll_error ?: olck->ols_state >= OLS_GRANTED ? 0 : CLO_WAIT;
}
......@@ -1306,7 +1303,7 @@ static void osc_lock_cancel(const struct lu_env *env,
LASSERT(cl_lock_is_mutexed(lock));
LINVRNT(osc_lock_invariant(olck));
if (dlmlock != NULL) {
if (dlmlock) {
int do_cancel;
discard = !!(dlmlock->l_flags & LDLM_FL_DISCARD_DATA);
......@@ -1382,7 +1379,7 @@ static void osc_lock_state(const struct lu_env *env,
if (state == CLS_HELD && slice->cls_lock->cll_state != CLS_HELD) {
struct osc_io *oio = osc_env_io(env);
LASSERT(lock->ols_owner == NULL);
LASSERT(!lock->ols_owner);
lock->ols_owner = oio;
} else if (state != CLS_HELD)
lock->ols_owner = NULL;
......@@ -1556,7 +1553,7 @@ int osc_lock_init(const struct lu_env *env,
int result;
clk = kmem_cache_alloc(osc_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (clk != NULL) {
if (clk) {
__u32 enqflags = lock->cll_descr.cld_enq_flags;
osc_lock_build_einfo(env, lock, clk, &clk->ols_einfo);
......@@ -1599,7 +1596,7 @@ int osc_dlm_lock_pageref(struct ldlm_lock *dlm)
* doesn't matter because in the worst case we don't cancel a lock
* which we actually can, that's no harm.
*/
if (olock != NULL &&
if (olock &&
atomic_add_return(_PAGEREF_MAGIC,
&olock->ols_pageref) != _PAGEREF_MAGIC) {
atomic_sub(_PAGEREF_MAGIC, &olock->ols_pageref);
......
......@@ -113,7 +113,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj)
LASSERT(list_empty(&osc->oo_write_item));
LASSERT(list_empty(&osc->oo_read_item));
LASSERT(osc->oo_root.rb_node == NULL);
LASSERT(!osc->oo_root.rb_node);
LASSERT(list_empty(&osc->oo_hp_exts));
LASSERT(list_empty(&osc->oo_urgent_exts));
LASSERT(list_empty(&osc->oo_rpc_exts));
......@@ -256,7 +256,7 @@ struct lu_object *osc_object_alloc(const struct lu_env *env,
struct lu_object *obj;
osc = kmem_cache_alloc(osc_object_kmem, GFP_NOFS | __GFP_ZERO);
if (osc != NULL) {
if (osc) {
obj = osc2lu(osc);
lu_object_init(obj, NULL, dev);
osc->oo_cl.co_ops = &osc_ops;
......
......@@ -69,7 +69,7 @@ static void osc_page_fini(const struct lu_env *env,
struct osc_page *opg = cl2osc_page(slice);
CDEBUG(D_TRACE, "%p\n", opg);
LASSERT(opg->ops_lock == NULL);
LASSERT(!opg->ops_lock);
}
static void osc_page_transfer_get(struct osc_page *opg, const char *label)
......@@ -135,7 +135,7 @@ static int osc_page_cache_add(const struct lu_env *env,
* osc_io_end() is called, so release it earlier.
* for mkwrite(), it's known there is no further pages. */
if (cl_io_is_sync_write(io) || cl_io_is_mkwrite(io)) {
if (oio->oi_active != NULL) {
if (oio->oi_active) {
osc_extent_release(env, oio->oi_active);
oio->oi_active = NULL;
}
......@@ -159,7 +159,7 @@ static int osc_page_addref_lock(const struct lu_env *env,
struct osc_lock *olock;
int rc;
LASSERT(opg->ops_lock == NULL);
LASSERT(!opg->ops_lock);
olock = osc_lock_at(lock);
if (atomic_inc_return(&olock->ols_pageref) <= 0) {
......@@ -179,7 +179,7 @@ static void osc_page_putref_lock(const struct lu_env *env,
struct cl_lock *lock = opg->ops_lock;
struct osc_lock *olock;
LASSERT(lock != NULL);
LASSERT(lock);
olock = osc_lock_at(lock);
atomic_dec(&olock->ols_pageref);
......@@ -197,7 +197,7 @@ static int osc_page_is_under_lock(const struct lu_env *env,
lock = cl_lock_at_page(env, slice->cpl_obj, slice->cpl_page,
NULL, 1, 0);
if (lock != NULL) {
if (lock) {
if (osc_page_addref_lock(env, cl2osc_page(slice), lock) == 0)
result = -EBUSY;
cl_lock_put(env, lock);
......@@ -325,7 +325,7 @@ static void osc_page_delete(const struct lu_env *env,
}
spin_lock(&obj->oo_seatbelt);
if (opg->ops_submitter != NULL) {
if (opg->ops_submitter) {
LASSERT(!list_empty(&opg->ops_inflight));
list_del_init(&opg->ops_inflight);
opg->ops_submitter = NULL;
......@@ -589,14 +589,14 @@ int osc_lru_shrink(struct client_obd *cli, int target)
continue;
}
LASSERT(page->cp_obj != NULL);
LASSERT(page->cp_obj);
if (clobj != page->cp_obj) {
struct cl_object *tmp = page->cp_obj;
cl_object_get(tmp);
client_obd_list_unlock(&cli->cl_lru_list_lock);
if (clobj != NULL) {
if (clobj) {
count -= discard_pagevec(env, io, pvec, index);
index = 0;
......@@ -641,7 +641,7 @@ int osc_lru_shrink(struct client_obd *cli, int target)
}
client_obd_list_unlock(&cli->cl_lru_list_lock);
if (clobj != NULL) {
if (clobj) {
count -= discard_pagevec(env, io, pvec, index);
cl_io_fini(env, io);
......@@ -720,7 +720,7 @@ static int osc_lru_reclaim(struct client_obd *cli)
int max_scans;
int rc;
LASSERT(cache != NULL);
LASSERT(cache);
rc = osc_lru_shrink(cli, lru_shrink_min);
if (rc != 0) {
......@@ -776,7 +776,7 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj,
struct client_obd *cli = osc_cli(obj);
int rc = 0;
if (cli->cl_cache == NULL) /* shall not be in LRU */
if (!cli->cl_cache) /* shall not be in LRU */
return 0;
LASSERT(atomic_read(cli->cl_lru_left) >= 0);
......
......@@ -36,7 +36,7 @@ static inline struct osc_quota_info *osc_oqi_alloc(u32 id)
struct osc_quota_info *oqi;
oqi = kmem_cache_alloc(osc_quota_kmem, GFP_NOFS | __GFP_ZERO);
if (oqi != NULL)
if (oqi)
oqi->oqi_id = id;
return oqi;
......@@ -90,11 +90,11 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
if ((flags & FL_QUOTA_FLAG(type)) != 0) {
/* This ID is getting close to its quota limit, let's
* switch to sync I/O */
if (oqi != NULL)
if (oqi)
continue;
oqi = osc_oqi_alloc(qid[type]);
if (oqi == NULL) {
if (!oqi) {
rc = -ENOMEM;
break;
}
......@@ -114,7 +114,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
} else {
/* This ID is now off the hook, let's remove it from
* the hash table */
if (oqi == NULL)
if (!oqi)
continue;
oqi = cfs_hash_del_key(cli->cl_quota_hash[type],
......@@ -147,7 +147,7 @@ oqi_keycmp(const void *key, struct hlist_node *hnode)
struct osc_quota_info *oqi;
u32 uid;
LASSERT(key != NULL);
LASSERT(key);
uid = *((u32 *)key);
oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash);
......@@ -218,7 +218,7 @@ int osc_quota_setup(struct obd_device *obd)
CFS_HASH_MAX_THETA,
&quota_hash_ops,
CFS_HASH_DEFAULT);
if (cli->cl_quota_hash[type] == NULL)
if (!cli->cl_quota_hash[type])
break;
}
......@@ -252,7 +252,7 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp,
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_OST_QUOTACTL, LUSTRE_OST_VERSION,
OST_QUOTACTL);
if (req == NULL)
if (!req)
return -ENOMEM;
oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
......@@ -294,7 +294,7 @@ int osc_quotacheck(struct obd_device *unused, struct obd_export *exp,
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION,
OST_QUOTACHECK);
if (req == NULL)
if (!req)
return -ENOMEM;
body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment