#ifndef _NFS_NFSCLSTATE_H_
#define _NFS_NFSCLSTATE_H_
LIST_HEAD(nfsclopenhead, nfsclopen);
LIST_HEAD(nfscllockownerhead, nfscllockowner);
SLIST_HEAD(nfscllockownerfhhead, nfscllockownerfh);
LIST_HEAD(nfscllockhead, nfscllock);
LIST_HEAD(nfsclhead, nfsclclient);
LIST_HEAD(nfsclownerhead, nfsclowner);
TAILQ_HEAD(nfscldeleghead, nfscldeleg);
LIST_HEAD(nfscldeleghash, nfscldeleg);
LIST_HEAD(nfsclopenhash, nfsclopen);
TAILQ_HEAD(nfscllayouthead, nfscllayout);
LIST_HEAD(nfscllayouthash, nfscllayout);
LIST_HEAD(nfsclflayouthead, nfsclflayout);
LIST_HEAD(nfscldevinfohead, nfscldevinfo);
LIST_HEAD(nfsclrecalllayouthead, nfsclrecalllayout);
#define NFSCLDELEGHASHSIZE 256
#define NFSCLDELEGHASH(c, f, l) \
(&((c)->nfsc_deleghash[ncl_hash((f), (l)) % NFSCLDELEGHASHSIZE]))
#define NFSCLOPENHASHSIZE 256
#define NFSCLOPENHASHFUNC(f, l) (ncl_hash((f), (l)) % NFSCLOPENHASHSIZE)
#define NFSCLOPENHASH(c, f, l) \
(&((c)->nfsc_openhash[NFSCLOPENHASHFUNC((f), (l))]))
#define NFSCLLAYOUTHASHSIZE 256
#define NFSCLLAYOUTHASH(c, f, l) \
(&((c)->nfsc_layouthash[ncl_hash((f), (l)) % NFSCLLAYOUTHASHSIZE]))
struct nfsclsession {
struct mtx nfsess_mtx;
struct nfsslot nfsess_cbslots[NFSV4_CBSLOTS];
nfsquad_t nfsess_clientid;
SVCXPRT *nfsess_xprt;
uint32_t nfsess_slotseq[64];
uint64_t nfsess_slots;
uint64_t nfsess_badslots;
uint32_t nfsess_sequenceid;
uint32_t nfsess_maxcache;
uint32_t nfsess_maxreq;
uint32_t nfsess_maxresp;
uint16_t nfsess_foreslots;
uint16_t nfsess_backslots;
uint8_t nfsess_sessionid[NFSX_V4SESSIONID];
uint8_t nfsess_defunct;
};
struct nfsclds {
TAILQ_ENTRY(nfsclds) nfsclds_list;
struct nfsclsession nfsclds_sess;
struct mtx nfsclds_mtx;
struct nfssockreq *nfsclds_sockp;
time_t nfsclds_expire;
uint16_t nfsclds_flags;
uint16_t nfsclds_servownlen;
uint8_t nfsclds_verf[NFSX_VERF];
uint8_t nfsclds_serverown[0];
};
#define NFSCLDS_HASWRITEVERF 0x0001
#define NFSCLDS_MDS 0x0002
#define NFSCLDS_DS 0x0004
#define NFSCLDS_CLOSED 0x0008
#define NFSCLDS_SAMECONN 0x0010
#define NFSCLDS_MINORV2 0x0020
struct nfsclclient {
LIST_ENTRY(nfsclclient) nfsc_list;
struct nfsclownerhead nfsc_owner;
struct nfscldeleghead nfsc_deleg;
struct nfscldeleghash nfsc_deleghash[NFSCLDELEGHASHSIZE];
struct nfsclopenhash nfsc_openhash[NFSCLOPENHASHSIZE];
struct nfscllayouthead nfsc_layout;
struct nfscllayouthash nfsc_layouthash[NFSCLLAYOUTHASHSIZE];
struct nfscldevinfohead nfsc_devinfo;
struct nfsv4lock nfsc_lock;
struct proc *nfsc_renewthread;
struct nfsmount *nfsc_nmp;
time_t nfsc_expire;
int nfsc_delegcnt;
int nfsc_deleghighwater;
int nfsc_layoutcnt;
int nfsc_layouthighwater;
u_int32_t nfsc_clientidrev;
u_int32_t nfsc_rev;
u_int32_t nfsc_renew;
u_int32_t nfsc_cbident;
u_int16_t nfsc_flags;
u_int16_t nfsc_idlen;
u_int8_t nfsc_id[1];
};
#define NFSCLFLAGS_INITED 0x0001
#define NFSCLFLAGS_HASCLIENTID 0x0002
#define NFSCLFLAGS_RECOVER 0x0004
#define NFSCLFLAGS_UMOUNT 0x0008
#define NFSCLFLAGS_HASTHREAD 0x0010
#define NFSCLFLAGS_AFINET6 0x0020
#define NFSCLFLAGS_EXPIREIT 0x0040
#define NFSCLFLAGS_FIRSTDELEG 0x0080
#define NFSCLFLAGS_GOTDELEG 0x0100
#define NFSCLFLAGS_RECVRINPROG 0x0200
struct nfsclowner {
LIST_ENTRY(nfsclowner) nfsow_list;
struct nfsclopenhead nfsow_open;
struct nfsclclient *nfsow_clp;
u_int32_t nfsow_seqid;
u_int32_t nfsow_defunct;
struct nfsv4lock nfsow_rwlock;
u_int8_t nfsow_owner[NFSV4CL_LOCKNAMELEN];
};
struct nfscldeleg {
TAILQ_ENTRY(nfscldeleg) nfsdl_list;
LIST_ENTRY(nfscldeleg) nfsdl_hash;
struct nfsclownerhead nfsdl_owner;
struct nfscllockownerhead nfsdl_lock;
nfsv4stateid_t nfsdl_stateid;
struct acl_entry nfsdl_ace;
struct nfsclclient *nfsdl_clp;
struct nfsv4lock nfsdl_rwlock;
struct nfscred nfsdl_cred;
time_t nfsdl_timestamp;
u_int64_t nfsdl_sizelimit;
u_int64_t nfsdl_size;
u_int64_t nfsdl_change;
struct timespec nfsdl_modtime;
u_int16_t nfsdl_fhlen;
u_int8_t nfsdl_flags;
u_int8_t nfsdl_fh[1];
};
#define NFSCLDL_READ 0x01
#define NFSCLDL_WRITE 0x02
#define NFSCLDL_RECALL 0x04
#define NFSCLDL_NEEDRECLAIM 0x08
#define NFSCLDL_ZAPPED 0x10
#define NFSCLDL_MODTIMESET 0x20
#define NFSCLDL_DELEGRET 0x40
struct nfsclopen {
LIST_ENTRY(nfsclopen) nfso_list;
LIST_ENTRY(nfsclopen) nfso_hash;
struct nfscllockownerhead nfso_lock;
nfsv4stateid_t nfso_stateid;
struct nfsclowner *nfso_own;
struct nfscred nfso_cred;
u_int32_t nfso_mode;
u_int32_t nfso_opencnt;
u_int16_t nfso_fhlen;
u_int8_t nfso_posixlock;
u_int8_t nfso_fh[1];
};
#define NFSCLOPEN_OK 0
#define NFSCLOPEN_DOOPEN 1
#define NFSCLOPEN_DOOPENDOWNGRADE 2
#define NFSCLOPEN_SETCRED 3
struct nfscllockowner {
LIST_ENTRY(nfscllockowner) nfsl_list;
struct nfscllockhead nfsl_lock;
struct nfsclopen *nfsl_open;
NFSPROC_T *nfsl_inprog;
nfsv4stateid_t nfsl_stateid;
int nfsl_lockflags;
u_int32_t nfsl_seqid;
struct nfsv4lock nfsl_rwlock;
u_int8_t nfsl_owner[NFSV4CL_LOCKNAMELEN];
u_int8_t nfsl_openowner[NFSV4CL_LOCKNAMELEN];
};
struct nfscllock {
LIST_ENTRY(nfscllock) nfslo_list;
u_int64_t nfslo_first;
u_int64_t nfslo_end;
short nfslo_type;
};
struct nfscllockownerfh {
SLIST_ENTRY(nfscllockownerfh) nfslfh_list;
struct nfscllockownerhead nfslfh_lock;
int nfslfh_len;
uint8_t nfslfh_fh[NFSX_V4FHMAX];
};
struct nfscllayout {
TAILQ_ENTRY(nfscllayout) nfsly_list;
LIST_ENTRY(nfscllayout) nfsly_hash;
nfsv4stateid_t nfsly_stateid;
struct nfsv4lock nfsly_lock;
uint64_t nfsly_filesid[2];
uint64_t nfsly_lastbyte;
struct nfsclflayouthead nfsly_flayread;
struct nfsclflayouthead nfsly_flayrw;
struct nfsclrecalllayouthead nfsly_recall;
time_t nfsly_timestamp;
struct nfsclclient *nfsly_clp;
uint16_t nfsly_flags;
uint16_t nfsly_fhlen;
uint8_t nfsly_fh[1];
};
#define NFSLY_FILES 0x0001
#define NFSLY_BLOCK 0x0002
#define NFSLY_OBJECT 0x0004
#define NFSLY_RECALL 0x0008
#define NFSLY_RECALLFILE 0x0010
#define NFSLY_RECALLFSID 0x0020
#define NFSLY_RECALLALL 0x0040
#define NFSLY_RETONCLOSE 0x0080
#define NFSLY_WRITTEN 0x0100
#define NFSLY_FLEXFILE 0x0200
#define NFSLY_RETURNED 0x0400
struct nfsffm {
nfsv4stateid_t st;
struct nfscldevinfo *devp;
char dev[NFSX_V4DEVICEID];
uint32_t eff;
uid_t user;
gid_t group;
struct nfsfh *fh[NFSDEV_MAXVERS];
uint16_t fhcnt;
};
struct nfsclflayout {
LIST_ENTRY(nfsclflayout) nfsfl_list;
uint64_t nfsfl_off;
uint64_t nfsfl_end;
uint32_t nfsfl_iomode;
uint16_t nfsfl_flags;
union {
struct {
uint64_t patoff;
uint32_t util;
uint32_t stripe1;
uint8_t dev[NFSX_V4DEVICEID];
uint16_t fhcnt;
struct nfscldevinfo *devp;
} fl;
struct {
uint64_t stripeunit;
uint32_t fflags;
uint32_t statshint;
uint16_t mirrorcnt;
} ff;
} nfsfl_un;
union {
struct nfsfh *fh[0];
struct nfsffm ffm[0];
} nfsfl_un2;
};
#define nfsfl_patoff nfsfl_un.fl.patoff
#define nfsfl_util nfsfl_un.fl.util
#define nfsfl_stripe1 nfsfl_un.fl.stripe1
#define nfsfl_dev nfsfl_un.fl.dev
#define nfsfl_fhcnt nfsfl_un.fl.fhcnt
#define nfsfl_devp nfsfl_un.fl.devp
#define nfsfl_stripeunit nfsfl_un.ff.stripeunit
#define nfsfl_fflags nfsfl_un.ff.fflags
#define nfsfl_statshint nfsfl_un.ff.statshint
#define nfsfl_mirrorcnt nfsfl_un.ff.mirrorcnt
#define nfsfl_fh nfsfl_un2.fh
#define nfsfl_ffm nfsfl_un2.ffm
#define NFSFL_RECALL 0x0001
#define NFSFL_FILE 0x0002
#define NFSFL_FLEXFILE 0x0004
struct nfsclrecalllayout {
LIST_ENTRY(nfsclrecalllayout) nfsrecly_list;
uint64_t nfsrecly_off;
uint64_t nfsrecly_len;
int nfsrecly_recalltype;
uint32_t nfsrecly_iomode;
uint32_t nfsrecly_stateseqid;
uint32_t nfsrecly_stat;
uint32_t nfsrecly_op;
char nfsrecly_devid[NFSX_V4DEVICEID];
};
struct nfscldevinfo {
LIST_ENTRY(nfscldevinfo) nfsdi_list;
uint8_t nfsdi_deviceid[NFSX_V4DEVICEID];
struct nfsclclient *nfsdi_clp;
uint32_t nfsdi_refcnt;
uint32_t nfsdi_layoutrefs;
union {
struct {
uint16_t stripecnt;
} fl;
struct {
int versindex;
uint32_t vers;
uint32_t minorvers;
uint32_t rsize;
uint32_t wsize;
} ff;
} nfsdi_un;
uint16_t nfsdi_addrcnt;
uint16_t nfsdi_flags;
struct nfsclds *nfsdi_data[0];
};
#define nfsdi_stripecnt nfsdi_un.fl.stripecnt
#define nfsdi_versindex nfsdi_un.ff.versindex
#define nfsdi_vers nfsdi_un.ff.vers
#define nfsdi_minorvers nfsdi_un.ff.minorvers
#define nfsdi_rsize nfsdi_un.ff.rsize
#define nfsdi_wsize nfsdi_un.ff.wsize
#define NFSDI_FILELAYOUT 0x0001
#define NFSDI_FLEXFILE 0x0002
#define NFSDI_TIGHTCOUPLED 0X0004
static __inline struct nfsclds **
nfsfldi_addr(struct nfscldevinfo *ndi, int pos)
{
if (pos >= ndi->nfsdi_addrcnt)
return (NULL);
return (&ndi->nfsdi_data[pos]);
}
static __inline int
nfsfldi_stripeindex(struct nfscldevinfo *ndi, int pos)
{
uint8_t *valp;
if (pos >= ndi->nfsdi_stripecnt)
return (-1);
valp = (uint8_t *)&ndi->nfsdi_data[ndi->nfsdi_addrcnt];
valp += pos;
return ((int)*valp);
}
static __inline void
nfsfldi_setstripeindex(struct nfscldevinfo *ndi, int pos, uint8_t val)
{
uint8_t *valp;
if (pos >= ndi->nfsdi_stripecnt)
return;
valp = (uint8_t *)&ndi->nfsdi_data[ndi->nfsdi_addrcnt];
valp += pos;
*valp = val;
}
#define NFSCL_INCRSEQID(s, n) do { \
if (((n)->nd_flag & ND_INCRSEQID)) \
(s)++; \
} while (0)
#endif