X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fptlrpc%2Fsec_plain.c;h=1b2f437061c8579a134893de83e4804dca362163;hp=bf022632c2de614a94195924d4140fef30130865;hb=d00c924149b5dd042e6fee09ef724013df1b4e14;hpb=ed3d0669da25b47fb35180019a43820d20a30a71 diff --git a/lustre/ptlrpc/sec_plain.c b/lustre/ptlrpc/sec_plain.c index bf02263..1b2f437 100644 --- a/lustre/ptlrpc/sec_plain.c +++ b/lustre/ptlrpc/sec_plain.c @@ -40,9 +40,6 @@ #define DEBUG_SUBSYSTEM S_SEC -#ifndef __KERNEL__ -#include -#endif #include #include @@ -50,6 +47,8 @@ #include #include +#include "ptlrpc_internal.h" + struct plain_sec { struct ptlrpc_sec pls_base; rwlock_t pls_lock; @@ -155,7 +154,6 @@ static int plain_verify_bulk_csum(struct ptlrpc_bulk_desc *desc, return 0; } -#ifdef __KERNEL__ static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc) { char *ptr; @@ -172,20 +170,6 @@ static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc) return; } } -#else -static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc) -{ - unsigned int i; - - for (i = 0; i < desc->bd_iov_count; i++) { - if (desc->bd_iov[i].iov_len == 0) - continue; - - ((char *)desc->bd_iov[i].iov_base)[i] ^= 0x1; - return; - } -} -#endif /* __KERNEL__ */ /**************************************** * cli_ctx apis * @@ -355,9 +339,7 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_bulk_sec_desc *bsdv; struct plain_bulk_token *tokenv; int rc; -#ifdef __KERNEL__ int i, nob; -#endif LASSERT(req->rq_pack_bulk); LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS); @@ -372,7 +354,6 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, return 0; } -#ifdef __KERNEL__ /* fix the actual data size */ for (i = 0, nob = 0; i < desc->bd_iov_count; i++) { if (desc->bd_iov[i].kiov_len + nob > desc->bd_nob_transferred) { @@ -381,7 +362,6 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, } nob += desc->bd_iov[i].kiov_len; } -#endif rc = plain_verify_bulk_csum(desc, req->rq_flvr.u_bulk.hash.hash_alg, tokenv); @@ -420,8 +400,8 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) ctx->cc_flags = PTLRPC_CTX_CACHED | PTLRPC_CTX_UPTODATE; ctx->cc_vcred.vc_uid = 0; spin_lock_init(&ctx->cc_lock); - CFS_INIT_LIST_HEAD(&ctx->cc_req_list); - CFS_INIT_LIST_HEAD(&ctx->cc_gc_chain); + INIT_LIST_HEAD(&ctx->cc_req_list); + INIT_LIST_HEAD(&ctx->cc_gc_chain); plsec->pls_ctx = ctx; atomic_inc(&plsec->pls_base.ps_nctx); @@ -489,7 +469,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, sec->ps_import = class_import_get(imp); sec->ps_flvr = *sf; spin_lock_init(&sec->ps_lock); - CFS_INIT_LIST_HEAD(&sec->ps_gc_list); + INIT_LIST_HEAD(&sec->ps_gc_list); sec->ps_gc_interval = 0; sec->ps_gc_next = 0; @@ -705,6 +685,15 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, if (newbuf == NULL) RETURN(-ENOMEM); + /* Must lock this, so that otherwise unprotected change of + * rq_reqmsg is not racing with parallel processing of + * 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 */ + if (req->rq_import) + spin_lock(&req->rq_import->imp_lock); + memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); @@ -712,6 +701,9 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, req->rq_reqbuf_len = newbuf_size; req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, 0); + + if (req->rq_import) + spin_unlock(&req->rq_import->imp_lock); } _sptlrpc_enlarge_msg_inplace(req->rq_reqbuf, PLAIN_PACK_MSG_OFF,