aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-03-29 16:47:53 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-05-01 01:17:10 -0400
commit2bea90d43a050bbc4021d44e59beb34f384438db (patch)
tree2dd3f15bd9df537166a82777b0c95243b90b17e1 /fs
parent511d2e8855a065c8251d0c140ebc353854f1929e (diff)
SUNRPC: RPC buffer size estimates are too large
The RPC buffer size estimation logic in net/sunrpc/clnt.c always significantly overestimates the requirements for the buffer size. A little instrumentation demonstrated that in fact rpc_malloc was never allocating the buffer from the mempool, but almost always called kmalloc. To compute the size of the RPC buffer more precisely, split p_bufsiz into two fields; one for the argument size, and one for the result size. Then, compute the sum of the exact call and reply header sizes, and split the RPC buffer precisely between the two. That should keep almost all RPC buffers within the 2KiB buffer mempool limit. And, we can finally be rid of RPC_SLACK_SPACE! Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/lockd/mon.c10
-rw-r--r--fs/lockd/xdr.c7
-rw-r--r--fs/lockd/xdr4.c7
-rw-r--r--fs/nfs/mount_clnt.c7
-rw-r--r--fs/nfs/nfs2xdr.c7
-rw-r--r--fs/nfs/nfs3xdr.c13
-rw-r--r--fs/nfs/nfs4xdr.c7
-rw-r--r--fs/nfsd/nfs4callback.c7
8 files changed, 25 insertions, 40 deletions
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index eb243edf8932..2102e2d0134d 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -225,16 +225,13 @@ xdr_decode_stat(struct rpc_rqst *rqstp, __be32 *p, struct nsm_res *resp)
225#define SM_monres_sz 2 225#define SM_monres_sz 2
226#define SM_unmonres_sz 1 226#define SM_unmonres_sz 1
227 227
228#ifndef MAX
229# define MAX(a, b) (((a) > (b))? (a) : (b))
230#endif
231
232static struct rpc_procinfo nsm_procedures[] = { 228static struct rpc_procinfo nsm_procedures[] = {
233[SM_MON] = { 229[SM_MON] = {
234 .p_proc = SM_MON, 230 .p_proc = SM_MON,
235 .p_encode = (kxdrproc_t) xdr_encode_mon, 231 .p_encode = (kxdrproc_t) xdr_encode_mon,
236 .p_decode = (kxdrproc_t) xdr_decode_stat_res, 232 .p_decode = (kxdrproc_t) xdr_decode_stat_res,
237 .p_bufsiz = MAX(SM_mon_sz, SM_monres_sz) << 2, 233 .p_arglen = SM_mon_sz,
234 .p_replen = SM_monres_sz,
238 .p_statidx = SM_MON, 235 .p_statidx = SM_MON,
239 .p_name = "MONITOR", 236 .p_name = "MONITOR",
240 }, 237 },
@@ -242,7 +239,8 @@ static struct rpc_procinfo nsm_procedures[] = {
242 .p_proc = SM_UNMON, 239 .p_proc = SM_UNMON,
243 .p_encode = (kxdrproc_t) xdr_encode_unmon, 240 .p_encode = (kxdrproc_t) xdr_encode_unmon,
244 .p_decode = (kxdrproc_t) xdr_decode_stat, 241 .p_decode = (kxdrproc_t) xdr_decode_stat,
245 .p_bufsiz = MAX(SM_mon_id_sz, SM_unmonres_sz) << 2, 242 .p_arglen = SM_mon_id_sz,
243 .p_replen = SM_unmonres_sz,
246 .p_statidx = SM_UNMON, 244 .p_statidx = SM_UNMON,
247 .p_name = "UNMONITOR", 245 .p_name = "UNMONITOR",
248 }, 246 },
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 6aac4b2c9ff0..9702956d206c 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -534,10 +534,6 @@ nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
534#define NLM_res_sz NLM_cookie_sz+1 534#define NLM_res_sz NLM_cookie_sz+1
535#define NLM_norep_sz 0 535#define NLM_norep_sz 0
536 536
537#ifndef MAX
538# define MAX(a, b) (((a) > (b))? (a) : (b))
539#endif
540
541/* 537/*
542 * For NLM, a void procedure really returns nothing 538 * For NLM, a void procedure really returns nothing
543 */ 539 */
@@ -548,7 +544,8 @@ nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
548 .p_proc = NLMPROC_##proc, \ 544 .p_proc = NLMPROC_##proc, \
549 .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \ 545 .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \
550 .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \ 546 .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \
551 .p_bufsiz = MAX(NLM_##argtype##_sz, NLM_##restype##_sz) << 2, \ 547 .p_arglen = NLM_##argtype##_sz, \
548 .p_replen = NLM_##restype##_sz, \
552 .p_statidx = NLMPROC_##proc, \ 549 .p_statidx = NLMPROC_##proc, \
553 .p_name = #proc, \ 550 .p_name = #proc, \
554 } 551 }
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index 7c8b679c394c..ce1efdbe1b3a 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -544,10 +544,6 @@ nlm4clt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
544#define NLM4_res_sz NLM4_cookie_sz+1 544#define NLM4_res_sz NLM4_cookie_sz+1
545#define NLM4_norep_sz 0 545#define NLM4_norep_sz 0
546 546
547#ifndef MAX
548# define MAX(a,b) (((a) > (b))? (a) : (b))
549#endif
550
551/* 547/*
552 * For NLM, a void procedure really returns nothing 548 * For NLM, a void procedure really returns nothing
553 */ 549 */
@@ -558,7 +554,8 @@ nlm4clt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
558 .p_proc = NLMPROC_##proc, \ 554 .p_proc = NLMPROC_##proc, \
559 .p_encode = (kxdrproc_t) nlm4clt_encode_##argtype, \ 555 .p_encode = (kxdrproc_t) nlm4clt_encode_##argtype, \
560 .p_decode = (kxdrproc_t) nlm4clt_decode_##restype, \ 556 .p_decode = (kxdrproc_t) nlm4clt_decode_##restype, \
561 .p_bufsiz = MAX(NLM4_##argtype##_sz, NLM4_##restype##_sz) << 2, \ 557 .p_arglen = NLM4_##argtype##_sz, \
558 .p_replen = NLM4_##restype##_sz, \
562 .p_statidx = NLMPROC_##proc, \ 559 .p_statidx = NLMPROC_##proc, \
563 .p_name = #proc, \ 560 .p_name = #proc, \
564 } 561 }
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index f75fe72b4160..ca5a266a3140 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -133,13 +133,15 @@ xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p, struct mnt_fhstatus *res)
133 133
134#define MNT_dirpath_sz (1 + 256) 134#define MNT_dirpath_sz (1 + 256)
135#define MNT_fhstatus_sz (1 + 8) 135#define MNT_fhstatus_sz (1 + 8)
136#define MNT_fhstatus3_sz (1 + 16)
136 137
137static struct rpc_procinfo mnt_procedures[] = { 138static struct rpc_procinfo mnt_procedures[] = {
138[MNTPROC_MNT] = { 139[MNTPROC_MNT] = {
139 .p_proc = MNTPROC_MNT, 140 .p_proc = MNTPROC_MNT,
140 .p_encode = (kxdrproc_t) xdr_encode_dirpath, 141 .p_encode = (kxdrproc_t) xdr_encode_dirpath,
141 .p_decode = (kxdrproc_t) xdr_decode_fhstatus, 142 .p_decode = (kxdrproc_t) xdr_decode_fhstatus,
142 .p_bufsiz = MNT_dirpath_sz << 2, 143 .p_arglen = MNT_dirpath_sz,
144 .p_replen = MNT_fhstatus_sz,
143 .p_statidx = MNTPROC_MNT, 145 .p_statidx = MNTPROC_MNT,
144 .p_name = "MOUNT", 146 .p_name = "MOUNT",
145 }, 147 },
@@ -150,7 +152,8 @@ static struct rpc_procinfo mnt3_procedures[] = {
150 .p_proc = MOUNTPROC3_MNT, 152 .p_proc = MOUNTPROC3_MNT,
151 .p_encode = (kxdrproc_t) xdr_encode_dirpath, 153 .p_encode = (kxdrproc_t) xdr_encode_dirpath,
152 .p_decode = (kxdrproc_t) xdr_decode_fhstatus3, 154 .p_decode = (kxdrproc_t) xdr_decode_fhstatus3,
153 .p_bufsiz = MNT_dirpath_sz << 2, 155 .p_arglen = MNT_dirpath_sz,
156 .p_replen = MNT_fhstatus3_sz,
154 .p_statidx = MOUNTPROC3_MNT, 157 .p_statidx = MOUNTPROC3_MNT,
155 .p_name = "MOUNT", 158 .p_name = "MOUNT",
156 }, 159 },
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index 3be4e72a0227..abd9f8b48943 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -687,16 +687,13 @@ nfs_stat_to_errno(int stat)
687 return nfs_errtbl[i].errno; 687 return nfs_errtbl[i].errno;
688} 688}
689 689
690#ifndef MAX
691# define MAX(a, b) (((a) > (b))? (a) : (b))
692#endif
693
694#define PROC(proc, argtype, restype, timer) \ 690#define PROC(proc, argtype, restype, timer) \
695[NFSPROC_##proc] = { \ 691[NFSPROC_##proc] = { \
696 .p_proc = NFSPROC_##proc, \ 692 .p_proc = NFSPROC_##proc, \
697 .p_encode = (kxdrproc_t) nfs_xdr_##argtype, \ 693 .p_encode = (kxdrproc_t) nfs_xdr_##argtype, \
698 .p_decode = (kxdrproc_t) nfs_xdr_##restype, \ 694 .p_decode = (kxdrproc_t) nfs_xdr_##restype, \
699 .p_bufsiz = MAX(NFS_##argtype##_sz,NFS_##restype##_sz) << 2, \ 695 .p_arglen = NFS_##argtype##_sz, \
696 .p_replen = NFS_##restype##_sz, \
700 .p_timer = timer, \ 697 .p_timer = timer, \
701 .p_statidx = NFSPROC_##proc, \ 698 .p_statidx = NFSPROC_##proc, \
702 .p_name = #proc, \ 699 .p_name = #proc, \
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 0ace092d126f..b51df8eb9f01 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -1102,16 +1102,13 @@ nfs3_xdr_setaclres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
1102} 1102}
1103#endif /* CONFIG_NFS_V3_ACL */ 1103#endif /* CONFIG_NFS_V3_ACL */
1104 1104
1105#ifndef MAX
1106# define MAX(a, b) (((a) > (b))? (a) : (b))
1107#endif
1108
1109#define PROC(proc, argtype, restype, timer) \ 1105#define PROC(proc, argtype, restype, timer) \
1110[NFS3PROC_##proc] = { \ 1106[NFS3PROC_##proc] = { \
1111 .p_proc = NFS3PROC_##proc, \ 1107 .p_proc = NFS3PROC_##proc, \
1112 .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \ 1108 .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
1113 .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \ 1109 .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
1114 .p_bufsiz = MAX(NFS3_##argtype##_sz,NFS3_##restype##_sz) << 2, \ 1110 .p_arglen = NFS3_##argtype##_sz, \
1111 .p_replen = NFS3_##restype##_sz, \
1115 .p_timer = timer, \ 1112 .p_timer = timer, \
1116 .p_statidx = NFS3PROC_##proc, \ 1113 .p_statidx = NFS3PROC_##proc, \
1117 .p_name = #proc, \ 1114 .p_name = #proc, \
@@ -1153,7 +1150,8 @@ static struct rpc_procinfo nfs3_acl_procedures[] = {
1153 .p_proc = ACLPROC3_GETACL, 1150 .p_proc = ACLPROC3_GETACL,
1154 .p_encode = (kxdrproc_t) nfs3_xdr_getaclargs, 1151 .p_encode = (kxdrproc_t) nfs3_xdr_getaclargs,
1155 .p_decode = (kxdrproc_t) nfs3_xdr_getaclres, 1152 .p_decode = (kxdrproc_t) nfs3_xdr_getaclres,
1156 .p_bufsiz = MAX(ACL3_getaclargs_sz, ACL3_getaclres_sz) << 2, 1153 .p_arglen = ACL3_getaclargs_sz,
1154 .p_replen = ACL3_getaclres_sz,
1157 .p_timer = 1, 1155 .p_timer = 1,
1158 .p_name = "GETACL", 1156 .p_name = "GETACL",
1159 }, 1157 },
@@ -1161,7 +1159,8 @@ static struct rpc_procinfo nfs3_acl_procedures[] = {
1161 .p_proc = ACLPROC3_SETACL, 1159 .p_proc = ACLPROC3_SETACL,
1162 .p_encode = (kxdrproc_t) nfs3_xdr_setaclargs, 1160 .p_encode = (kxdrproc_t) nfs3_xdr_setaclargs,
1163 .p_decode = (kxdrproc_t) nfs3_xdr_setaclres, 1161 .p_decode = (kxdrproc_t) nfs3_xdr_setaclres,
1164 .p_bufsiz = MAX(ACL3_setaclargs_sz, ACL3_setaclres_sz) << 2, 1162 .p_arglen = ACL3_setaclargs_sz,
1163 .p_replen = ACL3_setaclres_sz,
1165 .p_timer = 0, 1164 .p_timer = 0,
1166 .p_name = "SETACL", 1165 .p_name = "SETACL",
1167 }, 1166 },
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index f02d522fd788..b8c28f2380a5 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4546,16 +4546,13 @@ nfs4_stat_to_errno(int stat)
4546 return stat; 4546 return stat;
4547} 4547}
4548 4548
4549#ifndef MAX
4550# define MAX(a, b) (((a) > (b))? (a) : (b))
4551#endif
4552
4553#define PROC(proc, argtype, restype) \ 4549#define PROC(proc, argtype, restype) \
4554[NFSPROC4_CLNT_##proc] = { \ 4550[NFSPROC4_CLNT_##proc] = { \
4555 .p_proc = NFSPROC4_COMPOUND, \ 4551 .p_proc = NFSPROC4_COMPOUND, \
4556 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \ 4552 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
4557 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \ 4553 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
4558 .p_bufsiz = MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \ 4554 .p_arglen = NFS4_##argtype##_sz, \
4555 .p_replen = NFS4_##restype##_sz, \
4559 .p_statidx = NFSPROC4_CLNT_##proc, \ 4556 .p_statidx = NFSPROC4_CLNT_##proc, \
4560 .p_name = #proc, \ 4557 .p_name = #proc, \
4561 } 4558 }
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index fb14d68eacab..32ffea033c7a 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -315,16 +315,13 @@ out:
315/* 315/*
316 * RPC procedure tables 316 * RPC procedure tables
317 */ 317 */
318#ifndef MAX
319# define MAX(a, b) (((a) > (b))? (a) : (b))
320#endif
321
322#define PROC(proc, call, argtype, restype) \ 318#define PROC(proc, call, argtype, restype) \
323[NFSPROC4_CLNT_##proc] = { \ 319[NFSPROC4_CLNT_##proc] = { \
324 .p_proc = NFSPROC4_CB_##call, \ 320 .p_proc = NFSPROC4_CB_##call, \
325 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \ 321 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
326 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \ 322 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
327 .p_bufsiz = MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \ 323 .p_arglen = NFS4_##argtype##_sz, \
324 .p_replen = NFS4_##restype##_sz, \
328 .p_statidx = NFSPROC4_CB_##call, \ 325 .p_statidx = NFSPROC4_CB_##call, \
329 .p_name = #proc, \ 326 .p_name = #proc, \
330} 327}