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

Commit 8b382089 authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman
Browse files

staging/lustre/ptlrpc: 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 7f1ae4c0
Loading
Loading
Loading
Loading
+32 −43
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req,

	LASSERT(type == BULK_PUT_SINK || type == BULK_GET_SOURCE);
	desc = ptlrpc_new_bulk(npages, max_brw, type, portal);
	if (desc == NULL)
	if (!desc)
		return NULL;

	desc->bd_import_generation = req->rq_import_generation;
@@ -171,7 +171,7 @@ void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
			     struct page *page, int pageoffset, int len, int pin)
{
	LASSERT(desc->bd_iov_count < desc->bd_max_iov);
	LASSERT(page != NULL);
	LASSERT(page);
	LASSERT(pageoffset >= 0);
	LASSERT(len > 0);
	LASSERT(pageoffset + len <= PAGE_CACHE_SIZE);
@@ -193,7 +193,6 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin)
{
	int i;

	LASSERT(desc != NULL);
	LASSERT(desc->bd_iov_count != LI_POISON); /* not freed already */
	LASSERT(desc->bd_md_count == 0);	 /* network hands off */
	LASSERT((desc->bd_export != NULL) ^ (desc->bd_import != NULL));
@@ -412,7 +411,7 @@ int ptlrpc_request_cache_init(void)
	request_cache = kmem_cache_create("ptlrpc_cache",
					  sizeof(struct ptlrpc_request),
					  0, SLAB_HWCACHE_ALIGN, NULL);
	return request_cache == NULL ? -ENOMEM : 0;
	return !request_cache ? -ENOMEM : 0;
}

void ptlrpc_request_cache_fini(void)
@@ -442,8 +441,6 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
	struct list_head *l, *tmp;
	struct ptlrpc_request *req;

	LASSERT(pool != NULL);

	spin_lock(&pool->prp_lock);
	list_for_each_safe(l, tmp, &pool->prp_req_list) {
		req = list_entry(l, struct ptlrpc_request, rq_list);
@@ -753,7 +750,7 @@ ptlrpc_request_alloc_internal(struct obd_import *imp,
	struct ptlrpc_request *request;

	request = __ptlrpc_request_alloc(imp, pool);
	if (request == NULL)
	if (!request)
		return NULL;

	req_capsule_init(&request->rq_pill, request, RCL_CLIENT);
@@ -952,10 +949,10 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
	atomic_inc(&set->set_remaining);
	req->rq_queued_time = cfs_time_current();

	if (req->rq_reqmsg != NULL)
	if (req->rq_reqmsg)
		lustre_msg_set_jobid(req->rq_reqmsg, NULL);

	if (set->set_producer != NULL)
	if (set->set_producer)
		/*
		 * If the request set has a producer callback, the RPC must be
		 * sent straight away
@@ -975,7 +972,7 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
	struct ptlrpc_request_set *set = pc->pc_set;
	int count, i;

	LASSERT(req->rq_set == NULL);
	LASSERT(!req->rq_set);
	LASSERT(test_bit(LIOD_STOP, &pc->pc_flags) == 0);

	spin_lock(&set->set_new_req_lock);
@@ -1016,7 +1013,6 @@ static int ptlrpc_import_delay_req(struct obd_import *imp,
{
	int delay = 0;

	LASSERT(status != NULL);
	*status = 0;

	if (req->rq_ctx_init || req->rq_ctx_fini) {
@@ -1079,7 +1075,7 @@ static int ptlrpc_console_allow(struct ptlrpc_request *req)
	__u32 opc;
	int err;

	LASSERT(req->rq_reqmsg != NULL);
	LASSERT(req->rq_reqmsg);
	opc = lustre_msg_get_opc(req->rq_reqmsg);

	/*
@@ -1168,7 +1164,7 @@ static int after_reply(struct ptlrpc_request *req)
	struct timespec64 work_start;
	long timediff;

	LASSERT(obd != NULL);
	LASSERT(obd);
	/* repbuf must be unlinked */
	LASSERT(!req->rq_receiving_reply && !req->rq_reply_unlink);

@@ -1248,7 +1244,7 @@ static int after_reply(struct ptlrpc_request *req)
	ktime_get_real_ts64(&work_start);
	timediff = (work_start.tv_sec - req->rq_arrival_time.tv_sec) * USEC_PER_SEC +
		   (work_start.tv_nsec - req->rq_arrival_time.tv_nsec) / NSEC_PER_USEC;
	if (obd->obd_svc_stats != NULL) {
	if (obd->obd_svc_stats) {
		lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR,
				    timediff);
		ptlrpc_lprocfs_rpc_sent(req, timediff);
@@ -1311,7 +1307,7 @@ static int after_reply(struct ptlrpc_request *req)
			/* version recovery */
			ptlrpc_save_versions(req);
			ptlrpc_retain_replayable_request(req, imp);
		} else if (req->rq_commit_cb != NULL &&
		} else if (req->rq_commit_cb &&
			   list_empty(&req->rq_replay_list)) {
			/*
			 * NB: don't call rq_commit_cb if it's already on
@@ -1438,7 +1434,7 @@ static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set)
{
	int remaining, rc;

	LASSERT(set->set_producer != NULL);
	LASSERT(set->set_producer);

	remaining = atomic_read(&set->set_remaining);

@@ -1751,7 +1747,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
			 * process the reply. Similarly if the RPC returned
			 * an error, and therefore the bulk will never arrive.
			 */
			if (req->rq_bulk == NULL || req->rq_status < 0) {
			if (!req->rq_bulk || req->rq_status < 0) {
				ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET);
				goto interpret;
			}
@@ -1803,7 +1799,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
		}
		ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE);

		CDEBUG(req->rq_reqmsg != NULL ? D_RPCTRACE : 0,
		CDEBUG(req->rq_reqmsg ? D_RPCTRACE : 0,
		       "Completed RPC pname:cluuid:pid:xid:nid:opc %s:%s:%d:%llu:%s:%d\n",
		       current_comm(), imp->imp_obd->obd_uuid.uuid,
		       lustre_msg_get_status(req->rq_reqmsg), req->rq_xid,
@@ -1883,7 +1879,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink)
		      "timed out for sent delay" : "timed out for slow reply"),
		  (s64)req->rq_sent, (s64)req->rq_real_sent);

	if (imp != NULL && obd_debug_peer_on_timeout)
	if (imp && obd_debug_peer_on_timeout)
		LNetDebugPeer(imp->imp_connection->c_peer);

	ptlrpc_unregister_reply(req, async_unlink);
@@ -1892,7 +1888,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink)
	if (obd_dump_on_timeout)
		libcfs_debug_dumplog();

	if (imp == NULL) {
	if (!imp) {
		DEBUG_REQ(D_HA, req, "NULL import: already cleaned up?");
		return 1;
	}
@@ -1945,8 +1941,6 @@ int ptlrpc_expired_set(void *data)
	struct list_head *tmp;
	time64_t now = ktime_get_real_seconds();

	LASSERT(set != NULL);

	/* A timeout expired. See which reqs it applies to...  */
	list_for_each(tmp, &set->set_requests) {
		struct ptlrpc_request *req =
@@ -2003,7 +1997,6 @@ void ptlrpc_interrupted_set(void *data)
	struct ptlrpc_request_set *set = data;
	struct list_head *tmp;

	LASSERT(set != NULL);
	CDEBUG(D_RPCTRACE, "INTERRUPTED SET %p\n", set);

	list_for_each(tmp, &set->set_requests) {
@@ -2175,7 +2168,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
			rc = req->rq_status;
	}

	if (set->set_interpret != NULL) {
	if (set->set_interpret) {
		int (*interpreter)(struct ptlrpc_request_set *set, void *, int) =
			set->set_interpret;
		rc = interpreter(set, set->set_arg, rc);
@@ -2207,10 +2200,10 @@ EXPORT_SYMBOL(ptlrpc_set_wait);
 */
static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
{
	if (request == NULL)
	if (!request)
		return;
	LASSERTF(!request->rq_receiving_reply, "req %p\n", request);
	LASSERTF(request->rq_rqbd == NULL, "req %p\n", request);/* client-side */
	LASSERTF(!request->rq_rqbd, "req %p\n", request);/* client-side */
	LASSERTF(list_empty(&request->rq_list), "req %p\n", request);
	LASSERTF(list_empty(&request->rq_set_chain), "req %p\n", request);
	LASSERTF(list_empty(&request->rq_exp_list), "req %p\n", request);
@@ -2222,7 +2215,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
	 * We must take it off the imp_replay_list first.  Otherwise, we'll set
	 * request->rq_reqmsg to NULL while osc_close is dereferencing it.
	 */
	if (request->rq_import != NULL) {
	if (request->rq_import) {
		if (!locked)
			spin_lock(&request->rq_import->imp_lock);
		list_del_init(&request->rq_replay_list);
@@ -2237,20 +2230,20 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
		LBUG();
	}

	if (request->rq_repbuf != NULL)
	if (request->rq_repbuf)
		sptlrpc_cli_free_repbuf(request);
	if (request->rq_export != NULL) {
	if (request->rq_export) {
		class_export_put(request->rq_export);
		request->rq_export = NULL;
	}
	if (request->rq_import != NULL) {
	if (request->rq_import) {
		class_import_put(request->rq_import);
		request->rq_import = NULL;
	}
	if (request->rq_bulk != NULL)
	if (request->rq_bulk)
		ptlrpc_free_bulk_pin(request->rq_bulk);

	if (request->rq_reqbuf != NULL || request->rq_clrbuf != NULL)
	if (request->rq_reqbuf || request->rq_clrbuf)
		sptlrpc_cli_free_reqbuf(request);

	if (request->rq_cli_ctx)
@@ -2270,7 +2263,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
 */
static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked)
{
	if (request == NULL)
	if (!request)
		return 1;

	if (request == LP_POISON ||
@@ -2352,7 +2345,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async)
	 * a chance to run reply_in_callback(), and to make sure we've
	 * unlinked before returning a req to the pool.
	 */
	if (request->rq_set != NULL)
	if (request->rq_set)
		wq = &request->rq_set->set_waitq;
	else
		wq = &request->rq_reply_waitq;
@@ -2387,7 +2380,7 @@ static void ptlrpc_free_request(struct ptlrpc_request *req)
	req->rq_replay = 0;
	spin_unlock(&req->rq_lock);

	if (req->rq_commit_cb != NULL)
	if (req->rq_commit_cb)
		req->rq_commit_cb(req);
	list_del_init(&req->rq_replay_list);

@@ -2428,7 +2421,6 @@ void ptlrpc_free_committed(struct obd_import *imp)
	struct ptlrpc_request *last_req = NULL; /* temporary fire escape */
	bool skip_committed_list = true;

	LASSERT(imp != NULL);
	assert_spin_locked(&imp->imp_lock);

	if (imp->imp_peer_committed_transno == imp->imp_last_transno_checked &&
@@ -2612,11 +2604,11 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req)
	struct ptlrpc_request_set *set;
	int rc;

	LASSERT(req->rq_set == NULL);
	LASSERT(!req->rq_set);
	LASSERT(!req->rq_receiving_reply);

	set = ptlrpc_prep_set();
	if (set == NULL) {
	if (!set) {
		CERROR("Unable to allocate ptlrpc set.");
		return -ENOMEM;
	}
@@ -2848,8 +2840,6 @@ void ptlrpc_abort_set(struct ptlrpc_request_set *set)
{
	struct list_head *tmp, *pos;

	LASSERT(set != NULL);

	list_for_each_safe(pos, tmp, &set->set_requests) {
		struct ptlrpc_request *req =
			list_entry(pos, struct ptlrpc_request,
@@ -2995,7 +2985,6 @@ static int work_interpreter(const struct lu_env *env,
	struct ptlrpc_work_async_args *arg = data;

	LASSERT(ptlrpcd_check_work(req));
	LASSERT(arg->cb != NULL);

	rc = arg->cb(env, arg->cbdata);

@@ -3027,12 +3016,12 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,

	might_sleep();

	if (cb == NULL)
	if (!cb)
		return ERR_PTR(-EINVAL);

	/* copy some code from deprecated fakereq. */
	req = ptlrpc_request_cache_alloc(GFP_NOFS);
	if (req == NULL) {
	if (!req) {
		CERROR("ptlrpc: run out of memory!\n");
		return ERR_PTR(-ENOMEM);
	}
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ conn_keycmp(const void *key, struct hlist_node *hnode)
	struct ptlrpc_connection *conn;
	const lnet_process_id_t *conn_key;

	LASSERT(key != NULL);
	LASSERT(key);
	conn_key = key;
	conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);

+1 −1
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ void request_in_callback(lnet_event_t *ev)
			return;
		}
		req = ptlrpc_request_cache_alloc(GFP_ATOMIC);
		if (req == NULL) {
		if (!req) {
			CERROR("Can't allocate incoming request descriptor: Dropping %s RPC from %s\n",
			       service->srv_name,
			       libcfs_id2str(ev->initiator));
+4 −5
Original line number Diff line number Diff line
@@ -553,7 +553,6 @@ static int import_select_connection(struct obd_import *imp)
	imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);

	dlmexp = class_conn2export(&imp->imp_dlm_handle);
	LASSERT(dlmexp != NULL);
	ptlrpc_connection_put(dlmexp->exp_connection);
	dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
	class_export_put(dlmexp);
@@ -687,7 +686,7 @@ int ptlrpc_connect_import(struct obd_import *imp)
		goto out;

	request = ptlrpc_request_alloc(imp, &RQF_MDS_CONNECT);
	if (request == NULL) {
	if (!request) {
		rc = -ENOMEM;
		goto out;
	}
@@ -817,7 +816,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
	ocd = req_capsule_server_sized_get(&request->rq_pill,
					   &RMF_CONNECT_DATA, ret);

	if (ocd == NULL) {
	if (!ocd) {
		CERROR("%s: no connect data from server\n",
		       imp->imp_obd->obd_name);
		rc = -EPROTO;
@@ -1162,7 +1161,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
			struct obd_connect_data *ocd;

			/* reply message might not be ready */
			if (request->rq_repmsg == NULL)
			if (!request->rq_repmsg)
				return -EPROTO;

			ocd = req_capsule_server_get(&request->rq_pill,
@@ -1243,7 +1242,7 @@ static int signal_completed_replay(struct obd_import *imp)

	req = ptlrpc_request_alloc_pack(imp, &RQF_OBD_PING, LUSTRE_OBD_VERSION,
					OBD_PING);
	if (req == NULL) {
	if (!req) {
		atomic_dec(&imp->imp_replay_inflight);
		return -ENOMEM;
	}
+11 −15
Original line number Diff line number Diff line
@@ -1712,7 +1712,7 @@ void req_capsule_init(struct req_capsule *pill,
	 * high-priority RPC queue getting peeked at before ost_handle()
	 * handles an OST RPC.
	 */
	if (req != NULL && pill == &req->rq_pill && req->rq_pill_init)
	if (req && pill == &req->rq_pill && req->rq_pill_init)
		return;

	memset(pill, 0, sizeof(*pill));
@@ -1720,7 +1720,7 @@ void req_capsule_init(struct req_capsule *pill,
	pill->rc_loc = location;
	req_capsule_init_area(pill);

	if (req != NULL && pill == &req->rq_pill)
	if (req && pill == &req->rq_pill)
		req->rq_pill_init = 1;
}
EXPORT_SYMBOL(req_capsule_init);
@@ -1752,7 +1752,7 @@ static struct lustre_msg *__req_msg(const struct req_capsule *pill,
 */
void req_capsule_set(struct req_capsule *pill, const struct req_format *fmt)
{
	LASSERT(pill->rc_fmt == NULL || pill->rc_fmt == fmt);
	LASSERT(!pill->rc_fmt || pill->rc_fmt == fmt);
	LASSERT(__req_format_is_sane(fmt));

	pill->rc_fmt = fmt;
@@ -1773,8 +1773,6 @@ int req_capsule_filled_sizes(struct req_capsule *pill,
	const struct req_format *fmt = pill->rc_fmt;
	int i;

	LASSERT(fmt != NULL);

	for (i = 0; i < fmt->rf_fields[loc].nr; ++i) {
		if (pill->rc_area[loc][i] == -1) {
			pill->rc_area[loc][i] =
@@ -1810,7 +1808,7 @@ int req_capsule_server_pack(struct req_capsule *pill)

	LASSERT(pill->rc_loc == RCL_SERVER);
	fmt = pill->rc_fmt;
	LASSERT(fmt != NULL);
	LASSERT(fmt);

	count = req_capsule_filled_sizes(pill, RCL_SERVER);
	rc = lustre_pack_reply(pill->rc_req, count,
@@ -1865,7 +1863,7 @@ swabber_dumper_helper(struct req_capsule *pill,
	swabber = swabber ?: field->rmf_swabber;

	if (ptlrpc_buf_need_swab(pill->rc_req, inout, offset) &&
	    swabber != NULL && value != NULL)
	    swabber && value)
		do_swab = 1;
	else
		do_swab = 0;
@@ -1947,17 +1945,15 @@ static void *__req_capsule_get(struct req_capsule *pill,
		[RCL_SERVER] = "server"
	};

	LASSERT(pill != NULL);
	LASSERT(pill != LP_POISON);
	fmt = pill->rc_fmt;
	LASSERT(fmt != NULL);
	LASSERT(fmt);
	LASSERT(fmt != LP_POISON);
	LASSERT(__req_format_is_sane(fmt));

	offset = __req_capsule_offset(pill, field, loc);

	msg = __req_msg(pill, loc);
	LASSERT(msg != NULL);
	LASSERT(msg);

	getter = (field->rmf_flags & RMF_F_STRING) ?
		(typeof(getter))lustre_msg_string : lustre_msg_buf;
@@ -1980,7 +1976,7 @@ static void *__req_capsule_get(struct req_capsule *pill,
	}
	value = getter(msg, offset, len);

	if (value == NULL) {
	if (!value) {
		DEBUG_REQ(D_ERROR, pill->rc_req,
			  "Wrong buffer for field `%s' (%d of %d) in format `%s': %d vs. %d (%s)\n",
			  field->rmf_name, offset, lustre_msg_bufcount(msg),
@@ -2209,7 +2205,7 @@ void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt)

	const struct req_format *old;

	LASSERT(pill->rc_fmt != NULL);
	LASSERT(pill->rc_fmt);
	LASSERT(__req_format_is_sane(fmt));

	old = pill->rc_fmt;
@@ -2222,7 +2218,7 @@ void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt)
			const struct req_msg_field *ofield = FMT_FIELD(old, i, j);

			/* "opaque" fields can be transmogrified */
			if (ofield->rmf_swabber == NULL &&
			if (!ofield->rmf_swabber &&
			    (ofield->rmf_flags & ~RMF_F_NO_SIZE_CHECK) == 0 &&
			    (ofield->rmf_size == -1 ||
			    ofield->rmf_flags == RMF_F_NO_SIZE_CHECK))
@@ -2289,7 +2285,7 @@ void req_capsule_shrink(struct req_capsule *pill,
	int offset;

	fmt = pill->rc_fmt;
	LASSERT(fmt != NULL);
	LASSERT(fmt);
	LASSERT(__req_format_is_sane(fmt));
	LASSERT(req_capsule_has_field(pill, field, loc));
	LASSERT(req_capsule_field_present(pill, field, loc));
Loading