diff options
author | Bret Lambert <blambert@cvs.openbsd.org> | 2009-04-13 17:51:58 +0000 |
---|---|---|
committer | Bret Lambert <blambert@cvs.openbsd.org> | 2009-04-13 17:51:58 +0000 |
commit | 095e1a46a8eef59e3e980707c10ff03ce1aa23d8 (patch) | |
tree | 7be2d4e5562640feef887d9c220ec4adf192bcf9 /sys/nfs | |
parent | 9ff60d25b0d62b7a9c3aebecaf85050bb5869187 (diff) |
Convert macros to functions to reduce kernel memory usage.
In snaps for a while (way too long, according to deraadt@)
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_serv.c | 8 | ||||
-rw-r--r-- | sys/nfs/nfs_subs.c | 24 | ||||
-rw-r--r-- | sys/nfs/nfs_var.h | 4 | ||||
-rw-r--r-- | sys/nfs/nfs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/nfs/nfs_vnops.c | 44 | ||||
-rw-r--r-- | sys/nfs/nfsm_subs.h | 17 |
6 files changed, 56 insertions, 47 deletions
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index ebe10a1561f..843a68e2870 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_serv.c,v 1.65 2009/03/30 19:58:50 blambert Exp $ */ +/* $OpenBSD: nfs_serv.c,v 1.66 2009/04/13 17:51:57 blambert Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* @@ -391,7 +391,7 @@ nfsrv_lookup(nfsd, slp, procp, mrq) nfsm_srvpostop_attr(nfsd, dirattr_ret, &dirattr, &mb); return (0); } - nfsm_srvfhtom(fhp, v3); + nfsm_srvfhtom(&mb, fhp, v3); if (v3) { nfsm_srvpostop_attr(nfsd, 0, &va, &mb); nfsm_srvpostop_attr(nfsd, dirattr_ret, &dirattr, &mb); @@ -1436,7 +1436,7 @@ nfsrv_create(nfsd, slp, procp, mrq) nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, &mb); } else { - nfsm_srvfhtom(fhp, v3); + nfsm_srvfhtom(&mb, fhp, v3); fp = nfsm_build(&mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); } @@ -2201,7 +2201,7 @@ out: nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, &mb); } else { - nfsm_srvfhtom(fhp, v3); + nfsm_srvfhtom(&mb, fhp, v3); fp = nfsm_build(&mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); } diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index c71113db558..39e650671d7 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_subs.c,v 1.93 2009/03/30 19:58:50 blambert Exp $ */ +/* $OpenBSD: nfs_subs.c,v 1.94 2009/04/13 17:51:57 blambert Exp $ */ /* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */ /* @@ -1949,6 +1949,28 @@ nfsm_build(struct mbuf **mp, u_int len) return (bpos); } +void +nfsm_fhtom(struct mbuf **mp, struct vnode *v, int v3) +{ + struct nfsnode *n = VTONFS(v); + + if (v3) { + nfsm_strtombuf(mp, n->n_fhp, n->n_fhsize); + } else { + nfsm_buftombuf(mp, n->n_fhp, NFSX_V2FH); + } +} + +void +nfsm_srvfhtom(struct mbuf **mp, fhandle_t *f, int v3) +{ + if (v3) { + nfsm_strtombuf(mp, f, NFSX_V3FH); + } else { + nfsm_buftombuf(mp, f, NFSX_V2FH); + } +} + int nfsm_srvsattr(struct mbuf **mp, struct vattr *va, struct mbuf *mrep, caddr_t *dposp) diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h index 4f8d0d80ecb..d43068e45c2 100644 --- a/sys/nfs/nfs_var.h +++ b/sys/nfs/nfs_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_var.h,v 1.49 2009/03/30 19:58:50 blambert Exp $ */ +/* $OpenBSD: nfs_var.h,v 1.50 2009/04/13 17:51:57 blambert Exp $ */ /* $NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $ */ /* @@ -255,6 +255,8 @@ int nfsrv_errmap(struct nfsrv_descript *, int); void nfsrvw_sort(gid_t *, int); void nfsrv_setcred(struct ucred *, struct ucred *); int nfsm_srvsattr(struct mbuf **, struct vattr *, struct mbuf *, caddr_t *); +void nfsm_fhtom(struct mbuf **, struct vnode *, int); +void nfsm_srvfhtom(struct mbuf **, fhandle_t *, int); /* nfs_syscalls.c */ int sys_nfssvc(struct proc *, void *, register_t *); diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index 98fb5342c82..0c8a500964a 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vfsops.c,v 1.80 2008/12/24 02:43:52 thib Exp $ */ +/* $OpenBSD: nfs_vfsops.c,v 1.81 2009/04/13 17:51:57 blambert Exp $ */ /* $NetBSD: nfs_vfsops.c,v 1.46.4.1 1996/05/25 22:40:35 fvdl Exp $ */ /* @@ -128,7 +128,7 @@ nfs_statfs(mp, sbp, p) (void)nfs_fsinfo(nmp, vp, cred, p); nfsstats.rpccnt[NFSPROC_FSSTAT]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3)); - nfsm_fhtom(vp, v3); + nfsm_fhtom(&mb, vp, v3); nfsm_request(vp, NFSPROC_FSSTAT, p, cred); if (v3) nfsm_postop_attr(vp, retattr); @@ -189,7 +189,7 @@ nfs_fsinfo(nmp, vp, cred, p) nfsstats.rpccnt[NFSPROC_FSINFO]++; mb = mreq = nfsm_reqhead(NFSX_FH(1)); - nfsm_fhtom(vp, 1); + nfsm_fhtom(&mb, vp, 1); nfsm_request(vp, NFSPROC_FSINFO, p, cred); nfsm_postop_attr(vp, retattr); if (!error) { diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 53e4be8406e..1df5063e9e0 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.111 2009/01/24 23:37:56 thib Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.112 2009/04/13 17:51:57 blambert Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -290,7 +290,7 @@ nfs_access(v) if (v3) { nfsstats.rpccnt[NFSPROC_ACCESS]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED); - nfsm_fhtom(vp, v3); + nfsm_fhtom(&mb, vp, v3); tl = nfsm_build(&mb, NFSX_UNSIGNED); if (ap->a_mode & VREAD) mode = NFSV3ACCESS_READ; @@ -507,7 +507,7 @@ nfs_getattr(v) return (0); nfsstats.rpccnt[NFSPROC_GETATTR]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3)); - nfsm_fhtom(vp, v3); + nfsm_fhtom(&mb, vp, v3); nfsm_request(vp, NFSPROC_GETATTR, ap->a_p, ap->a_cred); if (!error) nfsm_loadattr(vp, ap->a_vap); @@ -620,7 +620,7 @@ nfs_setattrrpc(vp, vap, cred, procp) nfsstats.rpccnt[NFSPROC_SETATTR]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_SATTR(v3)); - nfsm_fhtom(vp, v3); + nfsm_fhtom(&mb, vp, v3); if (v3) { nfsm_v3attrbuild(&mb, vap, 1); tl = nfsm_build(&mb, NFSX_UNSIGNED); @@ -769,7 +769,7 @@ dorpc: nfsstats.rpccnt[NFSPROC_LOOKUP]++; len = cnp->cn_namelen; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN); nfsm_request(dvp, NFSPROC_LOOKUP, cnp->cn_proc, cnp->cn_cred); if (error) { @@ -956,7 +956,7 @@ nfs_readlinkrpc(vp, uiop, cred) nfsstats.rpccnt[NFSPROC_READLINK]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3)); - nfsm_fhtom(vp, v3); + nfsm_fhtom(&mb, vp, v3); nfsm_request(vp, NFSPROC_READLINK, uiop->uio_procp, cred); if (v3) nfsm_postop_attr(vp, attrflag); @@ -996,7 +996,7 @@ nfs_readrpc(vp, uiop) nfsstats.rpccnt[NFSPROC_READ]++; len = (tsiz > nmp->nm_rsize) ? nmp->nm_rsize : tsiz; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED * 3); - nfsm_fhtom(vp, v3); + nfsm_fhtom(&mb, vp, v3); tl = nfsm_build(&mb, NFSX_UNSIGNED * 3); if (v3) { txdr_hyper(uiop->uio_offset, tl); @@ -1062,7 +1062,7 @@ nfs_writerpc(vp, uiop, iomode, must_commit) len = (tsiz > nmp->nm_wsize) ? nmp->nm_wsize : tsiz; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + 5 * NFSX_UNSIGNED + nfsm_rndup(len)); - nfsm_fhtom(vp, v3); + nfsm_fhtom(&mb, vp, v3); if (v3) { tl = nfsm_build(&mb, 5 * NFSX_UNSIGNED); txdr_hyper(uiop->uio_offset, tl); @@ -1178,7 +1178,7 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) nfsstats.rpccnt[NFSPROC_MKNOD]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + 4 * NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3)); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); if (v3) { tl = nfsm_build(&mb, NFSX_UNSIGNED); @@ -1284,7 +1284,7 @@ again: nfsstats.rpccnt[NFSPROC_CREATE]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + 2 * NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3)); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); if (v3) { tl = nfsm_build(&mb, NFSX_UNSIGNED); @@ -1452,7 +1452,7 @@ nfs_removerpc(dvp, name, namelen, cred, proc) nfsstats.rpccnt[NFSPROC_REMOVE]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(namelen)); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(name, namelen, NFS_MAXNAMLEN); nfsm_request(dvp, NFSPROC_REMOVE, proc, cred); if (v3) @@ -1570,9 +1570,9 @@ nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) nfsstats.rpccnt[NFSPROC_RENAME]++; mb = mreq = nfsm_reqhead((NFSX_FH(v3) + NFSX_UNSIGNED)*2 + nfsm_rndup(fnamelen) + nfsm_rndup(tnamelen)); - nfsm_fhtom(fdvp, v3); + nfsm_fhtom(&mb, fdvp, v3); nfsm_strtom(fnameptr, fnamelen, NFS_MAXNAMLEN); - nfsm_fhtom(tdvp, v3); + nfsm_fhtom(&mb, tdvp, v3); nfsm_strtom(tnameptr, tnamelen, NFS_MAXNAMLEN); nfsm_request(fdvp, NFSPROC_RENAME, proc, cred); if (v3) { @@ -1628,8 +1628,8 @@ nfs_link(v) nfsstats.rpccnt[NFSPROC_LINK]++; mb = mreq = nfsm_reqhead(2 * NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); - nfsm_fhtom(vp, v3); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, vp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); nfsm_request(vp, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred); if (v3) { @@ -1675,7 +1675,7 @@ nfs_symlink(v) slen = strlen(ap->a_target); mb = mreq = nfsm_reqhead(NFSX_FH(v3) + 2 * NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen) + nfsm_rndup(slen) + NFSX_SATTR(v3)); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); if (v3) nfsm_v3attrbuild(&mb, vap, 0); @@ -1735,7 +1735,7 @@ nfs_mkdir(v) nfsstats.rpccnt[NFSPROC_MKDIR]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len) + NFSX_SATTR(v3)); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN); if (v3) { nfsm_v3attrbuild(&mb, vap, 0); @@ -1809,7 +1809,7 @@ nfs_rmdir(v) nfsstats.rpccnt[NFSPROC_RMDIR]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); nfsm_request(dvp, NFSPROC_RMDIR, cnp->cn_proc, cnp->cn_cred); if (v3) @@ -2045,7 +2045,7 @@ nfs_readdirrpc(struct vnode *vp, while (more_dirs && bigenough) { nfsstats.rpccnt[NFSPROC_READDIR]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_READDIR(v3)); - nfsm_fhtom(vp, v3); + nfsm_fhtom(&mb, vp, v3); if (v3) { tl = nfsm_build(&mb, 5 * NFSX_UNSIGNED); *tl++ = cookie.nfsuquad[0]; @@ -2236,7 +2236,7 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, while (more_dirs && bigenough) { nfsstats.rpccnt[NFSPROC_READDIRPLUS]++; mb = mreq = nfsm_reqhead(NFSX_FH(1) + 6 * NFSX_UNSIGNED); - nfsm_fhtom(vp, 1); + nfsm_fhtom(&mb, vp, 1); tl = nfsm_build(&mb, 6 * NFSX_UNSIGNED); *tl++ = cookie.nfsuquad[0]; *tl++ = cookie.nfsuquad[1]; @@ -2508,7 +2508,7 @@ nfs_lookitup(dvp, name, len, cred, procp, npp) nfsstats.rpccnt[NFSPROC_LOOKUP]++; mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); - nfsm_fhtom(dvp, v3); + nfsm_fhtom(&mb, dvp, v3); nfsm_strtom(name, len, NFS_MAXNAMLEN); nfsm_request(dvp, NFSPROC_LOOKUP, procp, cred); if (npp && !error) { @@ -2574,7 +2574,7 @@ nfs_commit(vp, offset, cnt, procp) return (0); nfsstats.rpccnt[NFSPROC_COMMIT]++; mb = mreq = nfsm_reqhead(NFSX_FH(1)); - nfsm_fhtom(vp, 1); + nfsm_fhtom(&mb, vp, 1); tl = nfsm_build(&mb, 3 * NFSX_UNSIGNED); txdr_hyper(offset, tl); tl += 2; diff --git a/sys/nfs/nfsm_subs.h b/sys/nfs/nfsm_subs.h index bd31482aded..828d5c7bf69 100644 --- a/sys/nfs/nfsm_subs.h +++ b/sys/nfs/nfsm_subs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfsm_subs.h,v 1.34 2009/03/30 19:58:50 blambert Exp $ */ +/* $OpenBSD: nfsm_subs.h,v 1.35 2009/04/13 17:51:57 blambert Exp $ */ /* $NetBSD: nfsm_subs.h,v 1.10 1996/03/20 21:59:56 fvdl Exp $ */ /* @@ -80,21 +80,6 @@ (a) = (c)cp2; \ } } -#define nfsm_fhtom(v, v3) \ - { if (v3) { \ - nfsm_strtombuf(&mb, VTONFS(v)->n_fhp, \ - VTONFS(v)->n_fhsize); \ - } else { \ - nfsm_buftombuf(&mb, VTONFS(v)->n_fhp, NFSX_V2FH); \ - } } - -#define nfsm_srvfhtom(f, v3) \ - { if (v3) { \ - nfsm_strtombuf(&mb, (f), NFSX_V3FH); \ - } else { \ - nfsm_buftombuf(&mb, (f), NFSX_V2FH); \ - } } - #define nfsm_srvpostop_fh(f) \ { tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED + NFSX_V3FH); \ *tl++ = nfs_true; \ |