diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-06-10 05:30:17 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-06-10 05:30:17 -0300 |
commit | d635711daa98be86d4c7fd01499c34f566b54ccb (patch) | |
tree | aa5cc3760a27c3d57146498cb82fa549547de06c /drivers/staging/lustre/lustre/ptlrpc | |
parent | c91265cd0efb83778f015b4d4b1129bd2cfd075e (diff) |
Linux-libre 4.6.2-gnu
Diffstat (limited to 'drivers/staging/lustre/lustre/ptlrpc')
26 files changed, 722 insertions, 1079 deletions
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index efdda0950..cf3ac8eee 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -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,15 +171,15 @@ 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); + LASSERT(pageoffset + len <= PAGE_SIZE); desc->bd_nob += len; if (pin) - page_cache_get(page); + get_page(page); ptlrpc_add_bulk_page(desc, page, pageoffset, len); } @@ -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)); @@ -207,7 +206,7 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) if (unpin) { for (i = 0; i < desc->bd_iov_count; i++) - page_cache_release(desc->bd_iov[i].kiov_page); + put_page(desc->bd_iov[i].kiov_page); } kfree(desc); @@ -353,6 +352,7 @@ static int unpack_reply(struct ptlrpc_request *req) * If anything goes wrong just ignore it - same as if it never happened */ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) + __must_hold(&req->rq_lock) { struct ptlrpc_request *early_req; time64_t olddl; @@ -411,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) @@ -423,7 +423,7 @@ struct ptlrpc_request *ptlrpc_request_cache_alloc(gfp_t flags) { struct ptlrpc_request *req; - req = kmem_cache_alloc(request_cache, flags | __GFP_ZERO); + req = kmem_cache_zalloc(request_cache, flags); return req; } @@ -441,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); @@ -559,7 +557,7 @@ ptlrpc_prep_req_from_pool(struct ptlrpc_request_pool *pool) } request = list_entry(pool->prp_req_list.next, struct ptlrpc_request, - rq_list); + rq_list); list_del_init(&request->rq_list); spin_unlock(&pool->prp_lock); @@ -724,10 +722,10 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp, request = ptlrpc_prep_req_from_pool(pool); if (request) { - LASSERTF((unsigned long)imp > 0x1000, "%p", imp); + LASSERTF((unsigned long)imp > 0x1000, "%p\n", imp); LASSERT(imp != LP_POISON); - LASSERTF((unsigned long)imp->imp_client > 0x1000, "%p", - imp->imp_client); + LASSERTF((unsigned long)imp->imp_client > 0x1000, "%p\n", + imp->imp_client); LASSERT(imp->imp_client != LP_POISON); request->rq_import = class_import_get(imp); @@ -752,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); @@ -898,8 +896,7 @@ void ptlrpc_set_destroy(struct ptlrpc_request_set *set) RQ_PHASE_COMPLETE : RQ_PHASE_NEW; list_for_each(tmp, &set->set_requests) { struct ptlrpc_request *req = - list_entry(tmp, struct ptlrpc_request, - rq_set_chain); + list_entry(tmp, struct ptlrpc_request, rq_set_chain); LASSERT(req->rq_phase == expected_phase); n++; @@ -911,8 +908,7 @@ void ptlrpc_set_destroy(struct ptlrpc_request_set *set) list_for_each_safe(tmp, next, &set->set_requests) { struct ptlrpc_request *req = - list_entry(tmp, struct ptlrpc_request, - rq_set_chain); + list_entry(tmp, struct ptlrpc_request, rq_set_chain); list_del_init(&req->rq_set_chain); LASSERT(req->rq_phase == expected_phase); @@ -951,10 +947,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 @@ -974,7 +970,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); @@ -1015,7 +1011,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) { @@ -1078,7 +1073,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); /* @@ -1167,7 +1162,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); @@ -1247,7 +1242,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); @@ -1310,7 +1305,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 @@ -1334,8 +1329,8 @@ static int after_reply(struct ptlrpc_request *req) struct ptlrpc_request *last; last = list_entry(imp->imp_replay_list.prev, - struct ptlrpc_request, - rq_replay_list); + struct ptlrpc_request, + rq_replay_list); /* * Requests with rq_replay stay on the list even if no * commit is expected. @@ -1437,7 +1432,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); @@ -1478,8 +1473,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) INIT_LIST_HEAD(&comp_reqs); list_for_each_safe(tmp, next, &set->set_requests) { struct ptlrpc_request *req = - list_entry(tmp, struct ptlrpc_request, - rq_set_chain); + list_entry(tmp, struct ptlrpc_request, rq_set_chain); struct obd_import *imp = req->rq_import; int unregistered = 0; int rc = 0; @@ -1621,8 +1615,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) */ list_del_init(&req->rq_list); list_add_tail(&req->rq_list, - &imp-> - imp_delayed_list); + &imp->imp_delayed_list); spin_unlock(&imp->imp_lock); continue; } @@ -1630,7 +1623,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) if (status != 0) { req->rq_status = status; ptlrpc_rqphase_move(req, - RQ_PHASE_INTERPRET); + RQ_PHASE_INTERPRET); spin_unlock(&imp->imp_lock); goto interpret; } @@ -1645,7 +1638,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) list_del_init(&req->rq_list); list_add_tail(&req->rq_list, - &imp->imp_sending_list); + &imp->imp_sending_list); spin_unlock(&imp->imp_lock); @@ -1750,7 +1743,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; } @@ -1802,7 +1795,7 @@ 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, @@ -1882,8 +1875,8 @@ 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) - LNetCtl(IOC_LIBCFS_DEBUG_PEER, &imp->imp_connection->c_peer); + if (imp && obd_debug_peer_on_timeout) + LNetDebugPeer(imp->imp_connection->c_peer); ptlrpc_unregister_reply(req, async_unlink); ptlrpc_unregister_bulk(req, async_unlink); @@ -1891,7 +1884,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; } @@ -1944,13 +1937,10 @@ 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 = - list_entry(tmp, struct ptlrpc_request, - rq_set_chain); + list_entry(tmp, struct ptlrpc_request, rq_set_chain); /* don't expire request waiting for context */ if (req->rq_wait_ctx) @@ -2002,13 +1992,11 @@ 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) { struct ptlrpc_request *req = - list_entry(tmp, struct ptlrpc_request, - rq_set_chain); + list_entry(tmp, struct ptlrpc_request, rq_set_chain); if (req->rq_phase != RQ_PHASE_RPC && req->rq_phase != RQ_PHASE_UNREGISTERING) @@ -2081,7 +2069,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) else list_for_each(tmp, &set->set_requests) { req = list_entry(tmp, struct ptlrpc_request, - rq_set_chain); + rq_set_chain); if (req->rq_phase == RQ_PHASE_NEW) (void)ptlrpc_send_new_req(req); } @@ -2155,7 +2143,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) if (rc == 0 && atomic_read(&set->set_remaining) == 0) { list_for_each(tmp, &set->set_requests) { req = list_entry(tmp, struct ptlrpc_request, - rq_set_chain); + rq_set_chain); spin_lock(&req->rq_lock); req->rq_invalid_rqset = 1; spin_unlock(&req->rq_lock); @@ -2174,7 +2162,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); @@ -2206,10 +2194,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); @@ -2221,7 +2209,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); @@ -2236,20 +2224,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) @@ -2269,7 +2257,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 || @@ -2351,7 +2339,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; @@ -2386,7 +2374,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); @@ -2427,7 +2415,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 && @@ -2575,8 +2562,7 @@ void ptlrpc_retain_replayable_request(struct ptlrpc_request *req, ptlrpc_request_addref(req); list_for_each_prev(tmp, &imp->imp_replay_list) { struct ptlrpc_request *iter = - list_entry(tmp, struct ptlrpc_request, - rq_replay_list); + list_entry(tmp, struct ptlrpc_request, rq_replay_list); /* * We may have duplicate transnos if we create and then @@ -2611,12 +2597,12 @@ 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) { - CERROR("Unable to allocate ptlrpc set."); + if (!set) { + CERROR("cannot allocate ptlrpc set: rc = %d\n", -ENOMEM); return -ENOMEM; } @@ -2847,12 +2833,9 @@ 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, - rq_set_chain); + list_entry(pos, struct ptlrpc_request, rq_set_chain); spin_lock(&req->rq_lock); if (req->rq_phase != RQ_PHASE_RPC) { @@ -2994,7 +2977,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); @@ -3026,12 +3008,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); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index da1f0b1ac..a14daff3f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -72,7 +72,8 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, * returned and may be compared against out object. */ /* In the function below, .hs_keycmp resolves to - * conn_keycmp() */ + * conn_keycmp() + */ /* coverity[overrun-buffer-val] */ conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash); if (conn != conn2) { @@ -172,7 +173,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); diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 990156986..47be21ac9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -71,7 +71,8 @@ void request_out_callback(lnet_event_t *ev) if (ev->type == LNET_EVENT_UNLINK || ev->status != 0) { /* Failed send: make it seem like the reply timed out, just - * like failing sends in client.c does currently... */ + * like failing sends in client.c does currently... + */ req->rq_net_err = 1; ptlrpc_client_wake_req(req); @@ -95,7 +96,8 @@ void reply_in_callback(lnet_event_t *ev) LASSERT(ev->md.start == req->rq_repbuf); LASSERT(ev->offset + ev->mlength <= req->rq_repbuf_len); /* We've set LNET_MD_MANAGE_REMOTE for all outgoing requests - for adaptive timeouts' early reply. */ + * for adaptive timeouts' early reply. + */ LASSERT((ev->md.options & LNET_MD_MANAGE_REMOTE) != 0); spin_lock(&req->rq_lock); @@ -151,7 +153,8 @@ void reply_in_callback(lnet_event_t *ev) req->rq_reply_off = ev->offset; req->rq_nob_received = ev->mlength; /* LNetMDUnlink can't be called under the LNET_LOCK, - so we must unlink in ptlrpc_unregister_reply */ + * so we must unlink in ptlrpc_unregister_reply + */ DEBUG_REQ(D_INFO, req, "reply in flags=%x mlen=%u offset=%d replen=%d", lustre_msg_get_flags(req->rq_reqmsg), @@ -162,7 +165,8 @@ void reply_in_callback(lnet_event_t *ev) out_wake: /* NB don't unlock till after wakeup; req can disappear under us - * since we don't have our own ref */ + * since we don't have our own ref + */ ptlrpc_client_wake_req(req); spin_unlock(&req->rq_lock); } @@ -213,7 +217,8 @@ void client_bulk_callback(lnet_event_t *ev) desc->bd_failure = 1; /* NB don't unlock till after wakeup; desc can disappear under us - * otherwise */ + * otherwise + */ if (desc->bd_md_count == 0) ptlrpc_client_wake_req(desc->bd_req); @@ -250,7 +255,8 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, __u64 new_seq; /* set sequence ID for request and add it to history list, - * it must be called with hold svcpt::scp_lock */ + * it must be called with hold svcpt::scp_lock + */ new_seq = (sec << REQS_SEC_SHIFT) | (usec << REQS_USEC_SHIFT) | @@ -258,7 +264,8 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, if (new_seq > svcpt->scp_hist_seq) { /* This handles the initial case of scp_hist_seq == 0 or - * we just jumped into a new time window */ + * we just jumped into a new time window + */ svcpt->scp_hist_seq = new_seq; } else { LASSERT(REQS_SEQ_SHIFT(svcpt) < REQS_USEC_SHIFT); @@ -266,7 +273,8 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, * however, it's possible that we used up all bits for * sequence and jumped into the next usec bucket (future time), * then we hope there will be less RPCs per bucket at some - * point, and sequence will catch up again */ + * point, and sequence will catch up again + */ svcpt->scp_hist_seq += (1U << REQS_SEQ_SHIFT(svcpt)); new_seq = svcpt->scp_hist_seq; } @@ -302,7 +310,8 @@ void request_in_callback(lnet_event_t *ev) * request buffer we can use the request object embedded in * rqbd. Note that if we failed to allocate a request, * we'd have to re-post the rqbd, which we can't do in this - * context. */ + * context. + */ req = &rqbd->rqbd_req; memset(req, 0, sizeof(*req)); } else { @@ -312,7 +321,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)); @@ -322,7 +331,8 @@ void request_in_callback(lnet_event_t *ev) /* NB we ABSOLUTELY RELY on req being zeroed, so pointers are NULL, * flags are reset and scalars are zero. We only set the message - * size to non-zero if this was a successful receive. */ + * size to non-zero if this was a successful receive. + */ req->rq_xid = ev->match_bits; req->rq_reqbuf = ev->md.start + ev->offset; if (ev->type == LNET_EVENT_PUT && ev->status == 0) @@ -352,7 +362,8 @@ void request_in_callback(lnet_event_t *ev) svcpt->scp_nrqbds_posted); /* Normally, don't complain about 0 buffers posted; LNET won't - * drop incoming reqs since we set the portal lazy */ + * drop incoming reqs since we set the portal lazy + */ if (test_req_buffer_pressure && ev->type != LNET_EVENT_UNLINK && svcpt->scp_nrqbds_posted == 0) @@ -369,7 +380,8 @@ void request_in_callback(lnet_event_t *ev) svcpt->scp_nreqs_incoming++; /* NB everything can disappear under us once the request - * has been queued and we unlock, so do the wake now... */ + * has been queued and we unlock, so do the wake now... + */ wake_up(&svcpt->scp_waitq); spin_unlock(&svcpt->scp_lock); @@ -390,7 +402,8 @@ void reply_out_callback(lnet_event_t *ev) if (!rs->rs_difficult) { /* 'Easy' replies have no further processing so I drop the - * net's ref on 'rs' */ + * net's ref on 'rs' + */ LASSERT(ev->unlinked); ptlrpc_rs_decref(rs); return; @@ -400,7 +413,8 @@ void reply_out_callback(lnet_event_t *ev) if (ev->unlinked) { /* Last network callback. The net's ref on 'rs' stays put - * until ptlrpc_handle_rs() is done with it */ + * until ptlrpc_handle_rs() is done with it + */ spin_lock(&svcpt->scp_rep_lock); spin_lock(&rs->rs_lock); @@ -438,15 +452,12 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, __u32 best_order = 0; int count = 0; int rc = -ENOENT; - int portals_compatibility; int dist; __u32 order; lnet_nid_t dst_nid; lnet_nid_t src_nid; - portals_compatibility = LNetCtl(IOC_LIBCFS_PORTALS_COMPATIBILITY, NULL); - - peer->pid = LUSTRE_SRV_LNET_PID; + peer->pid = LNET_PID_LUSTRE; /* Choose the matching UUID that's closest */ while (lustre_uuid_to_peer(uuid->uuid, &dst_nid, count++) == 0) { @@ -466,14 +477,6 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, best_dist = dist; best_order = order; - if (portals_compatibility > 1) { - /* Strong portals compatibility: Zero the nid's - * NET, so if I'm reading new config logs, or - * getting configured by (new) lconf I can - * still talk to old servers. */ - dst_nid = LNET_MKNID(0, LNET_NIDADDR(dst_nid)); - src_nid = LNET_MKNID(0, LNET_NIDADDR(src_nid)); - } peer->nid = dst_nid; *self = src_nid; rc = 0; @@ -494,7 +497,8 @@ static void ptlrpc_ni_fini(void) /* Wait for the event queue to become idle since there may still be * messages in flight with pending events (i.e. the fire-and-forget * messages == client requests and "non-difficult" server - * replies */ + * replies + */ for (retries = 0;; retries++) { rc = LNetEQFree(ptlrpc_eq_h); @@ -524,7 +528,7 @@ static lnet_pid_t ptl_get_pid(void) { lnet_pid_t pid; - pid = LUSTRE_SRV_LNET_PID; + pid = LNET_PID_LUSTRE; return pid; } @@ -544,11 +548,13 @@ static int ptlrpc_ni_init(void) } /* CAVEAT EMPTOR: how we process portals events is _radically_ - * different depending on... */ + * different depending on... + */ /* kernel LNet calls our master callback when there are new event, * because we are guaranteed to get every event via callback, * so we just set EQ size to 0 to avoid overhead of serializing - * enqueue/dequeue operations in LNet. */ + * enqueue/dequeue operations in LNet. + */ rc = LNetEQAlloc(0, ptlrpc_master_callback, &ptlrpc_eq_h); if (rc == 0) return 0; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index f752c789b..cd94fed0f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -112,7 +112,8 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp); * CLOSED. I would rather refcount the import and free it after * disconnection like we do with exports. To do that, the client_obd * will need to save the peer info somewhere other than in the import, - * though. */ + * though. + */ int ptlrpc_init_import(struct obd_import *imp) { spin_lock(&imp->imp_lock); @@ -139,7 +140,7 @@ static void deuuidify(char *uuid, const char *prefix, char **uuid_start, return; if (!strncmp(*uuid_start + *uuid_len - strlen(UUID_STR), - UUID_STR, strlen(UUID_STR))) + UUID_STR, strlen(UUID_STR))) *uuid_len -= strlen(UUID_STR); } @@ -282,11 +283,13 @@ void ptlrpc_invalidate_import(struct obd_import *imp) /* Wait forever until inflight == 0. We really can't do it another * way because in some cases we need to wait for very long reply * unlink. We can't do anything before that because there is really - * no guarantee that some rdma transfer is not in progress right now. */ + * no guarantee that some rdma transfer is not in progress right now. + */ do { /* Calculate max timeout for waiting on rpcs to error * out. Use obd_timeout if calculated value is smaller - * than it. */ + * than it. + */ if (!OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK)) { timeout = ptlrpc_inflight_timeout(imp); timeout += timeout / 3; @@ -304,7 +307,8 @@ void ptlrpc_invalidate_import(struct obd_import *imp) /* Wait for all requests to error out and call completion * callbacks. Cap it at obd_timeout -- these should all - * have been locally cancelled by ptlrpc_abort_inflight. */ + * have been locally cancelled by ptlrpc_abort_inflight. + */ lwi = LWI_TIMEOUT_INTERVAL( cfs_timeout_cap(cfs_time_seconds(timeout)), (timeout > 1)?cfs_time_seconds(1):cfs_time_seconds(1)/2, @@ -328,28 +332,30 @@ void ptlrpc_invalidate_import(struct obd_import *imp) * maybe waiting for long reply unlink in * sluggish nets). Let's check this. If there * is no inflight and unregistering != 0, this - * is bug. */ + * is bug. + */ LASSERTF(count == 0, "Some RPCs are still unregistering: %d\n", count); /* Let's save one loop as soon as inflight have * dropped to zero. No new inflights possible at - * this point. */ + * this point. + */ rc = 0; } else { list_for_each_safe(tmp, n, - &imp->imp_sending_list) { + &imp->imp_sending_list) { req = list_entry(tmp, - struct ptlrpc_request, - rq_list); + struct ptlrpc_request, + rq_list); DEBUG_REQ(D_ERROR, req, "still on sending list"); } list_for_each_safe(tmp, n, - &imp->imp_delayed_list) { + &imp->imp_delayed_list) { req = list_entry(tmp, - struct ptlrpc_request, - rq_list); + struct ptlrpc_request, + rq_list); DEBUG_REQ(D_ERROR, req, "still on delayed list"); } @@ -427,7 +433,6 @@ EXPORT_SYMBOL(ptlrpc_fail_import); int ptlrpc_reconnect_import(struct obd_import *imp) { -#ifdef ENABLE_PINGER struct l_wait_info lwi; int secs = cfs_time_seconds(obd_timeout); int rc; @@ -443,33 +448,6 @@ int ptlrpc_reconnect_import(struct obd_import *imp) CDEBUG(D_HA, "%s: recovery finished s:%s\n", obd2cli_tgt(imp->imp_obd), ptlrpc_import_state_name(imp->imp_state)); return rc; -#else - ptlrpc_set_import_discon(imp, 0); - /* Force a new connect attempt */ - ptlrpc_invalidate_import(imp); - /* Do a fresh connect next time by zeroing the handle */ - ptlrpc_disconnect_import(imp, 1); - /* Wait for all invalidate calls to finish */ - if (atomic_read(&imp->imp_inval_count) > 0) { - int rc; - struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); - - rc = l_wait_event(imp->imp_recovery_waitq, - (atomic_read(&imp->imp_inval_count) == 0), - &lwi); - if (rc) - CERROR("Interrupted, inval=%d\n", - atomic_read(&imp->imp_inval_count)); - } - - /* Allow reconnect attempts */ - imp->imp_obd->obd_no_recov = 0; - /* Remove 'invalid' flag */ - ptlrpc_activate_import(imp); - /* Attempt a new connect */ - ptlrpc_recover_import(imp, NULL, 0); - return 0; -#endif } EXPORT_SYMBOL(ptlrpc_reconnect_import); @@ -501,18 +479,20 @@ static int import_select_connection(struct obd_import *imp) conn->oic_last_attempt); /* If we have not tried this connection since - the last successful attempt, go with this one */ + * the last successful attempt, go with this one + */ if ((conn->oic_last_attempt == 0) || cfs_time_beforeq_64(conn->oic_last_attempt, - imp->imp_last_success_conn)) { + imp->imp_last_success_conn)) { imp_conn = conn; tried_all = 0; break; } /* If all of the connections have already been tried - since the last successful connection; just choose the - least recently used */ + * since the last successful connection; just choose the + * least recently used + */ if (!imp_conn) imp_conn = conn; else if (cfs_time_before_64(conn->oic_last_attempt, @@ -529,10 +509,11 @@ static int import_select_connection(struct obd_import *imp) LASSERT(imp_conn->oic_conn); /* If we've tried everything, and we're back to the beginning of the - list, increase our timeout and try again. It will be reset when - we do finally connect. (FIXME: really we should wait for all network - state associated with the last connection attempt to drain before - trying to reconnect on it.) */ + * list, increase our timeout and try again. It will be reset when + * we do finally connect. (FIXME: really we should wait for all network + * state associated with the last connection attempt to drain before + * trying to reconnect on it.) + */ if (tried_all && (imp->imp_conn_list.next == &imp_conn->oic_item)) { struct adaptive_timeout *at = &imp->imp_at.iat_net_latency; @@ -553,7 +534,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); @@ -590,7 +570,8 @@ static int ptlrpc_first_transno(struct obd_import *imp, __u64 *transno) struct list_head *tmp; /* The requests in committed_list always have smaller transnos than - * the requests in replay_list */ + * the requests in replay_list + */ if (!list_empty(&imp->imp_committed_list)) { tmp = imp->imp_committed_list.next; req = list_entry(tmp, struct ptlrpc_request, rq_replay_list); @@ -674,7 +655,8 @@ int ptlrpc_connect_import(struct obd_import *imp) goto out; /* Reset connect flags to the originally requested flags, in case - * the server is updated on-the-fly we will get the new features. */ + * the server is updated on-the-fly we will get the new features. + */ imp->imp_connect_data.ocd_connect_flags = imp->imp_connect_flags_orig; /* Reset ocd_version each time so the server knows the exact versions */ imp->imp_connect_data.ocd_version = LUSTRE_VERSION_CODE; @@ -687,7 +669,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; } @@ -700,7 +682,8 @@ int ptlrpc_connect_import(struct obd_import *imp) } /* Report the rpc service time to the server so that it knows how long - * to wait for clients to join recovery */ + * to wait for clients to join recovery + */ lustre_msg_set_service_time(request->rq_reqmsg, at_timeout2est(request->rq_timeout)); @@ -708,7 +691,8 @@ int ptlrpc_connect_import(struct obd_import *imp) * import_select_connection will increase the net latency on * repeated reconnect attempts to cover slow networks. * We override/ignore the server rpc completion estimate here, - * which may be large if this is a reconnect attempt */ + * which may be large if this is a reconnect attempt + */ request->rq_timeout = INITIAL_CONNECT_TIMEOUT; lustre_msg_set_timeout(request->rq_reqmsg, request->rq_timeout); @@ -799,7 +783,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, if (rc) { /* if this reconnect to busy export - not need select new target - * for connecting*/ + * for connecting + */ imp->imp_force_reconnect = ptlrpc_busy_reconnect(rc); spin_unlock(&imp->imp_lock); ptlrpc_maybe_ping_import_soon(imp); @@ -817,7 +802,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; @@ -851,7 +836,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, if (!exp) { /* This could happen if export is cleaned during the - connect attempt */ + * connect attempt + */ CERROR("%s: missing export after connect\n", imp->imp_obd->obd_name); rc = -ENODEV; @@ -877,14 +863,16 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, } /* if applies, adjust the imp->imp_msg_magic here - * according to reply flags */ + * according to reply flags + */ imp->imp_remote_handle = *lustre_msg_get_handle(request->rq_repmsg); /* Initial connects are allowed for clients with non-random * uuids when servers are in recovery. Simply signal the - * servers replay is complete and wait in REPLAY_WAIT. */ + * servers replay is complete and wait in REPLAY_WAIT. + */ if (msg_flags & MSG_CONNECT_RECOVERING) { CDEBUG(D_HA, "connect to %s during recovery\n", obd2cli_tgt(imp->imp_obd)); @@ -923,7 +911,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, * already erased all of our state because of previous * eviction. If it is in recovery - we are safe to * participate since we can reestablish all of our state - * with server again */ + * with server again + */ if ((msg_flags & MSG_CONNECT_RECOVERING)) { CDEBUG(level, "%s@%s changed server handle from %#llx to %#llx but is still in recovery\n", obd2cli_tgt(imp->imp_obd), @@ -1015,8 +1004,7 @@ finish: spin_lock(&imp->imp_lock); list_del(&imp->imp_conn_current->oic_item); - list_add(&imp->imp_conn_current->oic_item, - &imp->imp_conn_list); + list_add(&imp->imp_conn_current->oic_item, &imp->imp_conn_list); imp->imp_last_success_conn = imp->imp_conn_current->oic_last_attempt; @@ -1039,7 +1027,8 @@ finish: ocd->ocd_version < LUSTRE_VERSION_CODE - LUSTRE_VERSION_OFFSET_WARN)) { /* Sigh, some compilers do not like #ifdef in the middle - of macro arguments */ + * of macro arguments + */ const char *older = "older. Consider upgrading server or downgrading client" ; const char *newer = "newer than client version. Consider upgrading client" @@ -1061,7 +1050,8 @@ finish: * fixup is version-limited, because we don't want to carry the * OBD_CONNECT_MNE_SWAB flag around forever, just so long as we * need interop with unpatched 2.2 servers. For newer servers, - * the client will do MNE swabbing only as needed. LU-1644 */ + * the client will do MNE swabbing only as needed. LU-1644 + */ if (unlikely((ocd->ocd_connect_flags & OBD_CONNECT_VERSION) && !(ocd->ocd_connect_flags & OBD_CONNECT_MNE_SWAB) && OBD_OCD_VERSION_MAJOR(ocd->ocd_version) == 2 && @@ -1079,7 +1069,8 @@ finish: if (ocd->ocd_connect_flags & OBD_CONNECT_CKSUM) { /* We sent to the server ocd_cksum_types with bits set * for algorithms we understand. The server masked off - * the checksum types it doesn't support */ + * the checksum types it doesn't support + */ if ((ocd->ocd_cksum_types & cksum_types_supported_client()) == 0) { LCONSOLE_WARN("The negotiation of the checksum algorithm to use with server %s failed (%x/%x), disabling checksums\n", @@ -1093,14 +1084,15 @@ finish: } } else { /* The server does not support OBD_CONNECT_CKSUM. - * Enforce ADLER for backward compatibility*/ + * Enforce ADLER for backward compatibility + */ cli->cl_supp_cksum_types = OBD_CKSUM_ADLER; } cli->cl_cksum_type = cksum_type_select(cli->cl_supp_cksum_types); if (ocd->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) cli->cl_max_pages_per_rpc = - min(ocd->ocd_brw_size >> PAGE_CACHE_SHIFT, + min(ocd->ocd_brw_size >> PAGE_SHIFT, cli->cl_max_pages_per_rpc); else if (imp->imp_connect_op == MDS_CONNECT || imp->imp_connect_op == MGS_CONNECT) @@ -1109,7 +1101,8 @@ finish: /* Reset ns_connect_flags only for initial connect. It might be * changed in while using FS and if we reset it in reconnect * this leads to losing user settings done before such as - * disable lru_resize, etc. */ + * disable lru_resize, etc. + */ if (old_connect_flags != exp_connect_flags(exp) || aa->pcaa_initial_connect) { CDEBUG(D_HA, "%s: Resetting ns_connect_flags to server flags: %#llx\n", @@ -1123,13 +1116,14 @@ finish: if ((ocd->ocd_connect_flags & OBD_CONNECT_AT) && (imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V2)) /* We need a per-message support flag, because - a. we don't know if the incoming connect reply - supports AT or not (in reply_in_callback) - until we unpack it. - b. failovered server means export and flags are gone - (in ptlrpc_send_reply). - Can only be set when we know AT is supported at - both ends */ + * a. we don't know if the incoming connect reply + * supports AT or not (in reply_in_callback) + * until we unpack it. + * b. failovered server means export and flags are gone + * (in ptlrpc_send_reply). + * Can only be set when we know AT is supported at + * both ends + */ imp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT; else imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT; @@ -1162,7 +1156,7 @@ out: 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 +1237,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; } @@ -1337,12 +1331,13 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) { struct task_struct *task; /* bug 17802: XXX client_disconnect_export vs connect request - * race. if client will evicted at this time, we start + * race. if client is evicted at this time, we start * invalidate thread without reference to import and import can - * be freed at same time. */ + * be freed at same time. + */ class_import_get(imp); task = kthread_run(ptlrpc_invalidate_import_thread, imp, - "ll_imp_inval"); + "ll_imp_inval"); if (IS_ERR(task)) { class_import_put(imp); CERROR("error starting invalidate thread: %d\n", rc); @@ -1471,11 +1466,13 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) if (req) { /* We are disconnecting, do not retry a failed DISCONNECT rpc if * it fails. We can get through the above with a down server - * if the client doesn't know the server is gone yet. */ + * if the client doesn't know the server is gone yet. + */ req->rq_no_resend = 1; /* We want client umounts to happen quickly, no matter the - server state... */ + * server state... + */ req->rq_timeout = min_t(int, req->rq_timeout, INITIAL_CONNECT_TIMEOUT); @@ -1507,9 +1504,10 @@ EXPORT_SYMBOL(ptlrpc_disconnect_import); extern unsigned int at_min, at_max, at_history; /* Bin into timeslices using AT_BINS bins. - This gives us a max of the last binlimit*AT_BINS secs without the storage, - but still smoothing out a return to normalcy from a slow response. - (E.g. remember the maximum latency in each minute of the last 4 minutes.) */ + * This gives us a max of the last binlimit*AT_BINS secs without the storage, + * but still smoothing out a return to normalcy from a slow response. + * (E.g. remember the maximum latency in each minute of the last 4 minutes.) + */ int at_measured(struct adaptive_timeout *at, unsigned int val) { unsigned int old = at->at_current; @@ -1523,7 +1521,8 @@ int at_measured(struct adaptive_timeout *at, unsigned int val) if (val == 0) /* 0's don't count, because we never want our timeout to - drop to 0, and because 0 could mean an error */ + * drop to 0, and because 0 could mean an error + */ return 0; spin_lock(&at->at_lock); @@ -1565,7 +1564,8 @@ int at_measured(struct adaptive_timeout *at, unsigned int val) if (at->at_flags & AT_FLG_NOHIST) /* Only keep last reported val; keeping the rest of the history - for proc only */ + * for debugfs only + */ at->at_current = val; if (at_max > 0) diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index c0e613c23..5b06901e5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -118,25 +118,6 @@ static const struct req_msg_field *quotactl_only[] = { &RMF_OBD_QUOTACTL }; -static const struct req_msg_field *quota_body_only[] = { - &RMF_PTLRPC_BODY, - &RMF_QUOTA_BODY -}; - -static const struct req_msg_field *ldlm_intent_quota_client[] = { - &RMF_PTLRPC_BODY, - &RMF_DLM_REQ, - &RMF_LDLM_INTENT, - &RMF_QUOTA_BODY -}; - -static const struct req_msg_field *ldlm_intent_quota_server[] = { - &RMF_PTLRPC_BODY, - &RMF_DLM_REP, - &RMF_DLM_LVB, - &RMF_QUOTA_BODY -}; - static const struct req_msg_field *mdt_close_client[] = { &RMF_PTLRPC_BODY, &RMF_MDT_EPOCH, @@ -514,16 +495,6 @@ static const struct req_msg_field *mds_setattr_server[] = { &RMF_CAPA2 }; -static const struct req_msg_field *mds_update_client[] = { - &RMF_PTLRPC_BODY, - &RMF_UPDATE, -}; - -static const struct req_msg_field *mds_update_server[] = { - &RMF_PTLRPC_BODY, - &RMF_UPDATE_REPLY, -}; - static const struct req_msg_field *llog_origin_handle_create_client[] = { &RMF_PTLRPC_BODY, &RMF_LLOGD_BODY, @@ -551,16 +522,6 @@ static const struct req_msg_field *llog_origin_handle_next_block_server[] = { &RMF_EADATA }; -static const struct req_msg_field *obd_idx_read_client[] = { - &RMF_PTLRPC_BODY, - &RMF_IDX_INFO -}; - -static const struct req_msg_field *obd_idx_read_server[] = { - &RMF_PTLRPC_BODY, - &RMF_IDX_INFO -}; - static const struct req_msg_field *ost_body_only[] = { &RMF_PTLRPC_BODY, &RMF_OST_BODY @@ -676,7 +637,6 @@ static const struct req_msg_field *mdt_hsm_request[] = { static struct req_format *req_formats[] = { &RQF_OBD_PING, &RQF_OBD_SET_INFO, - &RQF_OBD_IDX_READ, &RQF_SEC_CTX, &RQF_MGS_TARGET_REG, &RQF_MGS_SET_INFO, @@ -721,7 +681,6 @@ static struct req_format *req_formats[] = { &RQF_MDS_HSM_ACTION, &RQF_MDS_HSM_REQUEST, &RQF_MDS_SWAP_LAYOUTS, - &RQF_UPDATE_OBJ, &RQF_QC_CALLBACK, &RQF_OST_CONNECT, &RQF_OST_DISCONNECT, @@ -759,8 +718,6 @@ static struct req_format *req_formats[] = { &RQF_LDLM_INTENT_CREATE, &RQF_LDLM_INTENT_UNLINK, &RQF_LDLM_INTENT_GETXATTR, - &RQF_LDLM_INTENT_QUOTA, - &RQF_QUOTA_DQACQ, &RQF_LOG_CANCEL, &RQF_LLOG_ORIGIN_HANDLE_CREATE, &RQF_LLOG_ORIGIN_HANDLE_DESTROY, @@ -899,11 +856,6 @@ struct req_msg_field RMF_OBD_QUOTACTL = lustre_swab_obd_quotactl, NULL); EXPORT_SYMBOL(RMF_OBD_QUOTACTL); -struct req_msg_field RMF_QUOTA_BODY = - DEFINE_MSGF("quota_body", 0, - sizeof(struct quota_body), lustre_swab_quota_body, NULL); -EXPORT_SYMBOL(RMF_QUOTA_BODY); - struct req_msg_field RMF_MDT_EPOCH = DEFINE_MSGF("mdt_ioepoch", 0, sizeof(struct mdt_ioepoch), lustre_swab_mdt_ioepoch, NULL); @@ -938,12 +890,12 @@ EXPORT_SYMBOL(RMF_SYMTGT); struct req_msg_field RMF_TGTUUID = DEFINE_MSGF("tgtuuid", RMF_F_STRING, sizeof(struct obd_uuid) - 1, NULL, - NULL); + NULL); EXPORT_SYMBOL(RMF_TGTUUID); struct req_msg_field RMF_CLUUID = DEFINE_MSGF("cluuid", RMF_F_STRING, sizeof(struct obd_uuid) - 1, NULL, - NULL); + NULL); EXPORT_SYMBOL(RMF_CLUUID); struct req_msg_field RMF_STRING = @@ -1078,7 +1030,7 @@ EXPORT_SYMBOL(RMF_RCS); struct req_msg_field RMF_EAVALS_LENS = DEFINE_MSGF("eavals_lens", RMF_F_STRUCT_ARRAY, sizeof(__u32), - lustre_swab_generic_32s, NULL); + lustre_swab_generic_32s, NULL); EXPORT_SYMBOL(RMF_EAVALS_LENS); struct req_msg_field RMF_OBD_ID = @@ -1105,10 +1057,6 @@ struct req_msg_field RMF_FIEMAP_VAL = DEFINE_MSGF("fiemap", 0, -1, lustre_swab_fiemap, NULL); EXPORT_SYMBOL(RMF_FIEMAP_VAL); -struct req_msg_field RMF_IDX_INFO = - DEFINE_MSGF("idx_info", 0, sizeof(struct idx_info), - lustre_swab_idx_info, NULL); -EXPORT_SYMBOL(RMF_IDX_INFO); struct req_msg_field RMF_HSM_USER_STATE = DEFINE_MSGF("hsm_user_state", 0, sizeof(struct hsm_user_state), lustre_swab_hsm_user_state, NULL); @@ -1145,15 +1093,6 @@ struct req_msg_field RMF_MDS_HSM_REQUEST = lustre_swab_hsm_request, NULL); EXPORT_SYMBOL(RMF_MDS_HSM_REQUEST); -struct req_msg_field RMF_UPDATE = DEFINE_MSGF("update", 0, -1, - lustre_swab_update_buf, NULL); -EXPORT_SYMBOL(RMF_UPDATE); - -struct req_msg_field RMF_UPDATE_REPLY = DEFINE_MSGF("update_reply", 0, -1, - lustre_swab_update_reply_buf, - NULL); -EXPORT_SYMBOL(RMF_UPDATE_REPLY); - struct req_msg_field RMF_SWAP_LAYOUTS = DEFINE_MSGF("swap_layouts", 0, sizeof(struct mdc_swap_layouts), lustre_swab_swap_layouts, NULL); @@ -1196,29 +1135,23 @@ struct req_format RQF_OBD_SET_INFO = DEFINE_REQ_FMT0("OBD_SET_INFO", obd_set_info_client, empty); EXPORT_SYMBOL(RQF_OBD_SET_INFO); -/* Read index file through the network */ -struct req_format RQF_OBD_IDX_READ = - DEFINE_REQ_FMT0("OBD_IDX_READ", - obd_idx_read_client, obd_idx_read_server); -EXPORT_SYMBOL(RQF_OBD_IDX_READ); - struct req_format RQF_SEC_CTX = DEFINE_REQ_FMT0("SEC_CTX", empty, empty); EXPORT_SYMBOL(RQF_SEC_CTX); struct req_format RQF_MGS_TARGET_REG = DEFINE_REQ_FMT0("MGS_TARGET_REG", mgs_target_info_only, - mgs_target_info_only); + mgs_target_info_only); EXPORT_SYMBOL(RQF_MGS_TARGET_REG); struct req_format RQF_MGS_SET_INFO = DEFINE_REQ_FMT0("MGS_SET_INFO", mgs_set_info, - mgs_set_info); + mgs_set_info); EXPORT_SYMBOL(RQF_MGS_SET_INFO); struct req_format RQF_MGS_CONFIG_READ = DEFINE_REQ_FMT0("MGS_CONFIG_READ", mgs_config_read_client, - mgs_config_read_server); + mgs_config_read_server); EXPORT_SYMBOL(RQF_MGS_CONFIG_READ); struct req_format RQF_SEQ_QUERY = @@ -1253,16 +1186,6 @@ struct req_format RQF_QC_CALLBACK = DEFINE_REQ_FMT0("QC_CALLBACK", quotactl_only, empty); EXPORT_SYMBOL(RQF_QC_CALLBACK); -struct req_format RQF_QUOTA_DQACQ = - DEFINE_REQ_FMT0("QUOTA_DQACQ", quota_body_only, quota_body_only); -EXPORT_SYMBOL(RQF_QUOTA_DQACQ); - -struct req_format RQF_LDLM_INTENT_QUOTA = - DEFINE_REQ_FMT0("LDLM_INTENT_QUOTA", - ldlm_intent_quota_client, - ldlm_intent_quota_server); -EXPORT_SYMBOL(RQF_LDLM_INTENT_QUOTA); - struct req_format RQF_MDS_GETSTATUS = DEFINE_REQ_FMT0("MDS_GETSTATUS", mdt_body_only, mdt_body_capa); EXPORT_SYMBOL(RQF_MDS_GETSTATUS); @@ -1357,11 +1280,6 @@ struct req_format RQF_MDS_GET_INFO = mds_getinfo_server); EXPORT_SYMBOL(RQF_MDS_GET_INFO); -struct req_format RQF_UPDATE_OBJ = - DEFINE_REQ_FMT0("OBJECT_UPDATE_OBJ", mds_update_client, - mds_update_server); -EXPORT_SYMBOL(RQF_UPDATE_OBJ); - struct req_format RQF_LDLM_ENQUEUE = DEFINE_REQ_FMT0("LDLM_ENQUEUE", ldlm_enqueue_client, ldlm_enqueue_lvb_server); @@ -1598,32 +1516,32 @@ EXPORT_SYMBOL(RQF_OST_STATFS); struct req_format RQF_OST_SET_GRANT_INFO = DEFINE_REQ_FMT0("OST_SET_GRANT_INFO", ost_grant_shrink_client, - ost_body_only); + ost_body_only); EXPORT_SYMBOL(RQF_OST_SET_GRANT_INFO); struct req_format RQF_OST_GET_INFO_GENERIC = DEFINE_REQ_FMT0("OST_GET_INFO", ost_get_info_generic_client, - ost_get_info_generic_server); + ost_get_info_generic_server); EXPORT_SYMBOL(RQF_OST_GET_INFO_GENERIC); struct req_format RQF_OST_GET_INFO_LAST_ID = DEFINE_REQ_FMT0("OST_GET_INFO_LAST_ID", ost_get_info_generic_client, - ost_get_last_id_server); + ost_get_last_id_server); EXPORT_SYMBOL(RQF_OST_GET_INFO_LAST_ID); struct req_format RQF_OST_GET_INFO_LAST_FID = DEFINE_REQ_FMT0("OST_GET_INFO_LAST_FID", obd_set_info_client, - ost_get_last_fid_server); + ost_get_last_fid_server); EXPORT_SYMBOL(RQF_OST_GET_INFO_LAST_FID); struct req_format RQF_OST_SET_INFO_LAST_FID = DEFINE_REQ_FMT0("OST_SET_INFO_LAST_FID", obd_set_info_client, - empty); + empty); EXPORT_SYMBOL(RQF_OST_SET_INFO_LAST_FID); struct req_format RQF_OST_GET_INFO_FIEMAP = DEFINE_REQ_FMT0("OST_GET_INFO_FIEMAP", ost_get_fiemap_client, - ost_get_fiemap_server); + ost_get_fiemap_server); EXPORT_SYMBOL(RQF_OST_GET_INFO_FIEMAP); #if !defined(__REQ_LAYOUT_USER__) @@ -1712,7 +1630,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 +1638,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 +1670,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 +1691,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,15 +1726,15 @@ 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, pill->rc_area[RCL_SERVER], NULL); if (rc != 0) { DEBUG_REQ(D_ERROR, pill->rc_req, - "Cannot pack %d fields in format `%s': ", - count, fmt->rf_name); + "Cannot pack %d fields in format `%s': ", + count, fmt->rf_name); } return rc; } @@ -1835,9 +1751,8 @@ static int __req_capsule_offset(const struct req_capsule *pill, int offset; offset = field->rmf_offset[pill->rc_fmt->rf_idx][loc]; - LASSERTF(offset > 0, "%s:%s, off=%d, loc=%d\n", - pill->rc_fmt->rf_name, - field->rmf_name, offset, loc); + LASSERTF(offset > 0, "%s:%s, off=%d, loc=%d\n", pill->rc_fmt->rf_name, + field->rmf_name, offset, loc); offset--; LASSERT(0 <= offset && offset < REQ_MAX_FIELD_NR); @@ -1865,7 +1780,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; @@ -1883,7 +1798,7 @@ swabber_dumper_helper(struct req_capsule *pill, return; swabber(value); ptlrpc_buf_set_swabbed(pill->rc_req, inout, offset); - if (dump) { + if (dump && field->rmf_dumper) { CDEBUG(D_RPCTRACE, "Dump of swabbed field %s follows\n", field->rmf_name); field->rmf_dumper(value); @@ -1947,17 +1862,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 +1893,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 +2122,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 +2135,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 +2202,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)); @@ -2299,7 +2212,7 @@ void req_capsule_shrink(struct req_capsule *pill, msg = __req_msg(pill, loc); len = lustre_msg_buflen(msg, offset); LASSERTF(newlen <= len, "%s:%s, oldlen=%d, newlen=%d\n", - fmt->rf_name, field->rmf_name, len, newlen); + fmt->rf_name, field->rmf_name, len, newlen); if (loc == RCL_CLIENT) pill->rc_req->rq_reqlen = lustre_shrink_msg(msg, offset, newlen, diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index e87702073..a23ac5f9a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -75,7 +75,8 @@ } while (0) /* This is a callback from the llog_* functions. - * Assumes caller has already pushed us into the kernel context. */ + * Assumes caller has already pushed us into the kernel context. + */ static int llog_client_open(const struct lu_env *env, struct llog_handle *lgh, struct llog_logid *logid, char *name, enum llog_open_param open_param) @@ -93,7 +94,7 @@ static int llog_client_open(const struct lu_env *env, LASSERT(lgh); req = ptlrpc_request_alloc(imp, &RQF_LLOG_ORIGIN_HANDLE_CREATE); - if (req == NULL) { + if (!req) { rc = -ENOMEM; goto out; } @@ -130,7 +131,7 @@ static int llog_client_open(const struct lu_env *env, goto out; body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY); - if (body == NULL) { + if (!body) { rc = -EFAULT; goto out; } @@ -158,7 +159,7 @@ static int llog_client_next_block(const struct lu_env *env, 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; } @@ -179,14 +180,14 @@ static int llog_client_next_block(const struct lu_env *env, 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; } @@ -216,7 +217,7 @@ static int llog_client_prev_block(const struct lu_env *env, 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; } @@ -236,13 +237,13 @@ static int llog_client_prev_block(const struct lu_env *env, 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; } @@ -269,7 +270,7 @@ static int llog_client_read_header(const struct lu_env *env, 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; } @@ -285,7 +286,7 @@ static int llog_client_read_header(const struct lu_env *env, goto out; hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR); - if (hdr == NULL) { + if (!hdr) { rc = -EFAULT; goto out; } @@ -316,8 +317,9 @@ static int llog_client_close(const struct lu_env *env, struct llog_handle *handle) { /* this doesn't call LLOG_ORIGIN_HANDLE_CLOSE because - the servers all close the file at the end of every - other LLOG_ RPC. */ + * the servers all close the file at the end of every + * other LLOG_ RPC. + */ return 0; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c index dac66f5b3..fbccb6221 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c @@ -58,7 +58,7 @@ int llog_initiator_connect(struct llog_ctxt *ctxt) 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) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index cc55b7973..c95a91ce2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -131,7 +131,6 @@ static struct ll_rpc_opcode { { SEC_CTX_INIT_CONT, "sec_ctx_init_cont" }, { SEC_CTX_FINI, "sec_ctx_fini" }, { FLD_QUERY, "fld_query" }, - { UPDATE_OBJ, "update_obj" }, }; static struct ll_eopcode { @@ -192,15 +191,15 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, 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); @@ -246,11 +245,11 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, 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; } @@ -307,8 +306,9 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, /* This sanity check is more of an insanity check; we can still * hose a kernel by allowing the request history to grow too - * far. */ - bufpages = (svc->srv_buf_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + * far. + */ + bufpages = (svc->srv_buf_size + PAGE_SIZE - 1) >> PAGE_SHIFT; if (val > totalram_pages / (2 * bufpages)) return -ERANGE; @@ -454,10 +454,8 @@ static const char *nrs_state2str(enum ptlrpc_nrs_pol_state state) * \param[out] info Holds returned status information */ static void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy, - struct ptlrpc_nrs_pol_info *info) + 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); @@ -508,7 +506,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) spin_unlock(&nrs->nrs_lock); infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS); - if (infos == NULL) { + if (!infos) { rc = -ENOMEM; goto unlock; } @@ -520,8 +518,7 @@ again: pol_idx = 0; - list_for_each_entry(policy, &nrs->nrs_policy_list, - pol_list) { + list_for_each_entry(policy, &nrs->nrs_policy_list, pol_list) { LASSERT(pol_idx < num_pols); nrs_policy_get_info_locked(policy, &tmp); @@ -592,7 +589,7 @@ again: * active: 0 */ seq_printf(m, "%s\n", - !hp ? "\nregular_requests:" : "high_priority_requests:"); + !hp ? "\nregular_requests:" : "high_priority_requests:"); for (pol_idx = 0; pol_idx < num_pols; pol_idx++) { seq_printf(m, " - name: %s\n" @@ -676,7 +673,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, /** * No [reg|hp] token has been specified */ - if (cmd == NULL) + if (!cmd) goto default_queue; /** @@ -733,15 +730,15 @@ ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt, 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 * recent), search from it onwards. * Since the service history is LRU (i.e. culled reqs will * be near the head), we shouldn't have to do long - * re-scans */ + * re-scans + */ LASSERTF(srhi->srhi_seq == srhi->srhi_req->rq_history_seq, "%s:%d: seek seq %llu, request seq %llu\n", svcpt->scp_service->srv_name, svcpt->scp_cpt, @@ -919,7 +916,8 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) * here. The request could contain any old crap, so you * must be just as careful as the service's request * parser. Currently I only print stuff here I know is OK - * to look at coz it was set up in request_in_callback()!!! */ + * to look at coz it was set up in request_in_callback()!!! + */ seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%lld:%lds(%+lds) ", req->rq_history_seq, nidstr, libcfs_id2str(req->rq_peer), req->rq_xid, @@ -927,7 +925,7 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) (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); @@ -971,7 +969,7 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) if (AT_OFF) { seq_printf(m, "adaptive timeouts off, using obd_timeout %u\n", - obd_timeout); + obd_timeout); return 0; } @@ -982,8 +980,8 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) s2dhms(&ts, ktime_get_real_seconds() - worstt); seq_printf(m, "%10s : cur %3u worst %3u (at %lld, " - DHMS_FMT" ago) ", "service", - cur, worst, (s64)worstt, DHMS_VARS(&ts)); + DHMS_FMT " ago) ", "service", + cur, worst, (s64)worstt, DHMS_VARS(&ts)); lprocfs_at_hist_helper(m, &svcpt->scp_at_estimate); } @@ -1103,7 +1101,7 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry, "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); @@ -1129,7 +1127,7 @@ void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount) 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)) @@ -1166,7 +1164,7 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_brw); 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) @@ -1198,7 +1196,7 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer, 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; @@ -1228,7 +1226,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, const char prefix[] = "connection="; const int prefix_len = sizeof(prefix) - 1; - if (count > PAGE_CACHE_SIZE - 1 || count <= prefix_len) + if (count > PAGE_SIZE - 1 || count <= prefix_len) return -EINVAL; kbuf = kzalloc(count + 1, GFP_NOFS); @@ -1298,7 +1296,7 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n) EXPORT_SYMBOL(lprocfs_rd_pinger_recov); int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, - size_t count, loff_t *off) + size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; struct client_obd *cli = &obd->u.cli; diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index c5d7ff5cb..10b8fe82a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -56,7 +56,6 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, 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; @@ -88,7 +87,8 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, int rc2; /* We're going to get an UNLINK event when I unlink below, * which will complete just like any other failed send, so - * I fall through and return success here! */ + * I fall through and return success here! + */ CERROR("LNetPut(%s, %d, %lld) failed: %d\n", libcfs_id2str(conn->c_peer), portal, xid, rc); rc2 = LNetMDUnlink(*mdh); @@ -130,7 +130,7 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) 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); @@ -153,7 +153,8 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) * using the same RDMA match bits after an error. * * For multi-bulk RPCs, rq_xid is the last XID needed for bulks. The - * first bulk XID is power-of-two aligned before rq_xid. LU-1431 */ + * first bulk XID is power-of-two aligned before rq_xid. LU-1431 + */ xid = req->rq_xid & ~((__u64)desc->bd_md_max_brw - 1); LASSERTF(!(desc->bd_registered && req->rq_send_state != LUSTRE_IMP_REPLAY) || @@ -209,7 +210,8 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) } /* Set rq_xid to matchbits of the final bulk so that server can - * infer the number of bulks that were prepared */ + * infer the number of bulks that were prepared + */ req->rq_xid = --xid; LASSERTF(desc->bd_last_xid == (req->rq_xid & PTLRPC_BULK_OPS_MASK), "bd_last_xid = x%llu, rq_xid = x%llu\n", @@ -260,7 +262,8 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) /* the unlink ensures the callback happens ASAP and is the last * one. If it fails, it must be because completion just happened, * but we must still l_wait_event() in this case to give liblustre - * a chance to run client_bulk_callback() */ + * a chance to run client_bulk_callback() + */ mdunlink_iterate_helper(desc->bd_mds, desc->bd_md_max_brw); if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ @@ -273,14 +276,15 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) 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; for (;;) { /* Network access will complete in finite time but the HUGE - * timeout lets us CWARN for visibility of sluggish NALs */ + * timeout lets us CWARN for visibility of sluggish LNDs + */ lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK), cfs_time_seconds(1), NULL, NULL); rc = l_wait_event(*wq, !ptlrpc_client_bulk_active(req), &lwi); @@ -305,13 +309,13 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) 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))) { /* early replies, errors and recovery requests don't count - * toward our service time estimate */ + * toward our service time estimate + */ int oldse = at_measured(&svcpt->scp_at_estimate, service_time); if (oldse != 0) { @@ -325,7 +329,8 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) lustre_msg_set_service_time(req->rq_repmsg, service_time); /* Report service time estimate for future client reqs, but report 0 * (to be ignored by client) if it's a error reply during recovery. - * (bz15815) */ + * (bz15815) + */ if (req->rq_type == PTL_RPC_MSG_ERR && !req->rq_export) lustre_msg_set_timeout(req->rq_repmsg, 0); else @@ -360,10 +365,10 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) * 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); @@ -403,12 +408,12 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) 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; } @@ -498,14 +503,15 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) LASSERT(request->rq_wait_ctx == 0); /* If this is a re-transmit, we're required to have disengaged - * cleanly from the previous attempt */ + * cleanly from the previous attempt + */ LASSERT(!request->rq_receiving_reply); LASSERT(!((lustre_msg_get_flags(request->rq_reqmsg) & MSG_REPLAY) && - (request->rq_import->imp_state == LUSTRE_IMP_FULL))); + (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); + obd->obd_name); /* this prevents us from waiting in ptlrpc_queue_wait */ spin_lock(&request->rq_lock); request->rq_err = 1; @@ -535,7 +541,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) 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; @@ -543,14 +549,15 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) 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) { /* this prevents us from looping in - * ptlrpc_queue_wait */ + * ptlrpc_queue_wait + */ spin_lock(&request->rq_lock); request->rq_err = 1; spin_unlock(&request->rq_lock); @@ -602,7 +609,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) reply_md.eq_handle = ptlrpc_eq_h; /* We must see the unlink callback to unset rq_reply_unlink, - so we can't auto-unlink */ + * so we can't auto-unlink + */ rc = LNetMDAttach(reply_me_h, reply_md, LNET_RETAIN, &request->rq_reply_md_h); if (rc != 0) { @@ -623,7 +631,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) /* 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)); @@ -632,7 +640,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) ktime_get_real_ts64(&request->rq_arrival_time); request->rq_sent = ktime_get_real_seconds(); /* We give the server rq_timeout secs to process the req, and - add the network latency for our local timeout. */ + * add the network latency for our local timeout. + */ request->rq_deadline = request->rq_sent + request->rq_timeout + ptlrpc_at_get_net_latency(request); @@ -656,7 +665,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) cleanup_me: /* MEUnlink is safe; the PUT didn't even get off the ground, and * nobody apart from the PUT's target has the right nid+XID to - * access the reply buffer. */ + * access the reply buffer. + */ rc2 = LNetMEUnlink(reply_me_h); LASSERT(rc2 == 0); /* UNLINKED callback called synchronously */ @@ -664,7 +674,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) cleanup_bulk: /* We do sync unlink here as there was no real transfer here so - * the chance to have long unlink to sluggish net is smaller here. */ + * the chance to have long unlink to sluggish net is smaller here. + */ ptlrpc_unregister_bulk(request, 0); out: if (request->rq_memalloc) @@ -692,7 +703,8 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) /* NB: CPT affinity service should use new LNet flag LNET_INS_LOCAL, * which means buffer can only be attached on local CPT, and LND - * threads can find it by grabbing a local lock */ + * threads can find it by grabbing a local lock + */ rc = LNetMEAttach(service->srv_req_portal, match_id, 0, ~0, LNET_UNLINK, rqbd->rqbd_svcpt->scp_cpt >= 0 ? diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 7044e1ff6..710fb806f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -13,10 +13,6 @@ * GNU General Public License version 2 for more details. A copy is * included in the COPYING file that accompanied this code. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * * GPL HEADER END */ /* @@ -47,9 +43,6 @@ #include "../../include/linux/libcfs/libcfs.h" #include "ptlrpc_internal.h" -/* XXX: This is just for liblustre. Remove the #if defined directive when the - * "cfs_" prefix is dropped from cfs_list_head. */ - /** * NRS core object. */ @@ -57,7 +50,7 @@ struct nrs_core nrs_core; 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; } @@ -66,7 +59,7 @@ static void nrs_policy_fini(struct ptlrpc_nrs_policy *policy) 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); } @@ -82,7 +75,7 @@ static int nrs_policy_ctl_locked(struct ptlrpc_nrs_policy *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; } @@ -91,7 +84,7 @@ static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) { 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); @@ -154,7 +147,7 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) { struct ptlrpc_nrs_policy *tmp = nrs->nrs_policy_primary; - if (tmp == NULL) + if (!tmp) return; nrs->nrs_policy_primary = NULL; @@ -220,12 +213,12 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) * 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) @@ -311,7 +304,7 @@ static void nrs_policy_put_locked(struct ptlrpc_nrs_policy *policy) policy->pol_ref--; if (unlikely(policy->pol_ref == 0 && - policy->pol_state == NRS_POL_STATE_STOPPING)) + policy->pol_state == NRS_POL_STATE_STOPPING)) nrs_policy_stop0(policy); } @@ -326,7 +319,7 @@ static void nrs_policy_put(struct ptlrpc_nrs_policy *policy) * Find and return a policy by name. */ static struct ptlrpc_nrs_policy *nrs_policy_find_locked(struct ptlrpc_nrs *nrs, - char *name) + char *name) { struct ptlrpc_nrs_policy *tmp; @@ -348,10 +341,10 @@ static void nrs_resource_put(struct ptlrpc_nrs_resource *res) { 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); } @@ -390,12 +383,11 @@ struct ptlrpc_nrs_resource *nrs_resource_get(struct ptlrpc_nrs_policy *policy, 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; @@ -445,7 +437,7 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, 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); @@ -454,9 +446,9 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, * 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); /** @@ -465,7 +457,7 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, * 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); } } @@ -482,11 +474,10 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) { struct ptlrpc_nrs_policy *pols[NRS_RES_MAX]; - struct ptlrpc_nrs *nrs = NULL; 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; @@ -496,18 +487,9 @@ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) } for (i = 0; i < NRS_RES_MAX; i++) { - if (pols[i] == NULL) - continue; - - if (nrs == NULL) { - nrs = pols[i]->pol_nrs; - spin_lock(&nrs->nrs_lock); - } - nrs_policy_put_locked(pols[i]); + if (pols[i]) + nrs_policy_put(pols[i]); } - - if (nrs != NULL) - spin_unlock(&nrs->nrs_lock); } /** @@ -536,7 +518,7 @@ struct ptlrpc_nrs_request *nrs_request_get(struct ptlrpc_nrs_policy *policy, 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; } @@ -562,7 +544,7 @@ static inline void nrs_request_enqueue(struct ptlrpc_nrs_request *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; @@ -632,7 +614,7 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, spin_lock(&nrs->nrs_lock); policy = nrs_policy_find_locked(nrs, name); - if (policy == NULL) { + if (!policy) { rc = -ENOENT; goto out; } @@ -654,7 +636,7 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, break; } out: - if (policy != NULL) + if (policy) nrs_policy_put_locked(policy); spin_unlock(&nrs->nrs_lock); @@ -679,7 +661,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) 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); @@ -712,7 +694,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) nrs_policy_fini(policy); - LASSERT(policy->pol_private == NULL); + LASSERT(!policy->pol_private); kfree(policy); return 0; @@ -736,18 +718,16 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, 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; @@ -767,7 +747,7 @@ static int nrs_policy_register(struct ptlrpc_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); @@ -817,7 +797,7 @@ static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req) */ if (unlikely(list_empty(&policy->pol_list_queued))) list_add_tail(&policy->pol_list_queued, - &policy->pol_nrs->nrs_policy_queued); + &policy->pol_nrs->nrs_policy_queued); } /** @@ -957,14 +937,14 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) /** * 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; } @@ -998,8 +978,7 @@ again: nrs = nrs_svcpt2nrs(svcpt, hp); nrs->nrs_stopping = 1; - list_for_each_entry_safe(policy, tmp, &nrs->nrs_policy_list, - pol_list) { + list_for_each_entry_safe(policy, tmp, &nrs->nrs_policy_list, pol_list) { rc = nrs_policy_unregister(nrs, policy->pol_desc->pd_name); LASSERT(rc == 0); } @@ -1089,7 +1068,7 @@ again: } } - if (desc->pd_ops->op_lprocfs_fini != NULL) + if (desc->pd_ops->op_lprocfs_fini) desc->pd_ops->op_lprocfs_fini(svc); } @@ -1115,15 +1094,15 @@ static int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) { struct ptlrpc_service *svc; struct ptlrpc_nrs_pol_desc *desc; + size_t len; 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'; @@ -1146,7 +1125,7 @@ static int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) 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; @@ -1159,7 +1138,12 @@ static int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) goto fail; } - strncpy(desc->pd_name, conf->nc_name, NRS_POL_NAME_MAX); + len = strlcpy(desc->pd_name, conf->nc_name, sizeof(desc->pd_name)); + if (len >= sizeof(desc->pd_name)) { + kfree(desc); + rc = -E2BIG; + goto fail; + } desc->pd_ops = conf->nc_ops; desc->pd_compat = conf->nc_compat; desc->pd_compat_svc_name = conf->nc_compat_svc_name; @@ -1224,7 +1208,7 @@ again: * 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); @@ -1288,7 +1272,7 @@ int ptlrpc_service_nrs_setup(struct ptlrpc_service *svc) 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; @@ -1329,7 +1313,7 @@ void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc) 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); } @@ -1376,7 +1360,8 @@ void ptlrpc_nrs_req_finalize(struct ptlrpc_request *req) if (req->rq_nrq.nr_initialized) { nrs_resource_put_safe(req->rq_nrq.nr_res_ptrs); /* no protection on bit nr_initialized because no - * contention at this late stage */ + * contention at this late stage + */ req->rq_nrq.nr_finalized = 1; } } @@ -1434,7 +1419,7 @@ static void nrs_request_removed(struct ptlrpc_nrs_policy *policy) policy->pol_nrs->nrs_req_queued); list_move_tail(&policy->pol_list_queued, - &policy->pol_nrs->nrs_policy_queued); + &policy->pol_nrs->nrs_policy_queued); } } @@ -1466,10 +1451,9 @@ ptlrpc_nrs_req_get_nolock0(struct ptlrpc_service_part *svcpt, bool hp, * Always try to drain requests from all NRS polices even if they are * inactive, because the user can change policy status at runtime. */ - list_for_each_entry(policy, &nrs->nrs_policy_queued, - pol_list_queued) { + 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; @@ -1619,8 +1603,7 @@ void ptlrpc_nrs_fini(void) struct ptlrpc_nrs_pol_desc *desc; struct ptlrpc_nrs_pol_desc *tmp; - list_for_each_entry_safe(desc, tmp, &nrs_core.nrs_policies, - pd_list) { + list_for_each_entry_safe(desc, tmp, &nrs_core.nrs_policies, pd_list) { list_del_init(&desc->pd_list); kfree(desc); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c index 8e21f0cdc..b123a9324 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c @@ -13,10 +13,6 @@ * GNU General Public License version 2 for more details. A copy is * included in the COPYING file that accompanied this code. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * * GPL HEADER END */ /* @@ -83,7 +79,7 @@ static int nrs_fifo_start(struct ptlrpc_nrs_policy *policy) 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); @@ -104,7 +100,7 @@ static void nrs_fifo_stop(struct ptlrpc_nrs_policy *policy) { struct nrs_fifo_head *head = policy->pol_private; - LASSERT(head != NULL); + LASSERT(head); LASSERT(list_empty(&head->fh_list)); kfree(head); @@ -167,9 +163,9 @@ struct ptlrpc_nrs_request *nrs_fifo_req_get(struct ptlrpc_nrs_policy *policy, nrq = unlikely(list_empty(&head->fh_list)) ? NULL : list_entry(head->fh_list.next, struct ptlrpc_nrs_request, - nr_u.fifo.fr_list); + 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); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index f3cb5184f..492d63fad 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -133,7 +133,8 @@ EXPORT_SYMBOL(lustre_msg_size_v2); * NOTE: this should only be used for NEW requests, and should always be * in the form of a v2 request. If this is a connection to a v1 * target then the first buffer will be stripped because the ptlrpc - * data is part of the lustre_msg_v1 header. b=14043 */ + * data is part of the lustre_msg_v1 header. b=14043 + */ int lustre_msg_size(__u32 magic, int count, __u32 *lens) { __u32 size[] = { sizeof(struct ptlrpc_body) }; @@ -157,7 +158,8 @@ int lustre_msg_size(__u32 magic, int count, __u32 *lens) EXPORT_SYMBOL(lustre_msg_size); /* This is used to determine the size of a buffer that was already packed - * and will correctly handle the different message formats. */ + * and will correctly handle the different message formats. + */ int lustre_packed_msg_size(struct lustre_msg *msg) { switch (msg->lm_magic) { @@ -183,7 +185,7 @@ void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens, 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); @@ -267,7 +269,8 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) spin_unlock(&svcpt->scp_rep_lock); /* If we cannot get anything for some long time, we better - * bail out instead of waiting infinitely */ + * bail out instead of waiting infinitely + */ lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL); rc = l_wait_event(svcpt->scp_rep_waitq, !list_empty(&svcpt->scp_rep_idle), &lwi); @@ -277,7 +280,7 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) } rs = list_entry(svcpt->scp_rep_idle.next, - struct ptlrpc_reply_state, rs_list); + struct ptlrpc_reply_state, rs_list); list_del(&rs->rs_list); spin_unlock(&svcpt->scp_rep_lock); @@ -306,7 +309,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int 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); @@ -383,7 +386,6 @@ void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size) { int i, offset, buflen, bufcount; - LASSERT(m != NULL); LASSERT(n >= 0); bufcount = m->lm_bufcount; @@ -488,7 +490,7 @@ void lustre_free_reply_state(struct ptlrpc_reply_state *rs) 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)); @@ -677,7 +679,8 @@ int lustre_msg_buflen(struct lustre_msg *m, int n) EXPORT_SYMBOL(lustre_msg_buflen); /* NB return the bufcount for lustre_msg_v2 format, so if message is packed - * in V1 format, the result is one bigger. (add struct ptlrpc_body). */ + * in V1 format, the result is one bigger. (add struct ptlrpc_body). + */ int lustre_msg_bufcount(struct lustre_msg *m) { switch (m->lm_magic) { @@ -705,7 +708,7 @@ char *lustre_msg_string(struct lustre_msg *m, int index, int max_len) 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; } @@ -740,7 +743,6 @@ static inline void *__lustre_swab_buf(struct lustre_msg *msg, int index, { void *ptr = NULL; - LASSERT(msg != NULL); switch (msg->lm_magic) { case LUSTRE_MSG_MAGIC_V2: ptr = lustre_msg_buf_v2(msg, index, min_size); @@ -799,7 +801,8 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg) /* no break */ default: /* flags might be printed in debug code while message - * uninitialized */ + * uninitialized + */ return 0; } } @@ -1032,7 +1035,8 @@ int lustre_msg_get_status(struct lustre_msg *msg) /* no break */ default: /* status might be printed in debug code while message - * uninitialized */ + * uninitialized + */ return -EINVAL; } } @@ -1368,7 +1372,8 @@ void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid) struct ptlrpc_body *pb; /* Don't set jobid for ldlm ast RPCs, they've been shrunk. - * See the comment in ptlrpc_request_pack(). */ + * See the comment in ptlrpc_request_pack(). + */ if (!opc || opc == LDLM_BL_CALLBACK || opc == LDLM_CP_CALLBACK || opc == LDLM_GL_CALLBACK) return; @@ -1377,7 +1382,7 @@ void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid) 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); @@ -1427,7 +1432,7 @@ int do_set_info_async(struct obd_import *imp, 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, @@ -1488,7 +1493,8 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *b) * clients and servers without ptlrpc_body_v2 (< 2.3) * do not swab any fields beyond pb_jobid, as we are * using this swab function for both ptlrpc_body - * and ptlrpc_body_v2. */ + * and ptlrpc_body_v2. + */ CLASSERT(offsetof(typeof(*b), pb_jobid) != 0); } EXPORT_SYMBOL(lustre_swab_ptlrpc_body); @@ -1502,7 +1508,8 @@ void lustre_swab_connect(struct obd_connect_data *ocd) __swab32s(&ocd->ocd_index); __swab32s(&ocd->ocd_brw_size); /* ocd_blocksize and ocd_inodespace don't need to be swabbed because - * they are 8-byte values */ + * they are 8-byte values + */ __swab16s(&ocd->ocd_grant_extent); __swab32s(&ocd->ocd_unused); __swab64s(&ocd->ocd_transno); @@ -1512,7 +1519,8 @@ void lustre_swab_connect(struct obd_connect_data *ocd) /* Fields after ocd_cksum_types are only accessible by the receiver * if the corresponding flag in ocd_connect_flags is set. Accessing * any field after ocd_maxbytes on the receiver without a valid flag - * may result in out-of-bound memory access and kernel oops. */ + * may result in out-of-bound memory access and kernel oops. + */ if (ocd->ocd_connect_flags & OBD_CONNECT_MAX_EASIZE) __swab32s(&ocd->ocd_max_easize); if (ocd->ocd_connect_flags & OBD_CONNECT_MAXBYTES) @@ -1848,20 +1856,6 @@ void lustre_swab_fiemap(struct ll_user_fiemap *fiemap) } EXPORT_SYMBOL(lustre_swab_fiemap); -void lustre_swab_idx_info(struct idx_info *ii) -{ - __swab32s(&ii->ii_magic); - __swab32s(&ii->ii_flags); - __swab16s(&ii->ii_count); - __swab32s(&ii->ii_attrs); - lustre_swab_lu_fid(&ii->ii_fid); - __swab64s(&ii->ii_version); - __swab64s(&ii->ii_hash_start); - __swab64s(&ii->ii_hash_end); - __swab16s(&ii->ii_keysize); - __swab16s(&ii->ii_recsize); -} - void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr) { __swab32s(&rr->rr_opcode); @@ -1914,7 +1908,7 @@ static void print_lum(struct lov_user_md *lum) CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size); CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count); CDEBUG(D_OTHER, "\tlmm_stripe_offset/lmm_layout_gen: %#x\n", - lum->lmm_stripe_offset); + lum->lmm_stripe_offset); } static void lustre_swab_lmm_oi(struct ost_id *oi) @@ -1986,7 +1980,8 @@ static void lustre_swab_ldlm_policy_data(ldlm_wire_policy_data_t *d) { /* the lock data is a union and the first two fields are always an * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock - * data the same way. */ + * data the same way. + */ __swab64s(&d->l_extent.start); __swab64s(&d->l_extent.end); __swab64s(&d->l_extent.gid); @@ -2035,16 +2030,6 @@ void lustre_swab_ldlm_reply(struct ldlm_reply *r) } EXPORT_SYMBOL(lustre_swab_ldlm_reply); -void lustre_swab_quota_body(struct quota_body *b) -{ - lustre_swab_lu_fid(&b->qb_fid); - lustre_swab_lu_fid((struct lu_fid *)&b->qb_id); - __swab32s(&b->qb_flags); - __swab64s(&b->qb_count); - __swab64s(&b->qb_usage); - __swab64s(&b->qb_slv_ver); -} - /* Dump functions */ void dump_ioo(struct obd_ioobj *ioo) { @@ -2288,24 +2273,6 @@ void lustre_swab_hsm_request(struct hsm_request *hr) } EXPORT_SYMBOL(lustre_swab_hsm_request); -void lustre_swab_update_buf(struct update_buf *ub) -{ - __swab32s(&ub->ub_magic); - __swab32s(&ub->ub_count); -} -EXPORT_SYMBOL(lustre_swab_update_buf); - -void lustre_swab_update_reply_buf(struct update_reply *ur) -{ - int i; - - __swab32s(&ur->ur_version); - __swab32s(&ur->ur_count); - for (i = 0; i < ur->ur_count; i++) - __swab32s(&ur->ur_lens[i]); -} -EXPORT_SYMBOL(lustre_swab_update_reply_buf); - void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl) { __swab64s(&msl->msl_flags); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index fb2d5236a..8a869315c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -68,7 +68,7 @@ int ptlrpc_obd_ping(struct obd_device *obd) 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; @@ -86,7 +86,7 @@ static int ptlrpc_ping(struct obd_import *imp) 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)); @@ -242,7 +242,7 @@ static int ptlrpc_pinger_main(void *arg) list_for_each(iter, &pinger_imports) { struct obd_import *imp = list_entry(iter, struct obd_import, - imp_pinger_chain); + imp_pinger_chain); ptlrpc_pinger_process_import(imp, this_ping); /* obd_timeout might have changed */ @@ -257,11 +257,12 @@ static int ptlrpc_pinger_main(void *arg) /* Wait until the next ping time, or until we're stopped. */ time_to_next_wake = pinger_check_timeout(this_ping); /* The ping sent by ptlrpc_send_rpc may get sent out - say .01 second after this. - ptlrpc_pinger_sending_on_import will then set the - next ping time to next_ping + .01 sec, which means - we will SKIP the next ping at next_ping, and the - ping will get sent 2 timeouts from now! Beware. */ + * say .01 second after this. + * ptlrpc_pinger_sending_on_import will then set the + * next ping time to next_ping + .01 sec, which means + * we will SKIP the next ping at next_ping, and the + * ping will get sent 2 timeouts from now! Beware. + */ CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n", time_to_next_wake, cfs_time_add(this_ping, @@ -293,6 +294,7 @@ static struct ptlrpc_thread pinger_thread; int ptlrpc_start_pinger(void) { struct l_wait_info lwi = { 0 }; + struct task_struct *task; int rc; if (!thread_is_init(&pinger_thread) && @@ -303,10 +305,11 @@ int ptlrpc_start_pinger(void) strcpy(pinger_thread.t_name, "ll_ping"); - rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, &pinger_thread, - "%s", pinger_thread.t_name)); - if (IS_ERR_VALUE(rc)) { - CERROR("cannot start thread: %d\n", rc); + task = kthread_run(ptlrpc_pinger_main, &pinger_thread, + pinger_thread.t_name); + if (IS_ERR(task)) { + rc = PTR_ERR(task); + CERROR("cannot start pinger thread: rc = %d\n", rc); return rc; } l_wait_event(pinger_thread.t_ctl_waitq, @@ -401,7 +404,8 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import); * be called when timeout happens. */ static struct timeout_item *ptlrpc_new_timeout(int time, - enum timeout_event event, timeout_cb_t cb, void *data) + enum timeout_event event, + timeout_cb_t cb, void *data) { struct timeout_item *ti; @@ -489,7 +493,6 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list, break; } } - LASSERTF(ti != NULL, "ti is NULL !\n"); if (list_empty(&ti->ti_obd_list)) { list_del(&ti->ti_chain); kfree(ti); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 8f67e0562..6ca26c98d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -101,8 +101,6 @@ struct nrs_core { * registration/unregistration, and NRS core lprocfs operations. */ struct mutex nrs_mutex; - /* XXX: This is just for liblustre. Remove the #if defined directive - * when the * "cfs_" prefix is dropped from cfs_list_head. */ /** * List of all policy descriptors registered with NRS core; protected * by nrs_core::nrs_mutex. diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index c4f1d0f5d..a8ec0e9d7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -162,8 +162,8 @@ static void __exit ptlrpc_exit(void) MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Lustre Request Processor and Lock Management"); +MODULE_VERSION(LUSTRE_VERSION_STRING); MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0.0"); module_init(ptlrpc_init); module_exit(ptlrpc_exit); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 60fb0ced7..db003f5da 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -163,8 +163,6 @@ void ptlrpcd_wake(struct ptlrpc_request *req) { struct ptlrpc_request_set *rq_set = req->rq_set; - LASSERT(rq_set != NULL); - wake_up(&rq_set->set_waitq); } EXPORT_SYMBOL(ptlrpcd_wake); @@ -176,7 +174,7 @@ ptlrpcd_select_pc(struct ptlrpc_request *req) 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); @@ -209,11 +207,10 @@ static int ptlrpcd_steal_rqset(struct ptlrpc_request_set *des, if (likely(!list_empty(&src->set_new_requests))) { list_for_each_safe(pos, tmp, &src->set_new_requests) { req = list_entry(pos, struct ptlrpc_request, - rq_set_chain); + rq_set_chain); req->rq_set = des; } - list_splice_init(&src->set_new_requests, - &des->set_requests); + list_splice_init(&src->set_new_requests, &des->set_requests); rc = atomic_read(&src->set_new_count); atomic_add(rc, &des->set_remaining); atomic_set(&src->set_new_count, 0); @@ -240,10 +237,11 @@ void ptlrpcd_add_req(struct ptlrpc_request *req) 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. */ + * linked. + */ LASSERT(req->rq_phase == RQ_PHASE_NEW); LASSERT(req->rq_send_state == LUSTRE_IMP_REPLAY); @@ -286,9 +284,9 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) spin_lock(&set->set_new_req_lock); if (likely(!list_empty(&set->set_new_requests))) { list_splice_init(&set->set_new_requests, - &set->set_requests); + &set->set_requests); atomic_add(atomic_read(&set->set_new_count), - &set->set_remaining); + &set->set_remaining); atomic_set(&set->set_new_count, 0); /* * Need to calculate its timeout. @@ -321,7 +319,8 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) rc |= ptlrpc_check_set(env, set); /* NB: ptlrpc_check_set has already moved completed request at the - * head of seq::set_requests */ + * head of seq::set_requests + */ list_for_each_safe(pos, tmp, &set->set_requests) { req = list_entry(pos, struct ptlrpc_request, rq_set_chain); if (req->rq_phase != RQ_PHASE_COMPLETE) @@ -339,7 +338,8 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) rc = atomic_read(&set->set_new_count); /* If we have nothing to do, check whether we can take some - * work from our partner threads. */ + * work from our partner threads. + */ if (rc == 0 && pc->pc_npartners > 0) { struct ptlrpcd_ctl *partner; struct ptlrpc_request_set *ps; @@ -349,12 +349,12 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) 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; } @@ -422,7 +422,6 @@ static int ptlrpcd(void *arg) complete(&pc->pc_starting); /* - * This mainloop strongly resembles ptlrpc_set_wait() except that our * set never completes. ptlrpcd_check() calls ptlrpc_check_set() when * there are requests in the set. New requests come in on the set's @@ -580,7 +579,7 @@ int ptlrpcd_start(struct ptlrpcd_ctl *pc) 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); @@ -631,7 +630,7 @@ void ptlrpcd_free(struct ptlrpcd_ctl *pc) out: if (pc->pc_npartners > 0) { - LASSERT(pc->pc_partners != NULL); + LASSERT(pc->pc_partners); kfree(pc->pc_partners); pc->pc_partners = NULL; @@ -645,7 +644,7 @@ static void ptlrpcd_fini(void) int i; int j; - if (ptlrpcds != NULL) { + if (ptlrpcds) { for (i = 0; i < ptlrpcds_num; i++) { if (!ptlrpcds[i]) break; diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index db6626cab..30d9a164e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -107,14 +107,14 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) /* Replay all the committed open requests on committed_list first */ if (!list_empty(&imp->imp_committed_list)) { tmp = imp->imp_committed_list.prev; - req = list_entry(tmp, struct ptlrpc_request, - rq_replay_list); + req = list_entry(tmp, struct ptlrpc_request, rq_replay_list); /* The last request on committed_list hasn't been replayed */ if (req->rq_transno > last_transno) { /* Since the imp_committed_list is immutable before * all of it's requests being replayed, it's safe to - * use a cursor to accelerate the search */ + * use a cursor to accelerate the search + */ imp->imp_replay_cursor = imp->imp_replay_cursor->next; while (imp->imp_replay_cursor != @@ -137,8 +137,9 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) } /* All the requests in committed list have been replayed, let's replay - * the imp_replay_list */ - if (req == NULL) { + * the imp_replay_list + */ + if (!req) { list_for_each_safe(tmp, pos, &imp->imp_replay_list) { req = list_entry(tmp, struct ptlrpc_request, rq_replay_list); @@ -152,15 +153,16 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) /* If need to resend the last sent transno (because a reconnect * 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) + * continue replay from the next request. + */ + 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", @@ -192,9 +194,8 @@ int ptlrpc_resend(struct obd_import *imp) return -1; } - list_for_each_entry_safe(req, next, &imp->imp_sending_list, - rq_list) { - LASSERTF((long)req > PAGE_CACHE_SIZE && req != LP_POISON, + list_for_each_entry_safe(req, next, &imp->imp_sending_list, rq_list) { + LASSERTF((long)req > PAGE_SIZE && req != LP_POISON, "req %p bad\n", req); LASSERTF(req->rq_type != LI_POISON, "req %p freed\n", req); if (!ptlrpc_no_resend(req)) @@ -249,7 +250,8 @@ void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) } /* Wait for recovery to complete and resend. If evicted, then - this request will be errored out later.*/ + * this request will be errored out later. + */ spin_lock(&failed_req->rq_lock); if (!failed_req->rq_no_resend) failed_req->rq_resend = 1; @@ -260,7 +262,7 @@ void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) * Administratively active/deactive a client. * This should only be called by the ioctl interface, currently * - the lctl deactivate and activate commands - * - echo 0/1 >> /proc/osc/XXX/active + * - echo 0/1 >> /sys/fs/lustre/osc/XXX/active * - client umount -f (ll_umount_begin) */ int ptlrpc_set_import_active(struct obd_import *imp, int active) @@ -271,13 +273,15 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active) LASSERT(obd); /* When deactivating, mark import invalid, and abort in-flight - * requests. */ + * requests. + */ if (!active) { LCONSOLE_WARN("setting import %s INACTIVE by administrator request\n", obd2cli_tgt(imp->imp_obd)); /* set before invalidate to avoid messages about imp_inval - * set without imp_deactive in ptlrpc_import_delay_req */ + * set without imp_deactive in ptlrpc_import_delay_req + */ spin_lock(&imp->imp_lock); imp->imp_deactive = 1; spin_unlock(&imp->imp_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 39f5261c9..187fd1d68 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -94,7 +94,7 @@ int sptlrpc_unregister_policy(struct ptlrpc_sec_policy *policy) 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; @@ -126,11 +126,11 @@ struct ptlrpc_sec_policy *sptlrpc_wireflavor2policy(__u32 flavor) 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; @@ -327,7 +327,7 @@ static int import_sec_validate_get(struct obd_import *imp, } *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; @@ -429,7 +429,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, 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); } @@ -445,7 +445,8 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, /* alloc new request buffer * we don't need to alloc reply buffer here, leave it to the - * rest procedure of ptlrpc */ + * rest procedure of ptlrpc + */ if (reqmsg_size != 0) { rc = sptlrpc_cli_alloc_reqbuf(req, reqmsg_size); if (!rc) { @@ -609,7 +610,7 @@ again: if (sec->ps_flvr.sf_rpc != req->rq_flvr.sf_rpc) { CDEBUG(D_SEC, "req %p: flavor has changed %x -> %x\n", - req, req->rq_flvr.sf_rpc, sec->ps_flvr.sf_rpc); + req, req->rq_flvr.sf_rpc, sec->ps_flvr.sf_rpc); req_off_ctx_list(req, ctx); sptlrpc_req_replace_dead_ctx(req); ctx = req->rq_cli_ctx; @@ -798,7 +799,8 @@ void sptlrpc_req_set_flavor(struct ptlrpc_request *req, int opcode) spin_unlock(&sec->ps_lock); /* force SVC_NULL for context initiation rpc, SVC_INTG for context - * destruction rpc */ + * destruction rpc + */ if (unlikely(req->rq_ctx_init)) flvr_set_svc(&req->rq_flvr.sf_rpc, SPTLRPC_SVC_NULL); else if (unlikely(req->rq_ctx_fini)) @@ -938,7 +940,7 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) 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; @@ -1000,8 +1002,8 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) 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 && @@ -1046,13 +1048,13 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, 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; } @@ -1067,8 +1069,8 @@ int sptlrpc_cli_unwrap_early_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); if (req->rq_reply_off != 0) { CERROR("early reply with offset %u\n", req->rq_reply_off); @@ -1354,12 +1356,12 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, 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 @@ -1447,11 +1449,11 @@ static void import_flush_ctx_common(struct obd_import *imp, { 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); @@ -1484,7 +1486,7 @@ int sptlrpc_cli_alloc_reqbuf(struct ptlrpc_request *req, int msgsize) 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; @@ -1515,7 +1517,7 @@ void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req) 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; @@ -1632,7 +1634,7 @@ void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req) 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); @@ -1684,12 +1686,13 @@ int sptlrpc_target_export_check(struct obd_export *exp, { 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) + * FIXME maybe we should check flavor this as well??? + */ + if (!exp->exp_imp_reverse) return 0; /* don't care about ctx fini rpc */ @@ -1702,11 +1705,13 @@ int sptlrpc_target_export_check(struct obd_export *exp, * the first req with the new flavor, then treat it as current flavor, * adapt reverse sec according to it. * note the first rpc with new flavor might not be with root ctx, in - * which case delay the sec_adapt by leaving exp_flvr_adapt == 1. */ + * which case delay the sec_adapt by leaving exp_flvr_adapt == 1. + */ if (unlikely(exp->exp_flvr_changed) && flavor_allowed(&exp->exp_flvr_old[1], req)) { /* make the new flavor as "current", and old ones as - * about-to-expire */ + * about-to-expire + */ CDEBUG(D_SEC, "exp %p: just changed: %x->%x\n", exp, exp->exp_flvr.sf_rpc, exp->exp_flvr_old[1].sf_rpc); flavor = exp->exp_flvr_old[1]; @@ -1742,10 +1747,12 @@ int sptlrpc_target_export_check(struct obd_export *exp, } /* if it equals to the current flavor, we accept it, but need to - * dealing with reverse sec/ctx */ + * dealing with reverse sec/ctx + */ if (likely(flavor_allowed(&exp->exp_flvr, req))) { /* most cases should return here, we only interested in - * gss root ctx init */ + * gss root ctx init + */ if (!req->rq_auth_gss || !req->rq_ctx_init || (!req->rq_auth_usr_root && !req->rq_auth_usr_mdt && !req->rq_auth_usr_ost)) { @@ -1755,7 +1762,8 @@ int sptlrpc_target_export_check(struct obd_export *exp, /* if flavor just changed, we should not proceed, just leave * it and current flavor will be discovered and replaced - * shortly, and let _this_ rpc pass through */ + * shortly, and let _this_ rpc pass through + */ if (exp->exp_flvr_changed) { LASSERT(exp->exp_flvr_adapt); spin_unlock(&exp->exp_lock); @@ -1809,7 +1817,8 @@ int sptlrpc_target_export_check(struct obd_export *exp, } /* now it doesn't match the current flavor, the only chance we can - * accept it is match the old flavors which is not expired. */ + * accept it is match the old flavors which is not expired. + */ if (exp->exp_flvr_changed == 0 && exp->exp_flvr_expire[1]) { if (exp->exp_flvr_expire[1] >= ktime_get_real_seconds()) { if (flavor_allowed(&exp->exp_flvr_old[1], req)) { @@ -1915,9 +1924,9 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) 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; @@ -1986,15 +1995,15 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) if (svcpt->scp_service->srv_max_reply_size < msglen + sizeof(struct ptlrpc_reply_state)) { /* Just return failure if the size is too big */ - CERROR("size of message is too big (%zd), %d allowed", - msglen + sizeof(struct ptlrpc_reply_state), - svcpt->scp_service->srv_max_reply_size); + CERROR("size of message is too big (%zd), %d allowed\n", + msglen + sizeof(struct ptlrpc_reply_state), + svcpt->scp_service->srv_max_reply_size); return -ENOMEM; } /* failed alloc, try emergency pool */ rs = lustre_get_emerg_rs(svcpt); - if (rs == NULL) + if (!rs) return -ENOMEM; req->rq_reply_state = rs; @@ -2059,7 +2068,7 @@ void sptlrpc_svc_ctx_addref(struct ptlrpc_request *req) { struct ptlrpc_svc_ctx *ctx = req->rq_svc_ctx; - if (ctx != NULL) + if (ctx) atomic_inc(&ctx->sc_refcount); } @@ -2067,7 +2076,7 @@ void sptlrpc_svc_ctx_decref(struct ptlrpc_request *req) { struct ptlrpc_svc_ctx *ctx = req->rq_svc_ctx; - if (ctx == NULL) + if (!ctx) return; LASSERT_ATOMIC_POS(&ctx->sc_refcount); @@ -2156,7 +2165,7 @@ int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req, * in case of privacy mode, nob_transferred needs to be adjusted. */ if (desc->bd_nob != desc->bd_nob_transferred) { - CERROR("nob %d doesn't match transferred nob %d", + CERROR("nob %d doesn't match transferred nob %d\n", desc->bd_nob, desc->bd_nob_transferred); return -EPROTO; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 6152c1b76..d3872b8c9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -58,7 +58,7 @@ * bulk encryption page pools * ****************************************/ -#define POINTERS_PER_PAGE (PAGE_CACHE_SIZE / sizeof(void *)) +#define POINTERS_PER_PAGE (PAGE_SIZE / sizeof(void *)) #define PAGES_PER_POOL (POINTERS_PER_PAGE) #define IDLE_IDX_MAX (100) @@ -120,7 +120,7 @@ static struct ptlrpc_enc_page_pool { } page_pools; /* - * /proc/fs/lustre/sptlrpc/encrypt_page_pools + * /sys/kernel/debug/lustre/sptlrpc/encrypt_page_pools */ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) { @@ -195,7 +195,7 @@ static void enc_pools_release_free_pages(long npages) 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; @@ -304,7 +304,6 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) static inline void enc_pools_wakeup(void) { assert_spin_locked(&page_pools.epp_lock); - LASSERT(page_pools.epp_waitqlen >= 0); if (unlikely(page_pools.epp_waitqlen)) { LASSERT(waitqueue_active(&page_pools.epp_waitq)); @@ -317,7 +316,7 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) 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); @@ -332,9 +331,9 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) 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; @@ -413,7 +412,7 @@ int sptlrpc_enc_pool_init(void) 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); @@ -476,7 +475,7 @@ int bulk_sec_desc_unpack(struct lustre_msg *msg, int offset, int swabbed) 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; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 4b0b81c11..a51b18bbf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -78,7 +78,7 @@ int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr) memset(flvr, 0, sizeof(*flvr)); - if (str == NULL || str[0] == '\0') { + if (!str || str[0] == '\0') { flvr->sf_rpc = SPTLRPC_FLVR_INVALID; return 0; } @@ -103,7 +103,7 @@ int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr) * format: plain-hash:<hash_alg> */ alg = strchr(bulk, ':'); - if (alg == NULL) + if (!alg) goto err_out; *alg++ = '\0'; @@ -166,7 +166,7 @@ static int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) sptlrpc_rule_init(rule); flavor = strchr(param, '='); - if (flavor == NULL) { + if (!flavor) { CERROR("invalid param, no '='\n"); return -EINVAL; } @@ -216,7 +216,7 @@ static int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) 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); @@ -241,7 +241,7 @@ static int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) /* 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) { @@ -450,7 +450,7 @@ static void target2fsname(const char *tgt, char *fsname, int buflen) } /* 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; @@ -467,7 +467,7 @@ static void sptlrpc_conf_free_rsets(struct sptlrpc_conf *conf) sptlrpc_rule_set_free(&conf->sc_rset); list_for_each_entry_safe(conf_tgt, conf_tgt_next, - &conf->sc_tgts, sct_list) { + &conf->sc_tgts, sct_list) { sptlrpc_rule_set_free(&conf_tgt->sct_rset); list_del(&conf_tgt->sct_list); kfree(conf_tgt); @@ -517,6 +517,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname, int create) { struct sptlrpc_conf *conf; + size_t len; list_for_each_entry(conf, &sptlrpc_confs, sc_list) { if (strcmp(conf->sc_fsname, fsname) == 0) @@ -530,7 +531,11 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname, if (!conf) return NULL; - strcpy(conf->sc_fsname, fsname); + len = strlcpy(conf->sc_fsname, fsname, sizeof(conf->sc_fsname)); + if (len >= sizeof(conf->sc_fsname)) { + kfree(conf); + return NULL; + } sptlrpc_rule_set_init(&conf->sc_rset); INIT_LIST_HEAD(&conf->sc_tgts); list_add(&conf->sc_list, &sptlrpc_confs); @@ -579,13 +584,13 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, 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; } @@ -603,12 +608,12 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, 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 { @@ -638,7 +643,7 @@ static int logname2fsname(const char *logname, char *buf, int buflen) 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; } @@ -772,7 +777,7 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, 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 */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 6e58d5f95..9082da06b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -109,7 +109,7 @@ static void sec_process_ctx_list(void) while (!list_empty(&sec_gc_ctx_list)) { ctx = list_entry(sec_gc_ctx_list.next, - struct ptlrpc_cli_ctx, cc_gc_chain); + struct ptlrpc_cli_ctx, cc_gc_chain); list_del_init(&ctx->cc_gc_chain); spin_unlock(&sec_gc_ctx_list_lock); @@ -131,7 +131,7 @@ static void sec_do_gc(struct ptlrpc_sec *sec) if (unlikely(sec->ps_gc_next == 0)) { CDEBUG(D_SEC, "sec %p(%s) has 0 gc time\n", - sec, sec->ps_policy->sp_name); + sec, sec->ps_policy->sp_name); return; } @@ -166,11 +166,13 @@ again: * is not optimal. we perhaps want to use balanced binary tree * to trace each sec as order of expiry time. * another issue here is we wakeup as fixed interval instead of - * according to each sec's expiry time */ + * according to each sec's expiry time + */ mutex_lock(&sec_gc_mutex); list_for_each_entry(sec, &sec_gc_list, ps_gc_list) { /* if someone is waiting to be deleted, let it - * proceed as soon as possible. */ + * proceed as soon as possible. + */ if (atomic_read(&sec_gc_wait_del)) { CDEBUG(D_SEC, "deletion pending, start over\n"); mutex_unlock(&sec_gc_mutex); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index bda9a77af..e610a8ddd 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -82,7 +82,7 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) 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)); @@ -121,7 +121,7 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v) 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) @@ -178,7 +178,7 @@ int sptlrpc_lproc_init(void) { int rc; - LASSERT(sptlrpc_debugfs_dir == NULL); + LASSERT(!sptlrpc_debugfs_dir); sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root, sptlrpc_lprocfs_vars, NULL); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index ebfa6092b..40e5349de 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -250,7 +250,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, 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 @@ -258,7 +258,8 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, * imp_replay_list traversing threads. See LU-3333 * This is a bandaid at best, we really need to deal with this * in request enlarging code before unpacking that's already - * there */ + * there + */ if (req->rq_import) spin_lock(&req->rq_import->imp_lock); memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen); @@ -319,7 +320,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize) 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; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 905a41451..6276bf59c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -104,7 +104,7 @@ static int plain_unpack_bsd(struct lustre_msg *msg, int swabbed) 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; @@ -227,7 +227,7 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) 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; } @@ -264,7 +264,8 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) } } else { /* whether we sent with bulk or not, we expect the same - * in reply, except for early reply */ + * in reply, except for early reply + */ if (!req->rq_early && !equi(req->rq_pack_bulk == 1, phdr->ph_flags & PLAIN_FL_BULK)) { @@ -419,7 +420,7 @@ void plain_destroy_sec(struct ptlrpc_sec *sec) 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); @@ -468,7 +469,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, /* 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; } @@ -492,7 +493,7 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec, 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; @@ -665,7 +666,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, 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 @@ -673,7 +674,8 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, * imp_replay_list traversing threads. See LU-3333 * This is a bandaid at best, we really need to deal with this * in request enlarging code before unpacking that's already - * there */ + * there + */ if (req->rq_import) spin_lock(&req->rq_import->imp_lock); @@ -732,7 +734,7 @@ int plain_accept(struct ptlrpc_request *req) 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; } @@ -801,7 +803,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) 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; diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 8598300a6..1bbd1d39c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -77,7 +77,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) 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; @@ -89,7 +89,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) svcpt->scp_cpt, svc->srv_buf_size, GFP_KERNEL); - if (rqbd->rqbd_buffer == NULL) { + if (!rqbd->rqbd_buffer) { kfree(rqbd); return NULL; } @@ -144,13 +144,14 @@ ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post) for (i = 0; i < svc->srv_nbuf_per_group; i++) { /* NB: another thread might have recycled enough rqbds, we - * need to make sure it wouldn't over-allocate, see LU-1212. */ + * need to make sure it wouldn't over-allocate, see LU-1212. + */ if (svcpt->scp_nrqbds_posted >= svc->srv_nbuf_per_group) break; rqbd = ptlrpc_alloc_rqbd(svcpt); - if (rqbd == NULL) { + if (!rqbd) { CERROR("%s: Can't allocate request buffer\n", svc->srv_name); rc = -ENOMEM; @@ -298,8 +299,8 @@ ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt) } rqbd = list_entry(svcpt->scp_rqbd_idle.next, - struct ptlrpc_request_buffer_desc, - rqbd_list); + struct ptlrpc_request_buffer_desc, + rqbd_list); list_del(&rqbd->rqbd_list); /* assume we will post successfully */ @@ -322,7 +323,8 @@ ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt) list_add_tail(&rqbd->rqbd_list, &svcpt->scp_rqbd_idle); /* Don't complain if no request buffers are posted right now; LNET - * won't drop requests because we set the portal lazy! */ + * won't drop requests because we set the portal lazy! + */ spin_unlock(&svcpt->scp_lock); @@ -363,13 +365,15 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, init = max_t(int, init, tc->tc_nthrs_init); /* NB: please see comments in lustre_lnet.h for definition - * details of these members */ + * details of these members + */ LASSERT(tc->tc_nthrs_max != 0); if (tc->tc_nthrs_user != 0) { /* In case there is a reason to test a service with many * threads, we give a less strict check here, it can - * be up to 8 * nthrs_max */ + * be up to 8 * nthrs_max + */ total = min(tc->tc_nthrs_max * 8, tc->tc_nthrs_user); nthrs = total / svc->srv_ncpts; init = max(init, nthrs); @@ -379,7 +383,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, total = tc->tc_nthrs_max; if (tc->tc_nthrs_base == 0) { /* don't care about base threads number per partition, - * this is most for non-affinity service */ + * this is most for non-affinity service + */ nthrs = total / svc->srv_ncpts; goto out; } @@ -390,7 +395,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, /* NB: Increase the base number if it's single partition * and total number of cores/HTs is larger or equal to 4. - * result will always < 2 * nthrs_base */ + * result will always < 2 * nthrs_base + */ weight = cfs_cpt_weight(svc->srv_cptable, CFS_CPT_ANY); for (i = 1; (weight >> (i + 1)) != 0 && /* >= 4 cores/HTs */ (tc->tc_nthrs_base >> i) != 0; i++) @@ -490,7 +496,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, 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++) @@ -499,14 +505,15 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, 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, (unsigned long)svcpt); /* At SOW, service time should be quick; 10s seems generous. If client - * timeout is less than this, we'll be sending an early reply. */ + * timeout is less than this, we'll be sending an early reply. + */ at_init(&svcpt->scp_at_estimate, 10, 0); /* assign this before call ptlrpc_grow_req_bufs */ @@ -514,7 +521,8 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, /* Now allocate the request buffers, but don't post them now */ rc = ptlrpc_grow_req_bufs(svcpt, 0); /* We shouldn't be under memory pressure at startup, so - * fail if we can't allocate all our buffers at this time. */ + * fail if we can't allocate all our buffers at this time. + */ if (rc != 0) goto free_reqs_count; @@ -556,14 +564,14 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, 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, @@ -632,11 +640,11 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, 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; } @@ -696,7 +704,8 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req) LASSERT(list_empty(&req->rq_timed_list)); /* DEBUG_REQ() assumes the reply state of a request with a valid - * ref will not be destroyed until that reference is dropped. */ + * ref will not be destroyed until that reference is dropped. + */ ptlrpc_req_drop_rs(req); sptlrpc_svc_ctx_decref(req); @@ -704,7 +713,8 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req) if (req != &req->rq_rqbd->rqbd_req) { /* NB request buffers use an embedded * req if the incoming req unlinked the - * MD; this isn't one of them! */ + * MD; this isn't one of them! + */ ptlrpc_request_cache_free(req); } } @@ -728,7 +738,8 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) if (req->rq_at_linked) { spin_lock(&svcpt->scp_at_lock); /* recheck with lock, in case it's unlinked by - * ptlrpc_at_check_timed() */ + * ptlrpc_at_check_timed() + */ if (likely(req->rq_at_linked)) ptlrpc_at_remove_timed(req); spin_unlock(&svcpt->scp_at_lock); @@ -755,20 +766,22 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) svcpt->scp_hist_nrqbds++; /* cull some history? - * I expect only about 1 or 2 rqbds need to be recycled here */ + * I expect only about 1 or 2 rqbds need to be recycled here + */ while (svcpt->scp_hist_nrqbds > svc->srv_hist_nrqbds_cpt_max) { rqbd = list_entry(svcpt->scp_hist_rqbds.next, - struct ptlrpc_request_buffer_desc, - rqbd_list); + struct ptlrpc_request_buffer_desc, + rqbd_list); list_del(&rqbd->rqbd_list); svcpt->scp_hist_nrqbds--; /* remove rqbd's reqs from svc's req history while - * I've got the service lock */ + * I've got the service lock + */ list_for_each(tmp, &rqbd->rqbd_reqs) { req = list_entry(tmp, struct ptlrpc_request, - rq_list); + rq_list); /* Track the highest culled req seq */ if (req->rq_history_seq > svcpt->scp_hist_seq_culled) { @@ -782,8 +795,8 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) list_for_each_safe(tmp, nxt, &rqbd->rqbd_reqs) { req = list_entry(rqbd->rqbd_reqs.next, - struct ptlrpc_request, - rq_list); + struct ptlrpc_request, + rq_list); list_del(&req->rq_list); ptlrpc_server_free_request(req); } @@ -795,8 +808,7 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) */ LASSERT(atomic_read(&rqbd->rqbd_req.rq_refcount) == 0); - list_add_tail(&rqbd->rqbd_list, - &svcpt->scp_rqbd_idle); + list_add_tail(&rqbd->rqbd_list, &svcpt->scp_rqbd_idle); } spin_unlock(&svcpt->scp_lock); @@ -846,7 +858,7 @@ static void ptlrpc_server_finish_active_request( 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); @@ -869,13 +881,13 @@ static int ptlrpc_check_req(struct ptlrpc_request *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)) { @@ -942,13 +954,13 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req) div_u64_rem(req->rq_deadline, array->paa_size, &index); if (array->paa_reqs_count[index] > 0) { /* latest rpcs will have the latest deadlines in the list, - * so search backward. */ - list_for_each_entry_reverse(rq, - &array->paa_reqs_array[index], - rq_timed_list) { + * so search backward. + */ + list_for_each_entry_reverse(rq, &array->paa_reqs_array[index], + rq_timed_list) { if (req->rq_deadline >= rq->rq_deadline) { list_add(&req->rq_timed_list, - &rq->rq_timed_list); + &rq->rq_timed_list); break; } } @@ -956,8 +968,7 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req) /* Add the request at the head of the list */ if (list_empty(&req->rq_timed_list)) - list_add(&req->rq_timed_list, - &array->paa_reqs_array[index]); + list_add(&req->rq_timed_list, &array->paa_reqs_array[index]); spin_lock(&req->rq_lock); req->rq_at_linked = 1; @@ -1003,7 +1014,8 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) int rc; /* deadline is when the client expects us to reply, margin is the - difference between clients' and servers' expectations */ + * difference between clients' and servers' expectations + */ DEBUG_REQ(D_ADAPTTO, req, "%ssending early reply (deadline %+lds, margin %+lds) for %d+%d", AT_OFF ? "AT off - not " : "", @@ -1027,12 +1039,14 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) } /* Fake our processing time into the future to ask the clients - * for some extra amount of time */ + * for some extra amount of time + */ at_measured(&svcpt->scp_at_estimate, at_extra + ktime_get_real_seconds() - req->rq_arrival_time.tv_sec); /* Check to see if we've actually increased the deadline - - * we may be past adaptive_max */ + * we may be past adaptive_max + */ if (req->rq_deadline >= req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate)) { DEBUG_REQ(D_WARNING, req, "Couldn't add any time (%ld/%lld), not sending early reply\n", @@ -1044,7 +1058,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) 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) { @@ -1074,7 +1088,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) /* 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; } @@ -1102,7 +1116,8 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) } /* Free the (early) reply state from lustre_pack_reply. - (ptlrpc_send_reply takes it's own rs ref, so this is safe here) */ + * (ptlrpc_send_reply takes it's own rs ref, so this is safe here) + */ ptlrpc_req_drop_rs(reqcopy); out_put: @@ -1117,8 +1132,9 @@ out_free: } /* Send early replies to everybody expiring within at_early_margin - asking for at_extra time */ -static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) + * asking for at_extra time + */ +static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) { struct ptlrpc_at_array *array = &svcpt->scp_at_array; struct ptlrpc_request *rq, *n; @@ -1132,14 +1148,14 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) spin_lock(&svcpt->scp_at_lock); if (svcpt->scp_at_check == 0) { spin_unlock(&svcpt->scp_at_lock); - return 0; + return; } delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime); svcpt->scp_at_check = 0; if (array->paa_count == 0) { spin_unlock(&svcpt->scp_at_lock); - return 0; + return; } /* The timer went off, but maybe the nearest rpc already completed. */ @@ -1148,20 +1164,20 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) /* We've still got plenty of time. Reset the timer. */ ptlrpc_at_set_timer(svcpt); spin_unlock(&svcpt->scp_at_lock); - return 0; + return; } /* We're close to a timeout, and we don't know how much longer the - server will take. Send early replies to everyone expiring soon. */ + * server will take. Send early replies to everyone expiring soon. + */ INIT_LIST_HEAD(&work_list); deadline = -1; div_u64_rem(array->paa_deadline, array->paa_size, &index); count = array->paa_count; while (count > 0) { count -= array->paa_reqs_count[index]; - list_for_each_entry_safe(rq, n, - &array->paa_reqs_array[index], - rq_timed_list) { + list_for_each_entry_safe(rq, n, &array->paa_reqs_array[index], + rq_timed_list) { if (rq->rq_deadline > now + at_early_margin) { /* update the earliest deadline */ if (deadline == -1 || @@ -1194,7 +1210,8 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) first, at_extra, counter); if (first < 0) { /* We're already past request deadlines before we even get a - chance to send early replies */ + * chance to send early replies + */ LCONSOLE_WARN("%s: This server is not able to keep up with request traffic (cpu-bound).\n", svcpt->scp_service->srv_name); CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=%ld(jiff)\n", @@ -1204,10 +1221,11 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) } /* we took additional refcount so entries can't be deleted from list, no - * locking is needed */ + * locking is needed + */ while (!list_empty(&work_list)) { rq = list_entry(work_list.next, struct ptlrpc_request, - rq_timed_list); + rq_timed_list); list_del_init(&rq->rq_timed_list); if (ptlrpc_at_send_early_reply(rq) == 0) @@ -1215,8 +1233,6 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) ptlrpc_server_drop_request(rq); } - - return 1; /* return "did_something" for liblustre */ } /** @@ -1237,7 +1253,8 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, if (req->rq_export && req->rq_ops) { /* Perform request specific check. We should do this check * before the request is added into exp_hp_rpcs list otherwise - * it may hit swab race at LU-1044. */ + * it may hit swab race at LU-1044. + */ if (req->rq_ops->hpreq_check) { rc = req->rq_ops->hpreq_check(req); /** @@ -1257,8 +1274,7 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, } spin_lock_bh(&req->rq_export->exp_rpc_lock); - list_add(&req->rq_exp_list, - &req->rq_export->exp_hp_rpcs); + list_add(&req->rq_exp_list, &req->rq_export->exp_hp_rpcs); spin_unlock_bh(&req->rq_export->exp_rpc_lock); } @@ -1272,7 +1288,8 @@ static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req) { if (req->rq_export && req->rq_ops) { /* refresh lock timeout again so that client has more - * room to send lock cancel RPC. */ + * room to send lock cancel RPC. + */ if (req->rq_ops->hpreq_fini) req->rq_ops->hpreq_fini(req); @@ -1316,7 +1333,7 @@ static bool ptlrpc_server_allow_high(struct ptlrpc_service_part *svcpt, 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; } @@ -1355,7 +1372,7 @@ static bool ptlrpc_server_allow_normal(struct ptlrpc_service_part *svcpt, 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; } @@ -1405,7 +1422,7 @@ ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) 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; } @@ -1413,7 +1430,7 @@ ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) 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; } @@ -1457,11 +1474,12 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, } req = list_entry(svcpt->scp_req_incoming.next, - struct ptlrpc_request, rq_list); + struct ptlrpc_request, rq_list); list_del_init(&req->rq_list); svcpt->scp_nreqs_incoming--; /* Consider this still a "queued" request as far as stats are - * concerned */ + * concerned + */ spin_unlock(&svcpt->scp_lock); /* go through security check/transform */ @@ -1598,7 +1616,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, 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)) @@ -1620,7 +1638,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, 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, @@ -1652,7 +1670,8 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, } /* Discard requests queued for longer than the deadline. - The deadline is increased if we send an early reply. */ + * The deadline is increased if we send an early reply. + */ if (ktime_get_real_seconds() > request->rq_deadline) { DEBUG_REQ(D_ERROR, request, "Dropping timed-out request from %s: deadline " CFS_DURATION_T ":" CFS_DURATION_T "s ago\n", libcfs_id2str(request->rq_peer), @@ -1718,7 +1737,7 @@ put_conn: 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); @@ -1804,7 +1823,8 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) if (nlocks == 0 && !been_handled) { /* If we see this, we should already have seen the warning - * in mds_steal_ack_locks() */ + * in mds_steal_ack_locks() + */ CDEBUG(D_HA, "All locks stolen from rs %p x%lld.t%lld o%d NID %s\n", rs, rs->rs_xid, rs->rs_transno, rs->rs_opc, @@ -1858,7 +1878,8 @@ ptlrpc_check_rqbd_pool(struct ptlrpc_service_part *svcpt) /* CAVEAT EMPTOR: We might be allocating buffers here because we've * allowed the request history to grow out of control. We could put a * sanity check on that here and cull some history if we need the - * space. */ + * space. + */ if (avail <= low_water) ptlrpc_grow_req_bufs(svcpt, 1); @@ -1992,7 +2013,8 @@ static int ptlrpc_main(void *arg) /* NB: we will call cfs_cpt_bind() for all threads, because we * might want to run lustre server only on a subset of system CPUs, - * in that case ->scp_cpt is CFS_CPT_ANY */ + * in that case ->scp_cpt is CFS_CPT_ANY + */ rc = cfs_cpt_bind(svc->srv_cptable, svcpt->scp_cpt); if (rc != 0) { CWARN("%s: failed to bind %s on CPT %d\n", @@ -2008,7 +2030,7 @@ static int ptlrpc_main(void *arg) 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; @@ -2035,7 +2057,7 @@ static int ptlrpc_main(void *arg) continue; CERROR("Failed to post rqbd for %s on CPT %d: %d\n", - svc->srv_name, svcpt->scp_cpt, rc); + svc->srv_name, svcpt->scp_cpt, rc); goto out_srv_fini; } @@ -2057,7 +2079,8 @@ static int ptlrpc_main(void *arg) /* SVC_STOPPING may already be set here if someone else is trying * to stop the service while this new thread has been dynamically * forked. We still set SVC_RUNNING to let our creator know that - * we are now running, however we will exit as soon as possible */ + * we are now running, however we will exit as soon as possible + */ thread_add_flags(thread, SVC_RUNNING); svcpt->scp_nthrs_running++; spin_unlock(&svcpt->scp_lock); @@ -2116,7 +2139,8 @@ static int ptlrpc_main(void *arg) ptlrpc_server_post_idle_rqbds(svcpt) < 0) { /* I just failed to repost request buffers. * Wait for a timeout (unless something else - * happens) before I try again */ + * happens) before I try again + */ svcpt->scp_rqbd_timeout = cfs_time_seconds(1) / 10; CDEBUG(D_RPCTRACE, "Posted buffers: %d\n", svcpt->scp_nrqbds_posted); @@ -2132,10 +2156,10 @@ out_srv_fini: /* * 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); } @@ -2183,7 +2207,7 @@ static int ptlrpc_hr_main(void *arg) { struct ptlrpc_hr_thread *hrt = arg; struct ptlrpc_hr_partition *hrp = hrt->hrt_partition; - LIST_HEAD (replies); + LIST_HEAD(replies); char threadname[20]; int rc; @@ -2206,9 +2230,8 @@ static int ptlrpc_hr_main(void *arg) while (!list_empty(&replies)) { struct ptlrpc_reply_state *rs; - rs = list_entry(replies.prev, - struct ptlrpc_reply_state, - rs_list); + rs = list_entry(replies.prev, struct ptlrpc_reply_state, + rs_list); list_del_init(&rs->rs_list); ptlrpc_handle_rs(rs); } @@ -2229,18 +2252,18 @@ static void ptlrpc_stop_hr_threads(void) 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) == - atomic_read(&hrp->hrp_nstarted)); + atomic_read(&hrp->hrp_nstopped) == + atomic_read(&hrp->hrp_nstarted)); } } @@ -2255,24 +2278,26 @@ static int ptlrpc_start_hr_threads(void) for (j = 0; j < hrp->hrp_nthrs; j++) { struct ptlrpc_hr_thread *hrt = &hrp->hrp_thrs[j]; - - rc = PTR_ERR(kthread_run(ptlrpc_hr_main, - &hrp->hrp_thrs[j], - "ptlrpc_hr%02d_%03d", - hrp->hrp_cpt, - hrt->hrt_id)); - if (IS_ERR_VALUE(rc)) + struct task_struct *task; + + task = kthread_run(ptlrpc_hr_main, + &hrp->hrp_thrs[j], + "ptlrpc_hr%02d_%03d", + hrp->hrp_cpt, hrt->hrt_id); + if (IS_ERR(task)) { + rc = PTR_ERR(task); break; + } } wait_event(ptlrpc_hr.hr_waitq, - atomic_read(&hrp->hrp_nstarted) == j); - if (!IS_ERR_VALUE(rc)) - continue; + atomic_read(&hrp->hrp_nstarted) == j); - CERROR("Reply handling thread %d:%d Failed on starting: rc = %d\n", - i, j, rc); - ptlrpc_stop_hr_threads(); - return rc; + if (rc < 0) { + CERROR("cannot start reply handler thread %d:%d: rc = %d\n", + i, j, rc); + ptlrpc_stop_hr_threads(); + return rc; + } } return 0; } @@ -2281,7 +2306,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) { struct l_wait_info lwi = { 0 }; struct ptlrpc_thread *thread; - LIST_HEAD (zombie); + LIST_HEAD(zombie); CDEBUG(D_INFO, "Stopping threads for service %s\n", svcpt->scp_service->srv_name); @@ -2298,7 +2323,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) while (!list_empty(&svcpt->scp_threads)) { thread = list_entry(svcpt->scp_threads.next, - struct ptlrpc_thread, t_link); + struct ptlrpc_thread, t_link); if (thread_is_stopped(thread)) { list_del(&thread->t_link); list_add(&thread->t_link, &zombie); @@ -2333,7 +2358,7 @@ static void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) int i; ptlrpc_service_for_each_part(svcpt, i, svc) { - if (svcpt->scp_service != NULL) + if (svcpt->scp_service) ptlrpc_svcpt_stop_threads(svcpt); } } @@ -2374,10 +2399,9 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) struct l_wait_info lwi = { 0 }; struct ptlrpc_thread *thread; struct ptlrpc_service *svc; + 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", @@ -2396,7 +2420,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) 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); @@ -2409,7 +2433,8 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) if (svcpt->scp_nthrs_starting != 0) { /* serialize starting because some modules (obdfilter) - * might require unique and contiguous t_id */ + * might require unique and contiguous t_id + */ LASSERT(svcpt->scp_nthrs_starting == 1); spin_unlock(&svcpt->scp_lock); kfree(thread); @@ -2442,9 +2467,10 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) } CDEBUG(D_RPCTRACE, "starting thread '%s'\n", thread->t_name); - rc = PTR_ERR(kthread_run(ptlrpc_main, thread, "%s", thread->t_name)); - if (IS_ERR_VALUE(rc)) { - CERROR("cannot start thread '%s': rc %d\n", + task = kthread_run(ptlrpc_main, thread, "%s", thread->t_name); + if (IS_ERR(task)) { + rc = PTR_ERR(task); + CERROR("cannot start thread '%s': rc = %d\n", thread->t_name, rc); spin_lock(&svcpt->scp_lock); --svcpt->scp_nthrs_starting; @@ -2488,7 +2514,7 @@ int ptlrpc_hr_init(void) 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); @@ -2509,7 +2535,7 @@ int ptlrpc_hr_init(void) 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; } @@ -2537,7 +2563,7 @@ void ptlrpc_hr_fini(void) struct ptlrpc_hr_partition *hrp; int i; - if (ptlrpc_hr.hr_partitions == NULL) + if (!ptlrpc_hr.hr_partitions) return; ptlrpc_stop_hr_threads(); @@ -2577,7 +2603,7 @@ ptlrpc_service_del_atimer(struct ptlrpc_service *svc) /* 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); } } @@ -2592,18 +2618,20 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) int i; /* All history will be culled when the next request buffer is - * freed in ptlrpc_service_purge_all() */ + * freed in ptlrpc_service_purge_all() + */ svc->srv_hist_nrqbds_cpt_max = 0; rc = LNetClearLazyPortal(svc->srv_req_portal); 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' - * event with its 'unlink' flag set for each posted rqbd */ + * event with its 'unlink' flag set for each posted rqbd + */ list_for_each_entry(rqbd, &svcpt->scp_rqbd_posted, rqbd_list) { rc = LNetMDUnlink(rqbd->rqbd_md_h); @@ -2612,17 +2640,19 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc) } 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 - * it's currently filling */ + * it's currently filling + */ spin_lock(&svcpt->scp_lock); while (svcpt->scp_nrqbds_posted != 0) { spin_unlock(&svcpt->scp_lock); /* Network access will complete in finite time but * the HUGE timeout lets us CWARN for visibility - * of sluggish NALs */ + * of sluggish LNDs + */ lwi = LWI_TIMEOUT_INTERVAL( cfs_time_seconds(LONG_UNLINK), cfs_time_seconds(1), NULL, NULL); @@ -2648,13 +2678,13 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) 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); while (!list_empty(&svcpt->scp_rep_active)) { rs = list_entry(svcpt->scp_rep_active.next, - struct ptlrpc_reply_state, rs_list); + struct ptlrpc_reply_state, rs_list); spin_lock(&rs->rs_lock); ptlrpc_schedule_difficult_reply(rs); spin_unlock(&rs->rs_lock); @@ -2663,10 +2693,11 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) /* purge the request queue. NB No new replies (rqbds * all unlinked) and no service threads, so I'm the only - * thread noodling the request queue now */ + * thread noodling the request queue now + */ while (!list_empty(&svcpt->scp_req_incoming)) { req = list_entry(svcpt->scp_req_incoming.next, - struct ptlrpc_request, rq_list); + struct ptlrpc_request, rq_list); list_del(&req->rq_list); svcpt->scp_nreqs_incoming--; @@ -2682,24 +2713,26 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) LASSERT(svcpt->scp_nreqs_incoming == 0); LASSERT(svcpt->scp_nreqs_active == 0); /* history should have been culled by - * ptlrpc_server_finish_request */ + * ptlrpc_server_finish_request + */ LASSERT(svcpt->scp_hist_nrqbds == 0); /* Now free all the request buffers since nothing - * references them any more... */ + * references them any more... + */ while (!list_empty(&svcpt->scp_rqbd_idle)) { rqbd = list_entry(svcpt->scp_rqbd_idle.next, - struct ptlrpc_request_buffer_desc, - rqbd_list); + struct ptlrpc_request_buffer_desc, + rqbd_list); ptlrpc_free_rqbd(rqbd); } ptlrpc_wait_replies(svcpt); while (!list_empty(&svcpt->scp_rep_idle)) { rs = list_entry(svcpt->scp_rep_idle.next, - struct ptlrpc_reply_state, - rs_list); + struct ptlrpc_reply_state, + rs_list); list_del(&rs->rs_list); kvfree(rs); } @@ -2714,7 +2747,7 @@ ptlrpc_service_free(struct ptlrpc_service *svc) 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 */ @@ -2730,7 +2763,7 @@ ptlrpc_service_free(struct ptlrpc_service *svc) 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); diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index 61d9ca93c..3ffd2d91f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -333,17 +333,9 @@ void lustre_assert_wire_constants(void) CLASSERT(LDLM_MAX_TYPE == 14); CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); - LASSERTF(UPDATE_OBJ == 1000, "found %lld\n", - (long long)UPDATE_OBJ); - LASSERTF(UPDATE_LAST_OPC == 1001, "found %lld\n", - (long long)UPDATE_LAST_OPC); CLASSERT(LUSTRE_RES_ID_QUOTA_SEQ_OFF == 2); CLASSERT(LUSTRE_RES_ID_QUOTA_VER_OID_OFF == 3); CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); - CLASSERT(LQUOTA_TYPE_USR == 0); - CLASSERT(LQUOTA_TYPE_GRP == 1); - CLASSERT(LQUOTA_RES_MD == 1); - CLASSERT(LQUOTA_RES_DT == 2); LASSERTF(OBD_PING == 400, "found %lld\n", (long long)OBD_PING); LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n", @@ -437,30 +429,6 @@ void lustre_assert_wire_constants(void) (unsigned)LMAC_NOT_IN_OI); LASSERTF(LMAC_FID_ON_OST == 0x00000008UL, "found 0x%.8xUL\n", (unsigned)LMAC_FID_ON_OST); - LASSERTF(OBJ_CREATE == 1, "found %lld\n", - (long long)OBJ_CREATE); - LASSERTF(OBJ_DESTROY == 2, "found %lld\n", - (long long)OBJ_DESTROY); - LASSERTF(OBJ_REF_ADD == 3, "found %lld\n", - (long long)OBJ_REF_ADD); - LASSERTF(OBJ_REF_DEL == 4, "found %lld\n", - (long long)OBJ_REF_DEL); - LASSERTF(OBJ_ATTR_SET == 5, "found %lld\n", - (long long)OBJ_ATTR_SET); - LASSERTF(OBJ_ATTR_GET == 6, "found %lld\n", - (long long)OBJ_ATTR_GET); - LASSERTF(OBJ_XATTR_SET == 7, "found %lld\n", - (long long)OBJ_XATTR_SET); - LASSERTF(OBJ_XATTR_GET == 8, "found %lld\n", - (long long)OBJ_XATTR_GET); - LASSERTF(OBJ_INDEX_LOOKUP == 9, "found %lld\n", - (long long)OBJ_INDEX_LOOKUP); - LASSERTF(OBJ_INDEX_LOOKUP == 9, "found %lld\n", - (long long)OBJ_INDEX_LOOKUP); - LASSERTF(OBJ_INDEX_INSERT == 10, "found %lld\n", - (long long)OBJ_INDEX_INSERT); - LASSERTF(OBJ_INDEX_DELETE == 11, "found %lld\n", - (long long)OBJ_INDEX_DELETE); /* Checks for struct ost_id */ LASSERTF((int)sizeof(struct ost_id) == 16, "found %lld\n", @@ -587,9 +555,6 @@ void lustre_assert_wire_constants(void) (long long)LDF_COLLIDE); LASSERTF(LU_PAGE_SIZE == 4096, "found %lld\n", (long long)LU_PAGE_SIZE); - /* Checks for union lu_page */ - LASSERTF((int)sizeof(union lu_page) == 4096, "found %lld\n", - (long long)(int)sizeof(union lu_page)); /* Checks for struct lustre_handle */ LASSERTF((int)sizeof(struct lustre_handle) == 8, "found %lld\n", @@ -1535,11 +1500,6 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(union lquota_id) == 16, "found %lld\n", (long long)(int)sizeof(union lquota_id)); - LASSERTF(QUOTABLOCK_BITS == 10, "found %lld\n", - (long long)QUOTABLOCK_BITS); - LASSERTF(QUOTABLOCK_SIZE == 1024, "found %lld\n", - (long long)QUOTABLOCK_SIZE); - /* Checks for struct obd_quotactl */ LASSERTF((int)sizeof(struct obd_quotactl) == 112, "found %lld\n", (long long)(int)sizeof(struct obd_quotactl)); @@ -1642,138 +1602,6 @@ void lustre_assert_wire_constants(void) LASSERTF(Q_FINVALIDATE == 0x800104, "found 0x%.8x\n", Q_FINVALIDATE); - /* Checks for struct lquota_acct_rec */ - LASSERTF((int)sizeof(struct lquota_acct_rec) == 16, "found %lld\n", - (long long)(int)sizeof(struct lquota_acct_rec)); - LASSERTF((int)offsetof(struct lquota_acct_rec, bspace) == 0, "found %lld\n", - (long long)(int)offsetof(struct lquota_acct_rec, bspace)); - LASSERTF((int)sizeof(((struct lquota_acct_rec *)0)->bspace) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_acct_rec *)0)->bspace)); - LASSERTF((int)offsetof(struct lquota_acct_rec, ispace) == 8, "found %lld\n", - (long long)(int)offsetof(struct lquota_acct_rec, ispace)); - LASSERTF((int)sizeof(((struct lquota_acct_rec *)0)->ispace) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_acct_rec *)0)->ispace)); - - /* Checks for struct lquota_glb_rec */ - LASSERTF((int)sizeof(struct lquota_glb_rec) == 32, "found %lld\n", - (long long)(int)sizeof(struct lquota_glb_rec)); - LASSERTF((int)offsetof(struct lquota_glb_rec, qbr_hardlimit) == 0, "found %lld\n", - (long long)(int)offsetof(struct lquota_glb_rec, qbr_hardlimit)); - LASSERTF((int)sizeof(((struct lquota_glb_rec *)0)->qbr_hardlimit) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_glb_rec *)0)->qbr_hardlimit)); - LASSERTF((int)offsetof(struct lquota_glb_rec, qbr_softlimit) == 8, "found %lld\n", - (long long)(int)offsetof(struct lquota_glb_rec, qbr_softlimit)); - LASSERTF((int)sizeof(((struct lquota_glb_rec *)0)->qbr_softlimit) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_glb_rec *)0)->qbr_softlimit)); - LASSERTF((int)offsetof(struct lquota_glb_rec, qbr_time) == 16, "found %lld\n", - (long long)(int)offsetof(struct lquota_glb_rec, qbr_time)); - LASSERTF((int)sizeof(((struct lquota_glb_rec *)0)->qbr_time) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_glb_rec *)0)->qbr_time)); - LASSERTF((int)offsetof(struct lquota_glb_rec, qbr_granted) == 24, "found %lld\n", - (long long)(int)offsetof(struct lquota_glb_rec, qbr_granted)); - LASSERTF((int)sizeof(((struct lquota_glb_rec *)0)->qbr_granted) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_glb_rec *)0)->qbr_granted)); - - /* Checks for struct lquota_slv_rec */ - LASSERTF((int)sizeof(struct lquota_slv_rec) == 8, "found %lld\n", - (long long)(int)sizeof(struct lquota_slv_rec)); - LASSERTF((int)offsetof(struct lquota_slv_rec, qsr_granted) == 0, "found %lld\n", - (long long)(int)offsetof(struct lquota_slv_rec, qsr_granted)); - LASSERTF((int)sizeof(((struct lquota_slv_rec *)0)->qsr_granted) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lquota_slv_rec *)0)->qsr_granted)); - - /* Checks for struct idx_info */ - LASSERTF((int)sizeof(struct idx_info) == 80, "found %lld\n", - (long long)(int)sizeof(struct idx_info)); - LASSERTF((int)offsetof(struct idx_info, ii_magic) == 0, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_magic)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_magic) == 4, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_magic)); - LASSERTF((int)offsetof(struct idx_info, ii_flags) == 4, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_flags)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_flags) == 4, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_flags)); - LASSERTF((int)offsetof(struct idx_info, ii_count) == 8, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_count)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_count) == 2, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_count)); - LASSERTF((int)offsetof(struct idx_info, ii_pad0) == 10, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_pad0)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_pad0) == 2, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_pad0)); - LASSERTF((int)offsetof(struct idx_info, ii_attrs) == 12, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_attrs)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_attrs) == 4, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_attrs)); - LASSERTF((int)offsetof(struct idx_info, ii_fid) == 16, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_fid)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_fid) == 16, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_fid)); - LASSERTF((int)offsetof(struct idx_info, ii_version) == 32, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_version)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_version) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_version)); - LASSERTF((int)offsetof(struct idx_info, ii_hash_start) == 40, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_hash_start)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_hash_start) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_hash_start)); - LASSERTF((int)offsetof(struct idx_info, ii_hash_end) == 48, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_hash_end)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_hash_end) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_hash_end)); - LASSERTF((int)offsetof(struct idx_info, ii_keysize) == 56, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_keysize)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_keysize) == 2, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_keysize)); - LASSERTF((int)offsetof(struct idx_info, ii_recsize) == 58, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_recsize)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_recsize) == 2, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_recsize)); - LASSERTF((int)offsetof(struct idx_info, ii_pad1) == 60, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_pad1)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_pad1) == 4, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_pad1)); - LASSERTF((int)offsetof(struct idx_info, ii_pad2) == 64, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_pad2)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_pad2) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_pad2)); - LASSERTF((int)offsetof(struct idx_info, ii_pad3) == 72, "found %lld\n", - (long long)(int)offsetof(struct idx_info, ii_pad3)); - LASSERTF((int)sizeof(((struct idx_info *)0)->ii_pad3) == 8, "found %lld\n", - (long long)(int)sizeof(((struct idx_info *)0)->ii_pad3)); - CLASSERT(IDX_INFO_MAGIC == 0x3D37CC37); - - /* Checks for struct lu_idxpage */ - LASSERTF((int)sizeof(struct lu_idxpage) == 16, "found %lld\n", - (long long)(int)sizeof(struct lu_idxpage)); - LASSERTF((int)offsetof(struct lu_idxpage, lip_magic) == 0, "found %lld\n", - (long long)(int)offsetof(struct lu_idxpage, lip_magic)); - LASSERTF((int)sizeof(((struct lu_idxpage *)0)->lip_magic) == 4, "found %lld\n", - (long long)(int)sizeof(((struct lu_idxpage *)0)->lip_magic)); - LASSERTF((int)offsetof(struct lu_idxpage, lip_flags) == 4, "found %lld\n", - (long long)(int)offsetof(struct lu_idxpage, lip_flags)); - LASSERTF((int)sizeof(((struct lu_idxpage *)0)->lip_flags) == 2, "found %lld\n", - (long long)(int)sizeof(((struct lu_idxpage *)0)->lip_flags)); - LASSERTF((int)offsetof(struct lu_idxpage, lip_nr) == 6, "found %lld\n", - (long long)(int)offsetof(struct lu_idxpage, lip_nr)); - LASSERTF((int)sizeof(((struct lu_idxpage *)0)->lip_nr) == 2, "found %lld\n", - (long long)(int)sizeof(((struct lu_idxpage *)0)->lip_nr)); - LASSERTF((int)offsetof(struct lu_idxpage, lip_pad0) == 8, "found %lld\n", - (long long)(int)offsetof(struct lu_idxpage, lip_pad0)); - LASSERTF((int)sizeof(((struct lu_idxpage *)0)->lip_pad0) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lu_idxpage *)0)->lip_pad0)); - CLASSERT(LIP_MAGIC == 0x8A6D6B6C); - LASSERTF(LIP_HDR_SIZE == 16, "found %lld\n", - (long long)LIP_HDR_SIZE); - LASSERTF(II_FL_NOHASH == 1, "found %lld\n", - (long long)II_FL_NOHASH); - LASSERTF(II_FL_VARKEY == 2, "found %lld\n", - (long long)II_FL_VARKEY); - LASSERTF(II_FL_VARREC == 4, "found %lld\n", - (long long)II_FL_VARREC); - LASSERTF(II_FL_NONUNQ == 8, "found %lld\n", - (long long)II_FL_NONUNQ); - /* Checks for struct niobuf_remote */ LASSERTF((int)sizeof(struct niobuf_remote) == 16, "found %lld\n", (long long)(int)sizeof(struct niobuf_remote)); @@ -3753,50 +3581,6 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct ll_fiemap_info_key *)0)->fiemap) == 32, "found %lld\n", (long long)(int)sizeof(((struct ll_fiemap_info_key *)0)->fiemap)); - /* Checks for struct quota_body */ - LASSERTF((int)sizeof(struct quota_body) == 112, "found %lld\n", - (long long)(int)sizeof(struct quota_body)); - LASSERTF((int)offsetof(struct quota_body, qb_fid) == 0, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_fid)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_fid) == 16, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_fid)); - LASSERTF((int)offsetof(struct quota_body, qb_id) == 16, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_id)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_id) == 16, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_id)); - LASSERTF((int)offsetof(struct quota_body, qb_flags) == 32, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_flags)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_flags) == 4, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_flags)); - LASSERTF((int)offsetof(struct quota_body, qb_padding) == 36, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_padding)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_padding) == 4, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_padding)); - LASSERTF((int)offsetof(struct quota_body, qb_count) == 40, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_count)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_count) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_count)); - LASSERTF((int)offsetof(struct quota_body, qb_usage) == 48, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_usage)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_usage) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_usage)); - LASSERTF((int)offsetof(struct quota_body, qb_slv_ver) == 56, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_slv_ver)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_slv_ver) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_slv_ver)); - LASSERTF((int)offsetof(struct quota_body, qb_lockh) == 64, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_lockh)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_lockh) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_lockh)); - LASSERTF((int)offsetof(struct quota_body, qb_glb_lockh) == 72, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_glb_lockh)); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_glb_lockh) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_glb_lockh)); - LASSERTF((int)offsetof(struct quota_body, qb_padding1[4]) == 112, "found %lld\n", - (long long)(int)offsetof(struct quota_body, qb_padding1[4])); - LASSERTF((int)sizeof(((struct quota_body *)0)->qb_padding1[4]) == 8, "found %lld\n", - (long long)(int)sizeof(((struct quota_body *)0)->qb_padding1[4])); - /* Checks for struct mgs_target_info */ LASSERTF((int)sizeof(struct mgs_target_info) == 4544, "found %lld\n", (long long)(int)sizeof(struct mgs_target_info)); @@ -4431,60 +4215,4 @@ void lustre_assert_wire_constants(void) LASSERTF(sizeof(((struct hsm_user_import *)0)->hui_archive_id) == 4, "found %lld\n", (long long)sizeof(((struct hsm_user_import *)0)->hui_archive_id)); - - /* Checks for struct update_buf */ - LASSERTF((int)sizeof(struct update_buf) == 8, "found %lld\n", - (long long)(int)sizeof(struct update_buf)); - LASSERTF((int)offsetof(struct update_buf, ub_magic) == 0, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_magic)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_magic) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_magic)); - LASSERTF((int)offsetof(struct update_buf, ub_count) == 4, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_count)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_count) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_count)); - LASSERTF((int)offsetof(struct update_buf, ub_bufs) == 8, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_bufs)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_bufs) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_bufs)); - - /* Checks for struct update_reply */ - LASSERTF((int)sizeof(struct update_reply) == 8, "found %lld\n", - (long long)(int)sizeof(struct update_reply)); - LASSERTF((int)offsetof(struct update_reply, ur_version) == 0, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_version)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_version) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_version)); - LASSERTF((int)offsetof(struct update_reply, ur_count) == 4, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_count)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_count) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_count)); - LASSERTF((int)offsetof(struct update_reply, ur_lens) == 8, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_lens)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_lens) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_lens)); - - /* Checks for struct update */ - LASSERTF((int)sizeof(struct update) == 56, "found %lld\n", - (long long)(int)sizeof(struct update)); - LASSERTF((int)offsetof(struct update, u_type) == 0, "found %lld\n", - (long long)(int)offsetof(struct update, u_type)); - LASSERTF((int)sizeof(((struct update *)0)->u_type) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_type)); - LASSERTF((int)offsetof(struct update, u_batchid) == 4, "found %lld\n", - (long long)(int)offsetof(struct update, u_batchid)); - LASSERTF((int)sizeof(((struct update *)0)->u_batchid) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_batchid)); - LASSERTF((int)offsetof(struct update, u_fid) == 8, "found %lld\n", - (long long)(int)offsetof(struct update, u_fid)); - LASSERTF((int)sizeof(((struct update *)0)->u_fid) == 16, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_fid)); - LASSERTF((int)offsetof(struct update, u_lens) == 24, "found %lld\n", - (long long)(int)offsetof(struct update, u_lens)); - LASSERTF((int)sizeof(((struct update *)0)->u_lens) == 32, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_lens)); - LASSERTF((int)offsetof(struct update, u_bufs) == 56, "found %lld\n", - (long long)(int)offsetof(struct update, u_bufs)); - LASSERTF((int)sizeof(((struct update *)0)->u_bufs) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_bufs)); } |