From 6226861683863ee3cee607542a28add69f61d46d Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Thu, 1 Apr 2010 15:40:41 -0700 Subject: [PATCH] b=21877 protect modification of request flag's bitfield with rq_lock --- lustre/ptlrpc/client.c | 14 ++++++++++++++ lustre/ptlrpc/pack_generic.c | 5 ++++- lustre/ptlrpc/sec.c | 6 ++++++ lustre/ptlrpc/service.c | 6 ++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 654394d..eb69133 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -1312,7 +1312,9 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) } if (req->rq_err) { + cfs_spin_lock(&req->rq_lock); req->rq_replied = 0; + cfs_spin_unlock(&req->rq_lock); if (req->rq_status == 0) req->rq_status = -EIO; ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET); @@ -1376,12 +1378,16 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) cfs_spin_unlock(&imp->imp_lock); + cfs_spin_lock(&req->rq_lock); req->rq_waiting = 0; + cfs_spin_unlock(&req->rq_lock); if (req->rq_timedout||req->rq_resend) { /* This is re-sending anyways, * let's mark req as resend. */ + cfs_spin_lock(&req->rq_lock); req->rq_resend = 1; + cfs_spin_unlock(&req->rq_lock); if (req->rq_bulk) { __u64 old_xid; @@ -1405,15 +1411,21 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) if (status) { if (req->rq_err) { req->rq_status = status; + cfs_spin_lock(&req->rq_lock); req->rq_wait_ctx = 0; + cfs_spin_unlock(&req->rq_lock); force_timer_recalc = 1; } else { + cfs_spin_lock(&req->rq_lock); req->rq_wait_ctx = 1; + cfs_spin_unlock(&req->rq_lock); } continue; } else { + cfs_spin_lock(&req->rq_lock); req->rq_wait_ctx = 0; + cfs_spin_unlock(&req->rq_lock); } rc = ptl_send_rpc(req, 0); @@ -1421,7 +1433,9 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) DEBUG_REQ(D_HA, req, "send failed (%d)", rc); force_timer_recalc = 1; + cfs_spin_lock(&req->rq_lock); req->rq_net_err = 1; + cfs_spin_unlock(&req->rq_lock); } /* need to reset the timeout */ force_timer_recalc = 1; diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 5149f1f..5af3db6 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -320,8 +320,11 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, LASSERT(req->rq_reply_state == NULL); - if ((flags & LPRFL_EARLY_REPLY) == 0) + if ((flags & LPRFL_EARLY_REPLY) == 0) { + cfs_spin_lock(&req->rq_lock); req->rq_packed_final = 1; + cfs_spin_unlock(&req->rq_lock); + } msg_len = lustre_msg_size_v2(count, lens); rc = sptlrpc_svc_alloc_rs(req, msg_len); diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index 84669c3..defe085 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -667,7 +667,9 @@ again: } if (unlikely(cfs_test_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags))) { + cfs_spin_lock(&req->rq_lock); req->rq_err = 1; + cfs_spin_unlock(&req->rq_lock); req_off_ctx_list(req, ctx); RETURN(-EPERM); } @@ -709,7 +711,9 @@ again: * don't switch ctx if import was deactivated */ if (req->rq_import->imp_deactive) { + cfs_spin_lock(&req->rq_lock); req->rq_err = 1; + cfs_spin_unlock(&req->rq_lock); RETURN(-EINTR); } @@ -718,7 +722,9 @@ again: LASSERT(ctx == req->rq_cli_ctx); CERROR("req %p: failed to replace dead ctx %p: %d\n", req, ctx, rc); + cfs_spin_lock(&req->rq_lock); req->rq_err = 1; + cfs_spin_unlock(&req->rq_lock); RETURN(rc); } diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index f6e6a65..07cd10d 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -658,7 +658,9 @@ void ptlrpc_server_drop_request(struct ptlrpc_request *req) LASSERT(!cfs_list_empty(&req->rq_timed_list)); cfs_list_del_init(&req->rq_timed_list); + cfs_spin_lock(&req->rq_lock); req->rq_at_linked = 0; + cfs_spin_unlock(&req->rq_lock); array->paa_reqs_count[index]--; array->paa_count--; } else @@ -919,7 +921,9 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req) cfs_list_add(&req->rq_timed_list, &array->paa_reqs_array[index]); + cfs_spin_lock(&req->rq_lock); req->rq_at_linked = 1; + cfs_spin_unlock(&req->rq_lock); req->rq_at_index = index; array->paa_reqs_count[index]++; array->paa_count++; @@ -1130,7 +1134,9 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc) counter++; array->paa_reqs_count[index]--; array->paa_count--; + cfs_spin_lock(&rq->rq_lock); rq->rq_at_linked = 0; + cfs_spin_unlock(&rq->rq_lock); continue; } -- 1.8.3.1