Skip to content

Commit eff042d

Browse files
committed
sunrpc: Add a helper to derive maxpages from sv_max_mesg
This page count is to be used to allocate various arrays of pages and bio_vecs, replacing the fixed RPCSVC_MAXPAGES value. The documenting comment is somewhat stale -- of course NFSv4 COMPOUND procedures may have multiple payloads. Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 5924331 commit eff042d

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

  • include/linux/sunrpc

include/linux/sunrpc/svc.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,23 @@ extern u32 svc_max_payload(const struct svc_rqst *rqstp);
159159
#define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE \
160160
+ 2 + 1)
161161

162+
/**
163+
* svc_serv_maxpages - maximum count of pages needed for one RPC message
164+
* @serv: RPC service context
165+
*
166+
* Returns a count of pages or vectors that can hold the maximum
167+
* size RPC message for @serv.
168+
*
169+
* Each request/reply pair can have at most one "payload", plus two
170+
* pages, one for the request, and one for the reply.
171+
* nfsd_splice_actor() might need an extra page when a READ payload
172+
* is not page-aligned.
173+
*/
174+
static inline unsigned long svc_serv_maxpages(const struct svc_serv *serv)
175+
{
176+
return DIV_ROUND_UP(serv->sv_max_mesg, PAGE_SIZE) + 2 + 1;
177+
}
178+
162179
/*
163180
* The context of a single thread, including the request currently being
164181
* processed.

0 commit comments

Comments
 (0)