Skip to content

Commit f412682

Browse files
committed
sunrpc: Adjust size of socket's receive page array dynamically
As a step towards making NFSD's maximum rsize and wsize variable at run-time, make sk_pages a flexible array. Reviewed-by: Jeff Layton <[email protected]> Reviewed-by: NeilBrown <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 1259560 commit f412682

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

include/linux/sunrpc/svcsock.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ struct svc_sock {
4040

4141
struct completion sk_handshake_done;
4242

43-
struct page * sk_pages[RPCSVC_MAXPAGES]; /* received data */
43+
/* received data */
44+
unsigned long sk_maxpages;
45+
struct page * sk_pages[] __counted_by(sk_maxpages);
4446
};
4547

4648
static inline u32 svc_sock_reclen(struct svc_sock *svsk)

net/sunrpc/svcsock.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,8 @@ static void svc_tcp_init(struct svc_sock *svsk, struct svc_serv *serv)
13391339
svsk->sk_marker = xdr_zero;
13401340
svsk->sk_tcplen = 0;
13411341
svsk->sk_datalen = 0;
1342-
memset(&svsk->sk_pages[0], 0, sizeof(svsk->sk_pages));
1342+
memset(&svsk->sk_pages[0], 0,
1343+
svsk->sk_maxpages * sizeof(struct page *));
13431344

13441345
tcp_sock_set_nodelay(sk);
13451346

@@ -1378,10 +1379,13 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
13781379
struct svc_sock *svsk;
13791380
struct sock *inet;
13801381
int pmap_register = !(flags & SVC_SOCK_ANONYMOUS);
1382+
unsigned long pages;
13811383

1382-
svsk = kzalloc(sizeof(*svsk), GFP_KERNEL);
1384+
pages = svc_serv_maxpages(serv);
1385+
svsk = kzalloc(struct_size(svsk, sk_pages, pages), GFP_KERNEL);
13831386
if (!svsk)
13841387
return ERR_PTR(-ENOMEM);
1388+
svsk->sk_maxpages = pages;
13851389

13861390
inet = sock->sk;
13871391

0 commit comments

Comments
 (0)