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;
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);
{
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));
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)
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);
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);
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
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);
{
int delay = 0;
- LASSERT(status != NULL);
*status = 0;
if (req->rq_ctx_init || req->rq_ctx_fini) {
__u32 opc;
int err;
- LASSERT(req->rq_reqmsg != NULL);
+ LASSERT(req->rq_reqmsg);
opc = lustre_msg_get_opc(req->rq_reqmsg);
/*
struct timespec64 work_start;
long timediff;
- LASSERT(obd != NULL);
+ LASSERT(obd);
/* repbuf must be unlinked */
LASSERT(!req->rq_receiving_reply && !req->rq_reply_unlink);
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);
/* 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
{
int remaining, rc;
- LASSERT(set->set_producer != NULL);
+ LASSERT(set->set_producer);
remaining = atomic_read(&set->set_remaining);
* 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;
}
}
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,
"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);
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;
}
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 =
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) {
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);
*/
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);
* 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);
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)
*/
static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked)
{
- if (request == NULL)
+ if (!request)
return 1;
if (request == LP_POISON ||
* 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;
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);
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 &&
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;
}
{
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,
struct ptlrpc_work_async_args *arg = data;
LASSERT(ptlrpcd_check_work(req));
- LASSERT(arg->cb != NULL);
rc = arg->cb(env, arg->cbdata);
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);
}
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);
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));
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);
goto out;
request = ptlrpc_request_alloc(imp, &RQF_MDS_CONNECT);
- if (request == NULL) {
+ if (!request) {
rc = -ENOMEM;
goto out;
}
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;
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,
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;
}
* 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));
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);
*/
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;
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] =
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,
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;
[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;
}
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),
const struct req_format *old;
- LASSERT(pill->rc_fmt != NULL);
+ LASSERT(pill->rc_fmt);
LASSERT(__req_format_is_sane(fmt));
old = pill->rc_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))
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));
LASSERT(lgh);
req = ptlrpc_request_alloc(imp, &RQF_LLOG_ORIGIN_HANDLE_CREATE);
- if (req == NULL) {
+ if (!req) {
rc = -ENOMEM;
goto out;
}
goto out;
body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
- if (body == NULL) {
+ if (!body) {
rc = -EFAULT;
goto out;
}
req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK,
LUSTRE_LOG_VERSION,
LLOG_ORIGIN_HANDLE_NEXT_BLOCK);
- if (req == NULL) {
+ if (!req) {
rc = -ENOMEM;
goto err_exit;
}
goto out;
body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
- if (body == NULL) {
+ if (!body) {
rc = -EFAULT;
goto out;
}
/* The log records are swabbed as they are processed */
ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
- if (ptr == NULL) {
+ if (!ptr) {
rc = -EFAULT;
goto out;
}
req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK,
LUSTRE_LOG_VERSION,
LLOG_ORIGIN_HANDLE_PREV_BLOCK);
- if (req == NULL) {
+ if (!req) {
rc = -ENOMEM;
goto err_exit;
}
goto out;
body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
- if (body == NULL) {
+ if (!body) {
rc = -EFAULT;
goto out;
}
ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
- if (ptr == NULL) {
+ if (!ptr) {
rc = -EFAULT;
goto out;
}
req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER,
LUSTRE_LOG_VERSION,
LLOG_ORIGIN_HANDLE_READ_HEADER);
- if (req == NULL) {
+ if (!req) {
rc = -ENOMEM;
goto err_exit;
}
goto out;
hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR);
- if (hdr == NULL) {
+ if (!hdr) {
rc = -EFAULT;
goto out;
}
LASSERT(ctxt);
new_imp = ctxt->loc_obd->u.cli.cl_import;
- LASSERTF(ctxt->loc_imp == NULL || ctxt->loc_imp == new_imp,
+ LASSERTF(!ctxt->loc_imp || ctxt->loc_imp == new_imp,
"%p - %p\n", ctxt->loc_imp, new_imp);
mutex_lock(&ctxt->loc_mutex);
if (ctxt->loc_imp != new_imp) {
unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX |
LPROCFS_CNTR_STDDEV;
- LASSERT(*debugfs_root_ret == NULL);
- LASSERT(*stats_ret == NULL);
+ LASSERT(!*debugfs_root_ret);
+ LASSERT(!*stats_ret);
svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES+LUSTRE_MAX_OPCODES,
0);
- if (svc_stats == NULL)
+ if (!svc_stats)
return;
- if (dir != NULL) {
+ if (dir) {
svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL);
if (IS_ERR(svc_debugfs_entry)) {
lprocfs_free_stats(&svc_stats);
rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats);
if (rc < 0) {
- if (dir != NULL)
+ if (dir)
ldebugfs_remove(&svc_debugfs_entry);
lprocfs_free_stats(&svc_stats);
} else {
- if (dir != NULL)
+ if (dir)
*debugfs_root_ret = svc_debugfs_entry;
*stats_ret = svc_stats;
}
static void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy,
struct ptlrpc_nrs_pol_info *info)
{
- LASSERT(policy != NULL);
- LASSERT(info != NULL);
assert_spin_locked(&policy->pol_nrs->nrs_lock);
memcpy(info->pi_name, policy->pol_desc->pd_name, NRS_POL_NAME_MAX);
spin_unlock(&nrs->nrs_lock);
infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS);
- if (infos == NULL) {
+ if (!infos) {
rc = -ENOMEM;
goto unlock;
}
/**
* No [reg|hp] token has been specified
*/
- if (cmd == NULL)
+ if (!cmd)
goto default_queue;
/**
struct list_head *e;
struct ptlrpc_request *req;
- if (srhi->srhi_req != NULL &&
- srhi->srhi_seq > svcpt->scp_hist_seq_culled &&
+ if (srhi->srhi_req && srhi->srhi_seq > svcpt->scp_hist_seq_culled &&
srhi->srhi_seq <= seq) {
/* If srhi_req was set previously, hasn't been culled and
* we're searching for a seq on or after it (i.e. more
(s64)req->rq_arrival_time.tv_sec,
(long)(req->rq_sent - req->rq_arrival_time.tv_sec),
(long)(req->rq_sent - req->rq_deadline));
- if (svc->srv_ops.so_req_printer == NULL)
+ if (!svc->srv_ops.so_req_printer)
seq_putc(s, '\n');
else
svc->srv_ops.so_req_printer(s, srhi->srhi_req);
"stats", &svc->srv_debugfs_entry,
&svc->srv_stats);
- if (svc->srv_debugfs_entry == NULL)
+ if (IS_ERR_OR_NULL(svc->srv_debugfs_entry))
return;
ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL);
int opc = opcode_offset(op);
svc_stats = req->rq_import->imp_obd->obd_svc_stats;
- if (svc_stats == NULL || opc <= 0)
+ if (!svc_stats || opc <= 0)
return;
LASSERT(opc < LUSTRE_MAX_OPCODES);
if (!(op == LDLM_ENQUEUE || op == MDS_REINT))
void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
{
- if (svc->srv_debugfs_entry != NULL)
+ if (!IS_ERR_OR_NULL(svc->srv_debugfs_entry))
ldebugfs_remove(&svc->srv_debugfs_entry);
if (svc->srv_stats)
req = ptlrpc_prep_ping(obd->u.cli.cl_import);
up_read(&obd->u.cli.cl_sem);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
req->rq_send_state = LUSTRE_IMP_FULL;
lnet_md_t md;
LASSERT(portal != 0);
- LASSERT(conn != NULL);
CDEBUG(D_INFO, "conn=%p id %s\n", conn, libcfs_id2str(conn->c_peer));
md.start = base;
md.length = len;
LASSERT(desc->bd_md_count == 0);
LASSERT(desc->bd_md_max_brw <= PTLRPC_BULK_OPS_COUNT);
LASSERT(desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES);
- LASSERT(desc->bd_req != NULL);
+ LASSERT(desc->bd_req);
LASSERT(desc->bd_type == BULK_PUT_SINK ||
desc->bd_type == BULK_GET_SOURCE);
if (async)
return 0;
- if (req->rq_set != NULL)
+ if (req->rq_set)
wq = &req->rq_set->set_waitq;
else
wq = &req->rq_reply_waitq;
req->rq_arrival_time.tv_sec, 1);
if (!(flags & PTLRPC_REPLY_EARLY) &&
- (req->rq_type != PTL_RPC_MSG_ERR) &&
- (req->rq_reqmsg != NULL) &&
+ (req->rq_type != PTL_RPC_MSG_ERR) && req->rq_reqmsg &&
!(lustre_msg_get_flags(req->rq_reqmsg) &
(MSG_RESENT | MSG_REPLAY |
MSG_REQ_REPLAY_DONE | MSG_LOCK_REPLAY_DONE))) {
* target_queue_final_reply().
*/
LASSERT(req->rq_no_reply == 0);
- LASSERT(req->rq_reqbuf != NULL);
- LASSERT(rs != NULL);
+ LASSERT(req->rq_reqbuf);
+ LASSERT(rs);
LASSERT((flags & PTLRPC_REPLY_MAYBE_DIFFICULT) || !rs->rs_difficult);
- LASSERT(req->rq_repmsg != NULL);
+ LASSERT(req->rq_repmsg);
LASSERT(req->rq_repmsg == rs->rs_msg);
LASSERT(rs->rs_cb_id.cbid_fn == reply_out_callback);
LASSERT(rs->rs_cb_id.cbid_arg == rs);
ptlrpc_at_set_reply(req, flags);
- if (req->rq_export == NULL || req->rq_export->exp_connection == NULL)
+ if (!req->rq_export || !req->rq_export->exp_connection)
conn = ptlrpc_connection_get(req->rq_peer, req->rq_self, NULL);
else
conn = ptlrpc_connection_addref(req->rq_export->exp_connection);
- if (unlikely(conn == NULL)) {
+ if (unlikely(!conn)) {
CERROR("not replying on NULL connection\n"); /* bug 9635 */
return -ENOTCONN;
}
LASSERT(!((lustre_msg_get_flags(request->rq_reqmsg) & MSG_REPLAY) &&
(request->rq_import->imp_state == LUSTRE_IMP_FULL)));
- if (unlikely(obd != NULL && obd->obd_fail)) {
+ if (unlikely(obd && obd->obd_fail)) {
CDEBUG(D_HA, "muting rpc for failed imp obd %s\n",
obd->obd_name);
/* this prevents us from waiting in ptlrpc_queue_wait */
goto out;
/* bulk register should be done after wrap_request() */
- if (request->rq_bulk != NULL) {
+ if (request->rq_bulk) {
rc = ptlrpc_register_bulk(request);
if (rc != 0)
goto out;
if (!noreply) {
LASSERT(request->rq_replen != 0);
- if (request->rq_repbuf == NULL) {
- LASSERT(request->rq_repdata == NULL);
- LASSERT(request->rq_repmsg == NULL);
+ if (!request->rq_repbuf) {
+ LASSERT(!request->rq_repdata);
+ LASSERT(!request->rq_repmsg);
rc = sptlrpc_cli_alloc_repbuf(request,
request->rq_replen);
if (rc) {
/* add references on request for request_out_callback */
ptlrpc_request_addref(request);
- if (obd != NULL && obd->obd_svc_stats != NULL)
+ if (obd && obd->obd_svc_stats)
lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQACTIVE_CNTR,
atomic_read(&request->rq_import->imp_inflight));
static int nrs_policy_init(struct ptlrpc_nrs_policy *policy)
{
- return policy->pol_desc->pd_ops->op_policy_init != NULL ?
+ return policy->pol_desc->pd_ops->op_policy_init ?
policy->pol_desc->pd_ops->op_policy_init(policy) : 0;
}
LASSERT(policy->pol_ref == 0);
LASSERT(policy->pol_req_queued == 0);
- if (policy->pol_desc->pd_ops->op_policy_fini != NULL)
+ if (policy->pol_desc->pd_ops->op_policy_fini)
policy->pol_desc->pd_ops->op_policy_fini(policy);
}
if (policy->pol_state == NRS_POL_STATE_STOPPED)
return -ENODEV;
- return policy->pol_desc->pd_ops->op_policy_ctl != NULL ?
+ return policy->pol_desc->pd_ops->op_policy_ctl ?
policy->pol_desc->pd_ops->op_policy_ctl(policy, opc, arg) :
-ENOSYS;
}
{
struct ptlrpc_nrs *nrs = policy->pol_nrs;
- if (policy->pol_desc->pd_ops->op_policy_stop != NULL) {
+ if (policy->pol_desc->pd_ops->op_policy_stop) {
spin_unlock(&nrs->nrs_lock);
policy->pol_desc->pd_ops->op_policy_stop(policy);
{
struct ptlrpc_nrs_policy *tmp = nrs->nrs_policy_primary;
- if (tmp == NULL)
+ if (!tmp)
return;
nrs->nrs_policy_primary = NULL;
* nrs_policy_flags::PTLRPC_NRS_FL_FALLBACK flag set can
* register with NRS core.
*/
- LASSERT(nrs->nrs_policy_fallback == NULL);
+ LASSERT(!nrs->nrs_policy_fallback);
} else {
/**
* Shouldn't start primary policy if w/o fallback policy.
*/
- if (nrs->nrs_policy_fallback == NULL)
+ if (!nrs->nrs_policy_fallback)
return -EPERM;
if (policy->pol_state == NRS_POL_STATE_STARTED)
{
struct ptlrpc_nrs_policy *policy = res->res_policy;
- if (policy->pol_desc->pd_ops->op_res_put != NULL) {
+ if (policy->pol_desc->pd_ops->op_res_put) {
struct ptlrpc_nrs_resource *parent;
- for (; res != NULL; res = parent) {
+ for (; res; res = parent) {
parent = res->res_parent;
policy->pol_desc->pd_ops->op_res_put(policy, res);
}
rc = policy->pol_desc->pd_ops->op_res_get(policy, nrq, res,
&tmp, moving_req);
if (rc < 0) {
- if (res != NULL)
+ if (res)
nrs_resource_put(res);
return NULL;
}
- LASSERT(tmp != NULL);
tmp->res_parent = res;
tmp->res_policy = policy;
res = tmp;
nrs_policy_get_locked(fallback);
primary = nrs->nrs_policy_primary;
- if (primary != NULL)
+ if (primary)
nrs_policy_get_locked(primary);
spin_unlock(&nrs->nrs_lock);
* Obtain resource hierarchy references.
*/
resp[NRS_RES_FALLBACK] = nrs_resource_get(fallback, nrq, moving_req);
- LASSERT(resp[NRS_RES_FALLBACK] != NULL);
+ LASSERT(resp[NRS_RES_FALLBACK]);
- if (primary != NULL) {
+ if (primary) {
resp[NRS_RES_PRIMARY] = nrs_resource_get(primary, nrq,
moving_req);
/**
* reference on the policy as it will not be used for this
* request.
*/
- if (resp[NRS_RES_PRIMARY] == NULL)
+ if (!resp[NRS_RES_PRIMARY])
nrs_policy_put(primary);
}
}
int i;
for (i = 0; i < NRS_RES_MAX; i++) {
- if (resp[i] != NULL) {
+ if (resp[i]) {
pols[i] = resp[i]->res_policy;
nrs_resource_put(resp[i]);
resp[i] = NULL;
nrq = policy->pol_desc->pd_ops->op_req_get(policy, peek, force);
- LASSERT(ergo(nrq != NULL, nrs_request_policy(nrq) == policy));
+ LASSERT(ergo(nrq, nrs_request_policy(nrq) == policy));
return nrq;
}
* the preferred choice.
*/
for (i = NRS_RES_MAX - 1; i >= 0; i--) {
- if (nrq->nr_res_ptrs[i] == NULL)
+ if (!nrq->nr_res_ptrs[i])
continue;
nrq->nr_res_idx = i;
spin_lock(&nrs->nrs_lock);
policy = nrs_policy_find_locked(nrs, name);
- if (policy == NULL) {
+ if (!policy) {
rc = -ENOENT;
goto out;
}
break;
}
out:
- if (policy != NULL)
+ if (policy)
nrs_policy_put_locked(policy);
spin_unlock(&nrs->nrs_lock);
spin_lock(&nrs->nrs_lock);
policy = nrs_policy_find_locked(nrs, name);
- if (policy == NULL) {
+ if (!policy) {
spin_unlock(&nrs->nrs_lock);
CERROR("Can't find NRS policy %s\n", name);
nrs_policy_fini(policy);
- LASSERT(policy->pol_private == NULL);
+ LASSERT(!policy->pol_private);
kfree(policy);
return 0;
struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt;
int rc;
- LASSERT(svcpt != NULL);
- LASSERT(desc->pd_ops != NULL);
- LASSERT(desc->pd_ops->op_res_get != NULL);
- LASSERT(desc->pd_ops->op_req_get != NULL);
- LASSERT(desc->pd_ops->op_req_enqueue != NULL);
- LASSERT(desc->pd_ops->op_req_dequeue != NULL);
- LASSERT(desc->pd_compat != NULL);
+ LASSERT(desc->pd_ops->op_res_get);
+ LASSERT(desc->pd_ops->op_req_get);
+ LASSERT(desc->pd_ops->op_req_enqueue);
+ LASSERT(desc->pd_ops->op_req_dequeue);
+ LASSERT(desc->pd_compat);
policy = kzalloc_node(sizeof(*policy), GFP_NOFS,
cfs_cpt_spread_node(svcpt->scp_service->srv_cptable,
svcpt->scp_cpt));
- if (policy == NULL)
+ if (!policy)
return -ENOMEM;
policy->pol_nrs = nrs;
spin_lock(&nrs->nrs_lock);
tmp = nrs_policy_find_locked(nrs, policy->pol_desc->pd_name);
- if (tmp != NULL) {
+ if (tmp) {
CERROR("NRS policy %s has been registered, can't register it for %s\n",
policy->pol_desc->pd_name,
svcpt->scp_service->srv_name);
/**
* Optionally allocate a high-priority NRS head.
*/
- if (svcpt->scp_service->srv_ops.so_hpreq_handler == NULL)
+ if (!svcpt->scp_service->srv_ops.so_hpreq_handler)
goto out;
svcpt->scp_nrs_hp =
kzalloc_node(sizeof(*svcpt->scp_nrs_hp), GFP_NOFS,
cfs_cpt_spread_node(svcpt->scp_service->srv_cptable,
svcpt->scp_cpt));
- if (svcpt->scp_nrs_hp == NULL) {
+ if (!svcpt->scp_nrs_hp) {
rc = -ENOMEM;
goto out;
}
}
}
- if (desc->pd_ops->op_lprocfs_fini != NULL)
+ if (desc->pd_ops->op_lprocfs_fini)
desc->pd_ops->op_lprocfs_fini(svc);
}
struct ptlrpc_nrs_pol_desc *desc;
int rc = 0;
- LASSERT(conf != NULL);
- LASSERT(conf->nc_ops != NULL);
- LASSERT(conf->nc_compat != NULL);
+ LASSERT(conf->nc_ops);
+ LASSERT(conf->nc_compat);
LASSERT(ergo(conf->nc_compat == nrs_policy_compat_one,
- conf->nc_compat_svc_name != NULL));
+ conf->nc_compat_svc_name));
LASSERT(ergo((conf->nc_flags & PTLRPC_NRS_FL_REG_EXTERN) != 0,
- conf->nc_owner != NULL));
+ conf->nc_owner));
conf->nc_name[NRS_POL_NAME_MAX - 1] = '\0';
mutex_lock(&nrs_core.nrs_mutex);
- if (nrs_policy_find_desc_locked(conf->nc_name) != NULL) {
+ if (nrs_policy_find_desc_locked(conf->nc_name)) {
CERROR("NRS: failing to register policy %s which has already been registered with NRS core!\n",
conf->nc_name);
rc = -EEXIST;
* No need to take a reference to other modules here, as we
* will be calling from the module's init() function.
*/
- if (desc->pd_ops->op_lprocfs_init != NULL) {
+ if (desc->pd_ops->op_lprocfs_init) {
rc = desc->pd_ops->op_lprocfs_init(svc);
if (rc != 0) {
rc2 = nrs_policy_unregister_locked(desc);
if (!nrs_policy_compatible(svc, desc))
continue;
- if (desc->pd_ops->op_lprocfs_init != NULL) {
+ if (desc->pd_ops->op_lprocfs_init) {
rc = desc->pd_ops->op_lprocfs_init(svc);
if (rc != 0)
goto failed;
if (!nrs_policy_compatible(svc, desc))
continue;
- if (desc->pd_ops->op_lprocfs_fini != NULL)
+ if (desc->pd_ops->op_lprocfs_fini)
desc->pd_ops->op_lprocfs_fini(svc);
}
list_for_each_entry(policy, &nrs->nrs_policy_queued,
pol_list_queued) {
nrq = nrs_request_get(policy, peek, force);
- if (nrq != NULL) {
+ if (nrq) {
if (likely(!peek)) {
nrq->nr_started = 1;
head = kzalloc_node(sizeof(*head), GFP_NOFS,
cfs_cpt_spread_node(nrs_pol2cptab(policy),
nrs_pol2cptid(policy)));
- if (head == NULL)
+ if (!head)
return -ENOMEM;
INIT_LIST_HEAD(&head->fh_list);
{
struct nrs_fifo_head *head = policy->pol_private;
- LASSERT(head != NULL);
+ LASSERT(head);
LASSERT(list_empty(&head->fh_list));
kfree(head);
list_entry(head->fh_list.next, struct ptlrpc_nrs_request,
nr_u.fifo.fr_list);
- if (likely(!peek && nrq != NULL)) {
+ if (likely(!peek && nrq)) {
struct ptlrpc_request *req = container_of(nrq,
struct ptlrpc_request,
rq_nrq);
for (i = 0; i < count; i++)
msg->lm_buflens[i] = lens[i];
- if (bufs == NULL)
+ if (!bufs)
return;
ptr = (char *)msg + lustre_msg_hdr_size_v2(count);
struct ptlrpc_reply_state *rs;
int msg_len, rc;
- LASSERT(req->rq_reply_state == NULL);
+ LASSERT(!req->rq_reply_state);
if ((flags & LPRFL_EARLY_REPLY) == 0) {
spin_lock(&req->rq_lock);
{
int i, offset, buflen, bufcount;
- LASSERT(m != NULL);
LASSERT(n >= 0);
bufcount = m->lm_bufcount;
LASSERT(!rs->rs_difficult || rs->rs_handled);
LASSERT(!rs->rs_on_net);
LASSERT(!rs->rs_scheduled);
- LASSERT(rs->rs_export == NULL);
+ LASSERT(!rs->rs_export);
LASSERT(rs->rs_nlocks == 0);
LASSERT(list_empty(&rs->rs_exp_list));
LASSERT(list_empty(&rs->rs_obd_list));
LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
}
- if (str == NULL) {
+ if (!str) {
CERROR("can't unpack string in msg %p buffer[%d]\n", m, index);
return NULL;
}
{
void *ptr = NULL;
- LASSERT(msg != NULL);
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2:
ptr = lustre_msg_buf_v2(msg, index, min_size);
sizeof(struct ptlrpc_body));
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
- if (jobid != NULL)
+ if (jobid)
memcpy(pb->pb_jobid, jobid, JOBSTATS_JOBID_SIZE);
else if (pb->pb_jobid[0] == '\0')
lustre_get_jobid(pb->pb_jobid);
int rc;
req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
struct ptlrpc_request *req;
req = ptlrpc_prep_ping(obd->u.cli.cl_import);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
req->rq_send_state = LUSTRE_IMP_FULL;
struct ptlrpc_request *req;
req = ptlrpc_prep_ping(imp);
- if (req == NULL) {
+ if (!req) {
CERROR("OOM trying to ping %s->%s\n",
imp->imp_obd->obd_uuid.uuid,
obd2cli_tgt(imp->imp_obd));
break;
}
}
- LASSERTF(ti != NULL, "ti is NULL !\n");
if (list_empty(&ti->ti_obd_list)) {
list_del(&ti->ti_chain);
kfree(ti);
{
struct ptlrpc_request_set *rq_set = req->rq_set;
- LASSERT(rq_set != NULL);
-
wake_up(&rq_set->set_waitq);
}
EXPORT_SYMBOL(ptlrpcd_wake);
int cpt;
int idx;
- if (req != NULL && req->rq_send_state != LUSTRE_IMP_FULL)
+ if (req && req->rq_send_state != LUSTRE_IMP_FULL)
return &ptlrpcd_rcv;
cpt = cfs_cpt_current(cfs_cpt_table, 1);
req->rq_invalid_rqset = 0;
spin_unlock(&req->rq_lock);
- l_wait_event(req->rq_set_waitq, (req->rq_set == NULL), &lwi);
+ l_wait_event(req->rq_set_waitq, !req->rq_set, &lwi);
} else if (req->rq_set) {
/* If we have a valid "rq_set", just reuse it to avoid double
* linked. */
partner = pc->pc_partners[pc->pc_cursor++];
if (pc->pc_cursor >= pc->pc_npartners)
pc->pc_cursor = 0;
- if (partner == NULL)
+ if (!partner)
continue;
spin_lock(&partner->pc_lock);
ps = partner->pc_set;
- if (ps == NULL) {
+ if (!ps) {
spin_unlock(&partner->pc_lock);
continue;
}
return 0;
out_set:
- if (pc->pc_set != NULL) {
+ if (pc->pc_set) {
struct ptlrpc_request_set *set = pc->pc_set;
spin_lock(&pc->pc_lock);
out:
if (pc->pc_npartners > 0) {
- LASSERT(pc->pc_partners != NULL);
+ LASSERT(pc->pc_partners);
kfree(pc->pc_partners);
pc->pc_partners = NULL;
int i;
int j;
- if (ptlrpcds != NULL) {
+ if (ptlrpcds) {
for (i = 0; i < ptlrpcds_num; i++) {
if (!ptlrpcds[i])
break;
/* All the requests in committed list have been replayed, let's replay
* the imp_replay_list */
- if (req == NULL) {
+ if (!req) {
list_for_each_safe(tmp, pos, &imp->imp_replay_list) {
req = list_entry(tmp, struct ptlrpc_request,
rq_replay_list);
* has occurred), then stop on the matching req and send it again.
* If, however, the last sent transno has been committed then we
* continue replay from the next request. */
- if (req != NULL && imp->imp_resend_replay)
+ if (req && imp->imp_resend_replay)
lustre_msg_add_flags(req->rq_reqmsg, MSG_RESENT);
spin_lock(&imp->imp_lock);
imp->imp_resend_replay = 0;
spin_unlock(&imp->imp_lock);
- if (req != NULL) {
+ if (req) {
rc = ptlrpc_replay_req(req);
if (rc) {
CERROR("recovery replay error %d for req %llu\n",
LASSERT(number < SPTLRPC_POLICY_MAX);
write_lock(&policy_lock);
- if (unlikely(policies[number] == NULL)) {
+ if (unlikely(!policies[number])) {
write_unlock(&policy_lock);
CERROR("%s: already unregistered\n", policy->sp_name);
return -EINVAL;
policy = policies[number];
if (policy && !try_module_get(policy->sp_owner))
policy = NULL;
- if (policy == NULL)
+ if (!policy)
flag = atomic_read(&loaded);
read_unlock(&policy_lock);
- if (policy != NULL || flag != 0 ||
+ if (policy || flag != 0 ||
number != SPTLRPC_POLICY_GSS)
break;
}
*sec = sptlrpc_import_sec_ref(imp);
- if (*sec == NULL) {
+ if (!*sec) {
CERROR("import %p (%s) with no sec\n",
imp, ptlrpc_import_state_name(imp->imp_state));
return -EACCES;
reqmsg_size = req->rq_reqlen;
if (reqmsg_size != 0) {
reqmsg = libcfs_kvzalloc(reqmsg_size, GFP_NOFS);
- if (reqmsg == NULL)
+ if (!reqmsg)
return -ENOMEM;
memcpy(reqmsg, req->rq_reqmsg, reqmsg_size);
}
LASSERT(ctx->cc_sec);
LASSERT(req->rq_repbuf);
LASSERT(req->rq_repdata);
- LASSERT(req->rq_repmsg == NULL);
+ LASSERT(!req->rq_repmsg);
req->rq_rep_swab_mask = 0;
int sptlrpc_cli_unwrap_reply(struct ptlrpc_request *req)
{
LASSERT(req->rq_repbuf);
- LASSERT(req->rq_repdata == NULL);
- LASSERT(req->rq_repmsg == NULL);
+ LASSERT(!req->rq_repdata);
+ LASSERT(!req->rq_repmsg);
LASSERT(req->rq_reply_off + req->rq_nob_received <= req->rq_repbuf_len);
if (req->rq_reply_off == 0 &&
int rc;
early_req = ptlrpc_request_cache_alloc(GFP_NOFS);
- if (early_req == NULL)
+ if (!early_req)
return -ENOMEM;
early_size = req->rq_nob_received;
early_bufsz = size_roundup_power2(early_size);
early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS);
- if (early_buf == NULL) {
+ if (!early_buf) {
rc = -ENOMEM;
goto err_req;
}
}
LASSERT(req->rq_repbuf);
- LASSERT(req->rq_repdata == NULL);
- LASSERT(req->rq_repmsg == NULL);
+ LASSERT(!req->rq_repdata);
+ LASSERT(!req->rq_repmsg);
if (req->rq_reply_off != 0) {
CERROR("early reply with offset %u\n", req->rq_reply_off);
might_sleep();
- if (imp == NULL)
+ if (!imp)
return 0;
conn = imp->imp_connection;
- if (svc_ctx == NULL) {
+ if (!svc_ctx) {
struct client_obd *cliobd = &imp->imp_obd->u.cli;
/*
* normal import, determine flavor from rule set, except
{
struct ptlrpc_sec *sec;
- if (imp == NULL)
+ if (!imp)
return;
sec = sptlrpc_import_sec_ref(imp);
- if (sec == NULL)
+ if (!sec)
return;
sec_cop_flush_ctx_cache(sec, uid, grace, force);
LASSERT(ctx);
LASSERT(ctx->cc_sec);
LASSERT(ctx->cc_sec->ps_policy);
- LASSERT(req->rq_reqmsg == NULL);
+ LASSERT(!req->rq_reqmsg);
LASSERT_ATOMIC_POS(&ctx->cc_refcount);
policy = ctx->cc_sec->ps_policy;
LASSERT(ctx->cc_sec->ps_policy);
LASSERT_ATOMIC_POS(&ctx->cc_refcount);
- if (req->rq_reqbuf == NULL && req->rq_clrbuf == NULL)
+ if (!req->rq_reqbuf && !req->rq_clrbuf)
return;
policy = ctx->cc_sec->ps_policy;
LASSERT(ctx->cc_sec->ps_policy);
LASSERT_ATOMIC_POS(&ctx->cc_refcount);
- if (req->rq_repbuf == NULL)
+ if (!req->rq_repbuf)
return;
LASSERT(req->rq_repbuf_len);
{
struct sptlrpc_flavor flavor;
- if (exp == NULL)
+ if (!exp)
return 0;
/* client side export has no imp_reverse, skip
* FIXME maybe we should check flavor this as well??? */
- if (exp->exp_imp_reverse == NULL)
+ if (!exp->exp_imp_reverse)
return 0;
/* don't care about ctx fini rpc */
int rc;
LASSERT(msg);
- LASSERT(req->rq_reqmsg == NULL);
- LASSERT(req->rq_repmsg == NULL);
- LASSERT(req->rq_svc_ctx == NULL);
+ LASSERT(!req->rq_reqmsg);
+ LASSERT(!req->rq_repmsg);
+ LASSERT(!req->rq_svc_ctx);
req->rq_req_swab_mask = 0;
/* failed alloc, try emergency pool */
rs = lustre_get_emerg_rs(svcpt);
- if (rs == NULL)
+ if (!rs)
return -ENOMEM;
req->rq_reply_state = rs;
{
struct ptlrpc_svc_ctx *ctx = req->rq_svc_ctx;
- if (ctx != NULL)
+ if (ctx)
atomic_inc(&ctx->sc_refcount);
}
{
struct ptlrpc_svc_ctx *ctx = req->rq_svc_ctx;
- if (ctx == NULL)
+ if (!ctx)
return;
LASSERT_ATOMIC_POS(&ctx->sc_refcount);
while (npages--) {
LASSERT(page_pools.epp_pools[p_idx]);
- LASSERT(page_pools.epp_pools[p_idx][g_idx] != NULL);
+ LASSERT(page_pools.epp_pools[p_idx][g_idx]);
__free_page(page_pools.epp_pools[p_idx][g_idx]);
page_pools.epp_pools[p_idx][g_idx] = NULL;
int p_idx, g_idx;
int i;
- if (desc->bd_enc_iov == NULL)
+ if (!desc->bd_enc_iov)
return;
LASSERT(desc->bd_iov_count > 0);
LASSERT(page_pools.epp_pools[p_idx]);
for (i = 0; i < desc->bd_iov_count; i++) {
- LASSERT(desc->bd_enc_iov[i].kiov_page != NULL);
+ LASSERT(desc->bd_enc_iov[i].kiov_page);
LASSERT(g_idx != 0 || page_pools.epp_pools[p_idx]);
- LASSERT(page_pools.epp_pools[p_idx][g_idx] == NULL);
+ LASSERT(!page_pools.epp_pools[p_idx][g_idx]);
page_pools.epp_pools[p_idx][g_idx] =
desc->bd_enc_iov[i].kiov_page;
page_pools.epp_st_max_wait = 0;
enc_pools_alloc();
- if (page_pools.epp_pools == NULL)
+ if (!page_pools.epp_pools)
return -ENOMEM;
register_shrinker(&pools_shrinker);
int size = msg->lm_buflens[offset];
bsd = lustre_msg_buf(msg, offset, sizeof(*bsd));
- if (bsd == NULL) {
+ if (!bsd) {
CERROR("Invalid bulk sec desc: size %d\n", size);
return -EINVAL;
}
memset(flvr, 0, sizeof(*flvr));
- if (str == NULL || str[0] == '\0') {
+ if (!str || str[0] == '\0') {
flvr->sf_rpc = SPTLRPC_FLVR_INVALID;
return 0;
}
* format: plain-hash:<hash_alg>
*/
alg = strchr(bulk, ':');
- if (alg == NULL)
+ if (!alg)
goto err_out;
*alg++ = '\0';
sptlrpc_rule_init(rule);
flavor = strchr(param, '=');
- if (flavor == NULL) {
+ if (!flavor) {
CERROR("invalid param, no '='\n");
return -EINVAL;
}
static void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset)
{
LASSERT(rset->srs_nslot ||
- (rset->srs_nrule == 0 && rset->srs_rules == NULL));
+ (rset->srs_nrule == 0 && !rset->srs_rules));
if (rset->srs_nslot) {
kfree(rset->srs_rules);
/* better use realloc() if available */
rules = kcalloc(nslot, sizeof(*rset->srs_rules), GFP_NOFS);
- if (rules == NULL)
+ if (!rules)
return -ENOMEM;
if (rset->srs_nrule) {
}
/* if we didn't find the pattern, treat the whole string as fsname */
- if (ptr == NULL)
+ if (!ptr)
len = strlen(tgt);
else
len = ptr - tgt;
int rc;
target = lustre_cfg_string(lcfg, 1);
- if (target == NULL) {
+ if (!target) {
CERROR("missing target name\n");
return -EINVAL;
}
param = lustre_cfg_string(lcfg, 2);
- if (param == NULL) {
+ if (!param) {
CERROR("missing parameter\n");
return -EINVAL;
}
if (rc)
return -EINVAL;
- if (conf == NULL) {
+ if (!conf) {
target2fsname(target, fsname, sizeof(fsname));
mutex_lock(&sptlrpc_conf_lock);
conf = sptlrpc_conf_get(fsname, 0);
- if (conf == NULL) {
+ if (!conf) {
CERROR("can't find conf\n");
rc = -ENOMEM;
} else {
int len;
ptr = strrchr(logname, '-');
- if (ptr == NULL || strcmp(ptr, "-sptlrpc")) {
+ if (!ptr || strcmp(ptr, "-sptlrpc")) {
CERROR("%s is not a sptlrpc config log\n", logname);
return -EINVAL;
}
mutex_lock(&sptlrpc_conf_lock);
conf = sptlrpc_conf_get(name, 0);
- if (conf == NULL)
+ if (!conf)
goto out;
/* convert uuid name (supposed end with _UUID) to target name */
if (cli->cl_import)
sec = sptlrpc_import_sec_ref(cli->cl_import);
- if (sec == NULL)
+ if (!sec)
goto out;
sec_flags2str(sec->ps_flvr.sf_flags, str, sizeof(str));
if (cli->cl_import)
sec = sptlrpc_import_sec_ref(cli->cl_import);
- if (sec == NULL)
+ if (!sec)
goto out;
if (sec->ps_policy->sp_cops->display)
{
int rc;
- LASSERT(sptlrpc_debugfs_dir == NULL);
+ LASSERT(!sptlrpc_debugfs_dir);
sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root,
sptlrpc_lprocfs_vars, NULL);
alloc_size = size_roundup_power2(newmsg_size);
newbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS);
- if (newbuf == NULL)
+ if (!newbuf)
return -ENOMEM;
/* Must lock this, so that otherwise unprotected change of
LASSERT(rs->rs_size >= rs_size);
} else {
rs = libcfs_kvzalloc(rs_size, GFP_NOFS);
- if (rs == NULL)
+ if (!rs)
return -ENOMEM;
rs->rs_size = rs_size;
return -EPROTO;
bsd = lustre_msg_buf(msg, PLAIN_PACK_BULK_OFF, PLAIN_BSD_SIZE);
- if (bsd == NULL) {
+ if (!bsd) {
CERROR("bulk sec desc has short size %d\n",
lustre_msg_buflen(msg, PLAIN_PACK_BULK_OFF));
return -EPROTO;
swabbed = ptlrpc_rep_need_swab(req);
phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr));
- if (phdr == NULL) {
+ if (!phdr) {
CERROR("missing plain header\n");
return -EPROTO;
}
LASSERT(sec->ps_import);
LASSERT(atomic_read(&sec->ps_refcount) == 0);
LASSERT(atomic_read(&sec->ps_nctx) == 0);
- LASSERT(plsec->pls_ctx == NULL);
+ LASSERT(!plsec->pls_ctx);
class_import_put(sec->ps_import);
/* install ctx immediately if this is a reverse sec */
if (svc_ctx) {
ctx = plain_sec_install_ctx(plsec);
- if (ctx == NULL) {
+ if (!ctx) {
plain_destroy_sec(sec);
return NULL;
}
atomic_inc(&ctx->cc_refcount);
read_unlock(&plsec->pls_lock);
- if (unlikely(ctx == NULL))
+ if (unlikely(!ctx))
ctx = plain_sec_install_ctx(plsec);
return ctx;
newbuf_size = size_roundup_power2(newbuf_size);
newbuf = libcfs_kvzalloc(newbuf_size, GFP_NOFS);
- if (newbuf == NULL)
+ if (!newbuf)
return -ENOMEM;
/* Must lock this, so that otherwise unprotected change of
swabbed = ptlrpc_req_need_swab(req);
phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr));
- if (phdr == NULL) {
+ if (!phdr) {
CERROR("missing plain header\n");
return -EPROTO;
}
LASSERT(rs->rs_size >= rs_size);
} else {
rs = libcfs_kvzalloc(rs_size, GFP_NOFS);
- if (rs == NULL)
+ if (!rs)
return -ENOMEM;
rs->rs_size = rs_size;
rqbd = kzalloc_node(sizeof(*rqbd), GFP_NOFS,
cfs_cpt_spread_node(svc->srv_cptable,
svcpt->scp_cpt));
- if (rqbd == NULL)
+ if (!rqbd)
return NULL;
rqbd->rqbd_svcpt = svcpt;
svcpt->scp_cpt,
svc->srv_buf_size,
GFP_KERNEL);
- if (rqbd->rqbd_buffer == NULL) {
+ if (!rqbd->rqbd_buffer) {
kfree(rqbd);
return NULL;
}
rqbd = ptlrpc_alloc_rqbd(svcpt);
- if (rqbd == NULL) {
+ if (!rqbd) {
CERROR("%s: Can't allocate request buffer\n",
svc->srv_name);
rc = -ENOMEM;
array->paa_reqs_array =
kzalloc_node(sizeof(struct list_head) * size, GFP_NOFS,
cfs_cpt_spread_node(svc->srv_cptable, cpt));
- if (array->paa_reqs_array == NULL)
+ if (!array->paa_reqs_array)
return -ENOMEM;
for (index = 0; index < size; index++)
array->paa_reqs_count =
kzalloc_node(sizeof(__u32) * size, GFP_NOFS,
cfs_cpt_spread_node(svc->srv_cptable, cpt));
- if (array->paa_reqs_count == NULL)
+ if (!array->paa_reqs_count)
goto free_reqs_array;
setup_timer(&svcpt->scp_at_timer, ptlrpc_at_timer,
LASSERT(conf->psc_thr.tc_ctx_tags != 0);
cptable = cconf->cc_cptable;
- if (cptable == NULL)
+ if (!cptable)
cptable = cfs_cpt_table;
if (!conf->psc_thr.tc_cpu_affinity) {
ncpts = 1;
} else {
ncpts = cfs_cpt_number(cptable);
- if (cconf->cc_pattern != NULL) {
+ if (cconf->cc_pattern) {
struct cfs_expr_list *el;
rc = cfs_expr_list_parse(cconf->cc_pattern,
if (!conf->psc_thr.tc_cpu_affinity)
cpt = CFS_CPT_ANY;
else
- cpt = cpts != NULL ? cpts[i] : i;
+ cpt = cpts ? cpts[i] : i;
svcpt = kzalloc_node(sizeof(*svcpt), GFP_NOFS,
cfs_cpt_spread_node(cptable, cpt));
- if (svcpt == NULL) {
+ if (!svcpt) {
rc = -ENOMEM;
goto failed;
}
ptlrpc_nrs_req_finalize(req);
- if (req->rq_export != NULL)
+ if (req->rq_export)
class_export_rpc_dec(req->rq_export);
ptlrpc_server_finish_request(svcpt, req);
req->rq_export->exp_conn_cnt);
return -EEXIST;
}
- if (unlikely(obd == NULL || obd->obd_fail)) {
+ if (unlikely(!obd || obd->obd_fail)) {
/*
* Failing over, don't handle any more reqs, send
* error response instead.
*/
CDEBUG(D_RPCTRACE, "Dropping req %p for failed obd %s\n",
- req, (obd != NULL) ? obd->obd_name : "unknown");
+ req, obd ? obd->obd_name : "unknown");
rc = -ENODEV;
} else if (lustre_msg_get_flags(req->rq_reqmsg) &
(MSG_REPLAY | MSG_REQ_REPLAY_DONE)) {
newdl = ktime_get_real_seconds() + at_get(&svcpt->scp_at_estimate);
reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS);
- if (reqcopy == NULL)
+ if (!reqcopy)
return -ENOMEM;
reqmsg = libcfs_kvzalloc(req->rq_reqlen, GFP_NOFS);
if (!reqmsg) {
/* Connection ref */
reqcopy->rq_export = class_conn2export(
lustre_msg_get_handle(reqcopy->rq_reqmsg));
- if (reqcopy->rq_export == NULL) {
+ if (!reqcopy->rq_export) {
rc = -ENODEV;
goto out;
}
CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CANCEL_RESEND))) {
/* leave just 1 thread for normal RPCs */
running = PTLRPC_NTHRS_INIT;
- if (svcpt->scp_service->srv_ops.so_hpreq_handler != NULL)
+ if (svcpt->scp_service->srv_ops.so_hpreq_handler)
running += 1;
}
CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CANCEL_RESEND))) {
/* leave just 1 thread for normal RPCs */
running = PTLRPC_NTHRS_INIT;
- if (svcpt->scp_service->srv_ops.so_hpreq_handler != NULL)
+ if (svcpt->scp_service->srv_ops.so_hpreq_handler)
running += 1;
}
if (ptlrpc_server_high_pending(svcpt, force)) {
req = ptlrpc_nrs_req_get_nolock(svcpt, true, force);
- if (req != NULL) {
+ if (req) {
svcpt->scp_hreq_count++;
goto got_request;
}
if (ptlrpc_server_normal_pending(svcpt, force)) {
req = ptlrpc_nrs_req_get_nolock(svcpt, false, force);
- if (req != NULL) {
+ if (req) {
svcpt->scp_hreq_count = 0;
goto got_request;
}
int fail_opc = 0;
request = ptlrpc_server_request_get(svcpt, false);
- if (request == NULL)
+ if (!request)
return 0;
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT))
timediff = timespec64_sub(work_start, request->rq_arrival_time);
timediff_usecs = timediff.tv_sec * USEC_PER_SEC +
timediff.tv_nsec / NSEC_PER_USEC;
- if (likely(svc->srv_stats != NULL)) {
+ if (likely(svc->srv_stats)) {
lprocfs_counter_add(svc->srv_stats, PTLRPC_REQWAIT_CNTR,
timediff_usecs);
lprocfs_counter_add(svc->srv_stats, PTLRPC_REQQDEPTH_CNTR,
request->rq_status,
(request->rq_repmsg ?
lustre_msg_get_status(request->rq_repmsg) : -999));
- if (likely(svc->srv_stats != NULL && request->rq_reqmsg != NULL)) {
+ if (likely(svc->srv_stats && request->rq_reqmsg)) {
__u32 op = lustre_msg_get_opc(request->rq_reqmsg);
int opc = opcode_offset(op);
set_current_groups(ginfo);
put_group_info(ginfo);
- if (svc->srv_ops.so_thr_init != NULL) {
+ if (svc->srv_ops.so_thr_init) {
rc = svc->srv_ops.so_thr_init(thread);
if (rc)
goto out;
/*
* deconstruct service specific state created by ptlrpc_start_thread()
*/
- if (svc->srv_ops.so_thr_done != NULL)
+ if (svc->srv_ops.so_thr_done)
svc->srv_ops.so_thr_done(thread);
- if (env != NULL) {
+ if (env) {
lu_context_fini(&env->le_ctx);
kfree(env);
}
ptlrpc_hr.hr_stopping = 1;
cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
- if (hrp->hrp_thrs == NULL)
+ if (!hrp->hrp_thrs)
continue; /* uninitialized */
for (j = 0; j < hrp->hrp_nthrs; j++)
wake_up_all(&hrp->hrp_thrs[j].hrt_waitq);
}
cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
- if (hrp->hrp_thrs == NULL)
+ if (!hrp->hrp_thrs)
continue; /* uninitialized */
wait_event(ptlrpc_hr.hr_waitq,
atomic_read(&hrp->hrp_nstopped) ==
int i;
ptlrpc_service_for_each_part(svcpt, i, svc) {
- if (svcpt->scp_service != NULL)
+ if (svcpt->scp_service)
ptlrpc_svcpt_stop_threads(svcpt);
}
}
struct task_struct *task;
int rc;
- LASSERT(svcpt != NULL);
-
svc = svcpt->scp_service;
CDEBUG(D_RPCTRACE, "%s[%d] started %d min %d max %d\n",
thread = kzalloc_node(sizeof(*thread), GFP_NOFS,
cfs_cpt_spread_node(svc->srv_cptable,
svcpt->scp_cpt));
- if (thread == NULL)
+ if (!thread)
return -ENOMEM;
init_waitqueue_head(&thread->t_ctl_waitq);
ptlrpc_hr.hr_partitions = cfs_percpt_alloc(ptlrpc_hr.hr_cpt_table,
sizeof(*hrp));
- if (ptlrpc_hr.hr_partitions == NULL)
+ if (!ptlrpc_hr.hr_partitions)
return -ENOMEM;
init_waitqueue_head(&ptlrpc_hr.hr_waitq);
kzalloc_node(hrp->hrp_nthrs * sizeof(*hrt), GFP_NOFS,
cfs_cpt_spread_node(ptlrpc_hr.hr_cpt_table,
i));
- if (hrp->hrp_thrs == NULL) {
+ if (!hrp->hrp_thrs) {
rc = -ENOMEM;
goto out;
}
struct ptlrpc_hr_partition *hrp;
int i;
- if (ptlrpc_hr.hr_partitions == NULL)
+ if (!ptlrpc_hr.hr_partitions)
return;
ptlrpc_stop_hr_threads();
/* early disarm AT timer... */
ptlrpc_service_for_each_part(svcpt, i, svc) {
- if (svcpt->scp_service != NULL)
+ if (svcpt->scp_service)
del_timer(&svcpt->scp_at_timer);
}
}
LASSERT(rc == 0);
ptlrpc_service_for_each_part(svcpt, i, svc) {
- if (svcpt->scp_service == NULL)
+ if (!svcpt->scp_service)
break;
/* Unlink all the request buffers. This forces a 'final'
}
ptlrpc_service_for_each_part(svcpt, i, svc) {
- if (svcpt->scp_service == NULL)
+ if (!svcpt->scp_service)
break;
/* Wait for the network to release any buffers
int i;
ptlrpc_service_for_each_part(svcpt, i, svc) {
- if (svcpt->scp_service == NULL)
+ if (!svcpt->scp_service)
break;
spin_lock(&svcpt->scp_rep_lock);
int i;
ptlrpc_service_for_each_part(svcpt, i, svc) {
- if (svcpt->scp_service == NULL)
+ if (!svcpt->scp_service)
break;
/* In case somebody rearmed this in the meantime */
ptlrpc_service_for_each_part(svcpt, i, svc)
kfree(svcpt);
- if (svc->srv_cpts != NULL)
+ if (svc->srv_cpts)
cfs_expr_list_values_free(svc->srv_cpts, svc->srv_ncpts);
kfree(svc);