From 8a7703eec9bb77a0dd85047a04910d30eb8843aa Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Thu, 10 Oct 2024 17:48:19 +0800 Subject: [PATCH] LU-16907 ptlrpc: correct the reply buffer size for batch RPC The calculation for growing reply buffer size for a batch RPC is incorrect and it adds the SUB request size wrongly. This may result in the following panic: "Max IOV exceeded: 257 should be < 256" Fix it accordingly. Fixes: 5a2dfd36f9c ("LU-14139 ptlrpc: grow PtlRPC properly when prepare sub request") Test-Parameters: testlist=sanity env=ONLY=123f,ONLY_REPEAT=10 Signed-off-by: Qian Yingjin Change-Id: I3c5151a485cac7f3fb9384cd9fb022143ca3389d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56645 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Timothy Day Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/ptlrpc/layout.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index 8b4d1f6..57678d3 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -2063,6 +2063,7 @@ int req_capsule_server_pack(struct req_capsule *pill) if (used_len + msg_len > req->rq_replen) { __u32 len; __u32 max; + __u32 add; if (!req_capsule_has_field(&req->rq_pill, &RMF_BUT_REPLY, RCL_SERVER)) @@ -2079,17 +2080,20 @@ int req_capsule_server_pack(struct req_capsule *pill) len = req_capsule_get_size(&req->rq_pill, &RMF_BUT_REPLY, RCL_SERVER); /* - * Currently just increase the batch reply buffer - * by 2. + * Currently just increase the batch RPC reply buffer + * (including @RMF_PTLRPC_BODY + @RMF_BUT_REPLY) by 2. + * We must set the new length carefully as it will be + * rounded up with 8. */ max = BUT_MAXREPSIZE - req->rq_replen; + add = len; if (used_len + msg_len > len) - len = used_len + msg_len; + add = used_len + msg_len; - if (len > max) + if (add > max) len += max; else - len += len; + len += add; rc = req_capsule_server_grow(&req->rq_pill, &RMF_BUT_REPLY, len); -- 1.8.3.1