Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xprtrdma: Fix calculation of ri_max_segs again

Commit 302d3deb206 ("xprtrdma: Prevent inline overflow") added this
calculation back in 2016, but got it wrong. I tested only the lower
bound, which is why there is a max_t there. The upper bound should be
rounded up too.

Now, when using DIV_ROUND_UP, that takes care of the lower bound as
well.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

authored by

Chuck Lever and committed by
Anna Schumaker
36bdd905 af08a775

+2 -2
+2 -2
net/sunrpc/xprtrdma/frwr_ops.c
··· 260 260 ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS; 261 261 ep->rep_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */ 262 262 263 - ia->ri_max_segs = max_t(unsigned int, 1, RPCRDMA_MAX_DATA_SEGS / 264 - ia->ri_max_frwr_depth); 263 + ia->ri_max_segs = 264 + DIV_ROUND_UP(RPCRDMA_MAX_DATA_SEGS, ia->ri_max_frwr_depth); 265 265 /* Reply chunks require segments for head and tail buffers */ 266 266 ia->ri_max_segs += 2; 267 267 if (ia->ri_max_segs > RPCRDMA_MAX_HDR_SEGS)