X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fptlrpc%2Fptlrpcd.c;h=4c9b577ba6960e0e011958a80d7b84b04c1378e6;hp=9810009f35318d6649329cf966625bc1f27f1406;hb=885b494632ca16d95fd09685a571b76d80d09414;hpb=ca6c35cab141597809c6f3a58102fac8ac86104a diff --git a/lustre/ptlrpc/ptlrpcd.c b/lustre/ptlrpc/ptlrpcd.c index 9810009..4c9b577 100644 --- a/lustre/ptlrpc/ptlrpcd.c +++ b/lustre/ptlrpc/ptlrpcd.c @@ -27,7 +27,6 @@ */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. * * lustre/ptlrpc/ptlrpcd.c */ @@ -175,7 +174,7 @@ ptlrpcd_select_pc(struct ptlrpc_request *req) if (req != NULL && req->rq_send_state != LUSTRE_IMP_FULL) return &ptlrpcd_rcv; - cpt = cfs_cpt_current(cfs_cpt_table, 1); + cpt = cfs_cpt_current(cfs_cpt_tab, 1); if (ptlrpcds_cpt_idx == NULL) idx = cpt; else @@ -240,17 +239,14 @@ void ptlrpcd_add_rqset(struct ptlrpc_request_set *set) static int ptlrpcd_steal_rqset(struct ptlrpc_request_set *des, struct ptlrpc_request_set *src) { - struct list_head *tmp, *pos; struct ptlrpc_request *req; int rc = 0; spin_lock(&src->set_new_req_lock); 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); + list_for_each_entry(req, &src->set_new_requests, rq_set_chain) req->rq_set = des; - } + list_splice_init(&src->set_new_requests, &des->set_requests); rc = atomic_read(&src->set_new_count); @@ -318,8 +314,7 @@ static inline void ptlrpc_reqset_get(struct ptlrpc_request_set *set) */ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) { - struct list_head *tmp, *pos; - struct ptlrpc_request *req; + struct ptlrpc_request *req, *tmp; struct ptlrpc_request_set *set = pc->pc_set; int rc = 0; int rc2; @@ -369,8 +364,7 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) * NB: ptlrpc_check_set has already moved complted request at the * head of seq::set_requests */ - list_for_each_safe(pos, tmp, &set->set_requests) { - req = list_entry(pos, struct ptlrpc_request, rq_set_chain); + list_for_each_entry_safe(req, tmp, &set->set_requests, rq_set_chain) { if (req->rq_phase != RQ_PHASE_COMPLETE) break; @@ -442,10 +436,7 @@ static int ptlrpcd(void *arg) int exit = 0; ENTRY; - - unshare_fs_struct(); - - if (cfs_cpt_bind(cfs_cpt_table, pc->pc_cpt) != 0) + if (cfs_cpt_bind(cfs_cpt_tab, pc->pc_cpt) != 0) CWARN("Failed to bind %s on CPT %d\n", pc->pc_name, pc->pc_cpt); /* @@ -486,16 +477,32 @@ static int ptlrpcd(void *arg) * new_req_list and ptlrpcd_check() moves them into the set. */ do { - struct l_wait_info lwi; + DEFINE_WAIT_FUNC(wait, woken_wake_function); time64_t timeout; timeout = ptlrpc_set_next_timeout(set); - lwi = LWI_TIMEOUT(cfs_time_seconds(timeout), - ptlrpc_expired_set, set); lu_context_enter(&env.le_ctx); lu_context_enter(env.le_ses); - l_wait_event(set->set_waitq, ptlrpcd_check(&env, pc), &lwi); + + add_wait_queue(&set->set_waitq, &wait); + while (!ptlrpcd_check(&env, pc)) { + int ret; + + if (timeout == 0) + ret = wait_woken(&wait, TASK_IDLE, + MAX_SCHEDULE_TIMEOUT); + else + ret = wait_woken(&wait, TASK_IDLE, + cfs_time_seconds(timeout)); + if (ret != 0) + continue; + /* Timed out */ + ptlrpc_expired_set(set); + break; + } + remove_wait_queue(&set->set_waitq, &wait); + lu_context_exit(&env.le_ctx); lu_context_exit(env.le_ses); @@ -588,7 +595,7 @@ static int ptlrpcd_partners(struct ptlrpcd *pd, int index) if (pc->pc_npartners <= 0) GOTO(out, rc); - OBD_CPT_ALLOC(pc->pc_partners, cfs_cpt_table, pc->pc_cpt, + OBD_CPT_ALLOC(pc->pc_partners, cfs_cpt_tab, pc->pc_cpt, sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners); if (pc->pc_partners == NULL) { pc->pc_npartners = 0; @@ -621,7 +628,7 @@ int ptlrpcd_start(struct ptlrpcd_ctl *pc) RETURN(0); } - task = kthread_run(ptlrpcd, pc, pc->pc_name); + task = kthread_run(ptlrpcd, pc, "%s", pc->pc_name); if (IS_ERR(task)) GOTO(out_set, rc = PTR_ERR(task)); @@ -689,8 +696,7 @@ out: if (pc->pc_npartners > 0) { LASSERT(pc->pc_partners != NULL); - OBD_FREE(pc->pc_partners, - sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners); + OBD_FREE_PTR_ARRAY(pc->pc_partners, pc->pc_npartners); pc->pc_partners = NULL; } pc->pc_npartners = 0; @@ -717,7 +723,7 @@ static void ptlrpcd_fini(void) OBD_FREE(ptlrpcds[i], ptlrpcds[i]->pd_size); ptlrpcds[i] = NULL; } - OBD_FREE(ptlrpcds, sizeof(ptlrpcds[0]) * ptlrpcds_num); + OBD_FREE_PTR_ARRAY(ptlrpcds, ptlrpcds_num); } ptlrpcds_num = 0; @@ -725,8 +731,8 @@ static void ptlrpcd_fini(void) ptlrpcd_free(&ptlrpcd_rcv); if (ptlrpcds_cpt_idx != NULL) { - ncpts = cfs_cpt_number(cfs_cpt_table); - OBD_FREE(ptlrpcds_cpt_idx, ncpts * sizeof(ptlrpcds_cpt_idx[0])); + ncpts = cfs_cpt_number(cfs_cpt_tab); + OBD_FREE_PTR_ARRAY(ptlrpcds_cpt_idx, ncpts); ptlrpcds_cpt_idx = NULL; } @@ -752,7 +758,7 @@ static int ptlrpcd_init(void) /* * Determine the CPTs that ptlrpcd threads will run on. */ - cptable = cfs_cpt_table; + cptable = cfs_cpt_tab; ncpts = cfs_cpt_number(cptable); if (ptlrpcd_cpts != NULL) { struct cfs_expr_list *el;