shrink sizeof struct nfsnode by putting exclusive members into union.

This commit is contained in:
yamt 2004-03-12 16:52:37 +00:00
parent a4cbf5b042
commit c819fadc97
4 changed files with 80 additions and 46 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_node.c,v 1.72 2004/01/23 22:20:20 wrstuden Exp $ */
/* $NetBSD: nfs_node.c,v 1.73 2004/03/12 16:52:37 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.72 2004/01/23 22:20:20 wrstuden Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.73 2004/03/12 16:52:37 yamt Exp $");
#include "opt_nfs.h"
@ -159,7 +159,6 @@ nfs_nget(mntp, fhp, fhsize, npp)
struct nfsnode *np;
struct nfsnodehashhead *nhpp;
struct vnode *vp;
struct vnode *nvp;
int error;
nhpp = &nfsnodehashtbl[NFSNOHASH(nfs_hash(fhp, fhsize))];
@ -176,16 +175,14 @@ loop:
}
if (lockmgr(&nfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0))
goto loop;
error = getnewvnode(VT_NFS, mntp, nfsv2_vnodeop_p, &nvp);
error = getnewvnode(VT_NFS, mntp, nfsv2_vnodeop_p, &vp);
if (error) {
*npp = 0;
lockmgr(&nfs_hashlock, LK_RELEASE, 0);
return (error);
}
vp = nvp;
np = pool_get(&nfs_node_pool, PR_WAITOK);
memset(np, 0, sizeof *np);
lockinit(&np->n_commitlock, PINOD, "nfsclock", 0, 0);
vp->v_data = np;
np->n_vnode = vp;
genfs_node_init(vp, &nfs_genfsops);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_subs.c,v 1.130 2003/11/29 19:31:13 yamt Exp $ */
/* $NetBSD: nfs_subs.c,v 1.131 2004/03/12 16:52:37 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.130 2003/11/29 19:31:13 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.131 2004/03/12 16:52:37 yamt Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@ -1622,8 +1622,9 @@ nfs_loadattrcache(vpp, fp, vaper, flags)
if (vp->v_type == VFIFO) {
extern int (**fifo_nfsv2nodeop_p) __P((void *));
vp->v_op = fifo_nfsv2nodeop_p;
}
if (vp->v_type == VCHR || vp->v_type == VBLK) {
} else if (vp->v_type == VREG) {
lockinit(&np->n_commitlock, PINOD, "nfsclock", 0, 0);
} else if (vp->v_type == VCHR || vp->v_type == VBLK) {
vp->v_op = spec_nfsv2nodeop_p;
nvp = checkalias(vp, (dev_t)rdev, vp->v_mount);
if (nvp) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_vnops.c,v 1.185 2004/03/12 16:52:14 yamt Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.186 2004/03/12 16:52:37 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.185 2004/03/12 16:52:14 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.186 2004/03/12 16:52:37 yamt Exp $");
#include "opt_nfs.h"
#include "opt_uvmhist.h"
@ -3046,7 +3046,12 @@ nfs_fsync(v)
struct proc * a_p;
} */ *ap = v;
return (nfs_flush(ap->a_vp, ap->a_cred,
struct vnode *vp = ap->a_vp;
if (vp->v_type != VREG)
return 0;
return (nfs_flush(vp, ap->a_cred,
(ap->a_flags & FSYNC_WAIT) != 0 ? MNT_WAIT : 0, ap->a_p, 1));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfsnode.h,v 1.45 2004/03/12 16:52:14 yamt Exp $ */
/* $NetBSD: nfsnode.h,v 1.46 2004/03/12 16:52:38 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -93,39 +93,77 @@ struct nfsdircache {
* each current directory, each mounted-on file, text file, and the root.
* An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
*/
struct nfsnode_spec {
struct timespec nspec_mtim; /* local mtime */
struct timespec nspec_atim; /* local atime */
};
struct nfsnode_reg {
off_t nreg_pushedlo; /* 1st blk in commited range */
off_t nreg_pushedhi; /* Last block in range */
off_t nreg_pushlo; /* 1st block in commit range */
off_t nreg_pushhi; /* Last block in range */
struct lock nreg_commitlock; /* Serialize commits XXX */
int nreg_commitflags;
int nreg_error; /* Save write error value */
};
struct nfsnode_dir {
off_t ndir_direof; /* EOF offset cache */
nfsuint64 ndir_cookieverf; /* Cookie verifier */
daddr_t ndir_dblkno; /* faked dir blkno */
struct nfsdirhashhead *ndir_dircache; /* offset -> cache hash heads */
struct nfsdirchainhead ndir_dirchain; /* Chain of dir cookies */
struct timespec ndir_nctime; /* Last neg cache entry */
unsigned ndir_dircachesize; /* Size of dir cookie cache */
};
struct nfsnode {
struct genfs_node n_gnode;
u_quad_t n_size; /* Current size of file */
u_quad_t n_brev; /* Modify rev when cached */
u_quad_t n_lrev; /* Modify rev for lease */
union {
struct timespec nf_mtim;
off_t nd_direof; /* Dir. EOF offset cache */
} n_un2;
union {
struct timespec nf_atim; /* Special file times */
nfsuint64 nd_cookieverf; /* Cookie verifier (dir only) */
struct nfsnode_spec nu_spec;
struct nfsnode_reg nu_reg;
struct nfsnode_dir nu_dir;
} n_un1;
#define n_mtim n_un1.nu_spec.nspec_mtim
#define n_atim n_un1.nu_spec.nspec_atim
#define n_pushedlo n_un1.nu_reg.nreg_pushedlo
#define n_pushedhi n_un1.nu_reg.nreg_pushedhi
#define n_pushlo n_un1.nu_reg.nreg_pushlo
#define n_pushhi n_un1.nu_reg.nreg_pushhi
#define n_commitlock n_un1.nu_reg.nreg_commitlock
#define n_commitflags n_un1.nu_reg.nreg_commitflags
#define n_error n_un1.nu_reg.nreg_error
#define n_direofoffset n_un1.nu_dir.ndir_direof
#define n_cookieverf n_un1.nu_dir.ndir_cookieverf
#define n_dblkno n_un1.nu_dir.ndir_dblkno
#define n_dircache n_un1.nu_dir.ndir_dircache
#define n_dirchain n_un1.nu_dir.ndir_dirchain
#define n_nctime n_un1.nu_dir.ndir_nctime
#define n_dircachesize n_un1.nu_dir.ndir_dircachesize
union {
struct sillyrename *nf_silly; /* Ptr to silly rename struct */
struct nfsdirhashhead *nd_dircache;
} n_un3;
struct sillyrename *nf_silly; /* !VDIR: silly rename struct */
unsigned *ndir_dirgens; /* 32<->64bit xlate gen. no. */
} n_un2;
#define n_sillyrename n_un2.nf_silly
#define n_dirgens n_un2.ndir_dirgens
LIST_ENTRY(nfsnode) n_hash; /* Hash chain */
CIRCLEQ_ENTRY(nfsnode) n_timer; /* Nqnfs timer chain */
struct nfsdirchainhead n_dirchain; /* Chain of dir cookies */
nfsfh_t *n_fhp; /* NFS File Handle */
struct vattr *n_vattr; /* Vnode attribute cache */
struct vnode *n_vnode; /* associated vnode */
struct lockf *n_lockf; /* Locking record of file */
unsigned *n_dirgens; /* 32<->64bit xlate gen. no. */
time_t n_attrstamp; /* Attr. cache timestamp */
struct timespec n_mtime; /* Prev modify time. */
time_t n_ctime; /* Prev create time. */
struct timespec n_nctime; /* Last neg cache entry (dir) */
time_t n_expiry; /* Lease expiry time */
daddr_t n_dblkno; /* To keep faked dir blkno */
unsigned n_dircachesize; /* Size of dir cookie cache */
int n_error; /* Save write error value */
short n_fhsize; /* size in bytes, of fh */
short n_flag; /* Flag for locking.. */
nfsfh_t n_fh; /* Small File Handle */
@ -133,14 +171,14 @@ struct nfsnode {
uid_t n_accuid; /* Last access requester */
int n_accmode; /* Mode last requested */
int n_accerror; /* Error last returned */
off_t n_pushedlo; /* 1st blk in commited range */
off_t n_pushedhi; /* Last block in range */
off_t n_pushlo; /* 1st block in commit range */
off_t n_pushhi; /* Last block in range */
struct lock n_commitlock; /* Serialize commits XXX */
int n_commitflags;
struct ucred *n_rcred;
struct ucred *n_wcred;
/* members below are only used by NQNFS */
CIRCLEQ_ENTRY(nfsnode) n_timer; /* Nqnfs timer chain */
u_quad_t n_brev; /* Modify rev when cached */
u_quad_t n_lrev; /* Modify rev for lease */
time_t n_expiry; /* Lease expiry time */
};
LIST_HEAD(nfsnodehashhead, nfsnode);
@ -150,13 +188,6 @@ LIST_HEAD(nfsnodehashhead, nfsnode);
#define NFS_COMMIT_PUSH_VALID 0x0001 /* push range valid */
#define NFS_COMMIT_PUSHED_VALID 0x0002 /* pushed range valid */
#define n_atim n_un1.nf_atim
#define n_mtim n_un2.nf_mtim
#define n_sillyrename n_un3.nf_silly
#define n_cookieverf n_un1.nd_cookieverf
#define n_direofoffset n_un2.nd_direof
#define n_dircache n_un3.nd_dircache
/*
* Flags for n_flag
*/