From: Patrick Farrell Date: Fri, 22 Nov 2013 16:47:54 +0000 (-0600) Subject: LU-3680 ptlrpc: Fix assertion failure of null_alloc_rs() X-Git-Tag: 2.5.1-RC1~59 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=428cd4b68c72146e9cdcb0d01139f3c33a74ec4d;p=fs%2Flustre-release.git LU-3680 ptlrpc: Fix assertion failure of null_alloc_rs() lustre_get_emerg_rs() set the size of the reply buffer to zero by mistake, which will cause LBUG in null_alloc_rs() when memory pressure is high. This patch fix this problem and adds a size check to avoid the problem of insufficient buffer size. Signed-off-by: Li Xi Signed-off-by: Patrick Farrell Change-Id: I9fbd4f14e8e1263de2af564c4f2e420f5f2b43bc Reviewed-on: http://review.whamcloud.com/8200 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 4c91135..ea7abab 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -311,6 +311,7 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) spin_unlock(&svcpt->scp_rep_lock); memset(rs, 0, svcpt->scp_service->srv_max_reply_size); + rs->rs_size = svcpt->scp_service->srv_max_reply_size; rs->rs_svcpt = svcpt; rs->rs_prealloc = 1; out: diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index cbfa405..2f67762 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -2107,8 +2107,18 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) rc = policy->sp_sops->alloc_rs(req, msglen); if (unlikely(rc == -ENOMEM)) { + struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; + 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); + RETURN(-ENOMEM); + } + /* failed alloc, try emergency pool */ - rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_svcpt); + rs = lustre_get_emerg_rs(svcpt); if (rs == NULL) RETURN(-ENOMEM);