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.55~30 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5aa4ccc5f251227b79c26408569f6371314d2072 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 2d6d7bd..c33a6da 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 1c2e30e..fbea227 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -2111,8 +2111,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);