version 1.204, 2008/06/04 12:41:40 |
version 1.204.4.1, 2008/10/19 22:17:59 |
Line 99 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 99 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/dirent.h> |
#include <sys/dirent.h> |
#include <sys/once.h> |
#include <sys/once.h> |
#include <sys/kauth.h> |
#include <sys/kauth.h> |
|
#include <sys/atomic.h> |
|
|
#include <uvm/uvm_extern.h> |
#include <uvm/uvm_extern.h> |
|
|
Line 119 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 120 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <netiso/iso.h> |
#include <netiso/iso.h> |
#endif |
#endif |
|
|
|
static u_int32_t nfs_xid; |
|
|
/* |
/* |
* Data items converted to xdr at startup, since they are constant |
* Data items converted to xdr at startup, since they are constant |
* This is kinda hokey, but may save a little time doing byte swaps |
* This is kinda hokey, but may save a little time doing byte swaps |
Line 1539 nfs_init0(void) |
|
Line 1542 nfs_init0(void) |
|
nfs_ticks = (hz * NFS_TICKINTVL + 500) / 1000; |
nfs_ticks = (hz * NFS_TICKINTVL + 500) / 1000; |
if (nfs_ticks < 1) |
if (nfs_ticks < 1) |
nfs_ticks = 1; |
nfs_ticks = 1; |
|
nfs_xid = arc4random(); |
#ifdef NFSSERVER |
#ifdef NFSSERVER |
vfs_hooks_attach(&nfs_export_hooks); |
vfs_hooks_attach(&nfs_export_hooks); |
nfsrv_init(0); /* Init server data structures */ |
nfsrv_init(0); /* Init server data structures */ |
Line 1566 nfs_init0(void) |
|
Line 1570 nfs_init0(void) |
|
/* Initialize the iod structures */ |
/* Initialize the iod structures */ |
nfs_iodinit(); |
nfs_iodinit(); |
#endif |
#endif |
|
|
return 0; |
return 0; |
} |
} |
|
|
|
|
void |
void |
nfs_vfs_init() |
nfs_vfs_init() |
{ |
{ |
|
|
/* Initialize NFS server / client shared data. */ |
/* Initialize NFS server / client shared data. */ |
nfs_init(); |
nfs_init(); |
|
|
nfs_nhinit(); /* Init the nfsnode table */ |
nfs_node_init(); |
nfs_commitsize = uvmexp.npages << (PAGE_SHIFT - 4); |
nfs_commitsize = uvmexp.npages << (PAGE_SHIFT - 4); |
} |
} |
|
|
void |
void |
nfs_vfs_reinit() |
nfs_vfs_reinit() |
{ |
{ |
nfs_nhreinit(); |
|
|
nfs_node_reinit(); |
} |
} |
|
|
void |
void |
nfs_vfs_done() |
nfs_vfs_done() |
{ |
{ |
nfs_nhdone(); |
|
|
nfs_node_done(); |
} |
} |
|
|
/* |
/* |
Line 1724 nfs_loadattrcache(vpp, fp, vaper, flags) |
|
Line 1732 nfs_loadattrcache(vpp, fp, vaper, flags) |
|
vap->va_rdev = (dev_t)rdev; |
vap->va_rdev = (dev_t)rdev; |
vap->va_mtime = mtime; |
vap->va_mtime = mtime; |
vap->va_ctime = ctime; |
vap->va_ctime = ctime; |
|
vap->va_birthtime.tv_sec = VNOVAL; |
|
vap->va_birthtime.tv_nsec = VNOVAL; |
vap->va_fsid = vp->v_mount->mnt_stat.f_fsidx.__fsid_val[0]; |
vap->va_fsid = vp->v_mount->mnt_stat.f_fsidx.__fsid_val[0]; |
switch (vtyp) { |
switch (vtyp) { |
case VDIR: |
case VDIR: |
Line 2903 nfsrv_errmap(nd, err) |
|
Line 2913 nfsrv_errmap(nd, err) |
|
u_int32_t |
u_int32_t |
nfs_getxid() |
nfs_getxid() |
{ |
{ |
static u_int32_t base; |
|
static u_int32_t nfs_xid = 0; |
|
static struct simplelock nfs_xidlock = SIMPLELOCK_INITIALIZER; |
|
u_int32_t newxid; |
u_int32_t newxid; |
|
|
simple_lock(&nfs_xidlock); |
/* get next xid. skip 0 */ |
/* |
do { |
* derive initial xid from system time |
newxid = atomic_inc_32_nv(&nfs_xid); |
* XXX time is invalid if root not yet mounted |
} while (__predict_false(newxid == 0)); |
*/ |
|
if (__predict_false(!base && (rootvp))) { |
|
struct timeval tv; |
|
|
|
microtime(&tv); |
|
base = tv.tv_sec << 12; |
|
nfs_xid = base; |
|
} |
|
|
|
/* |
|
* Skip zero xid if it should ever happen. |
|
*/ |
|
if (__predict_false(++nfs_xid == 0)) |
|
nfs_xid++; |
|
newxid = nfs_xid; |
|
simple_unlock(&nfs_xidlock); |
|
|
|
return txdr_unsigned(newxid); |
return txdr_unsigned(newxid); |
} |
} |