#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);
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 NFSCLLAYOUTHASHSIZE 256
#define NFSCLLAYOUTHASH(c, f, l) \
(&((c)->nfsc_layouthash[ncl_hash((f), (l)) % NFSCLLAYOUTHASHSIZE]))
struct nfsclsession {
kmutex_t nfsess_mtx;
struct nfsslot nfsess_cbslots[NFSV4_CBSLOTS];
nfsquad_t nfsess_clientid;
SVCXPRT *nfsess_xprt;
uint32_t nfsess_slotseq[64];
uint64_t nfsess_slots;
uint32_t nfsess_sequenceid;
uint32_t nfsess_maxcache;
uint16_t nfsess_foreslots;
uint16_t nfsess_backslots;
uint8_t nfsess_sessionid[NFSX_V4SESSIONID];
};
struct nfsclds {
TAILQ_ENTRY(nfsclds) nfsclds_list;
struct nfsclsession nfsclds_sess;
kmutex_t 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
struct nfsclclient {
LIST_ENTRY(nfsclclient) nfsc_list;
struct nfsclownerhead nfsc_owner;
struct nfscldeleghead nfsc_deleg;
struct nfscldeleghash nfsc_deleghash[NFSCLDELEGHASHSIZE];
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;
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;
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
struct nfsclflayout {
LIST_ENTRY(nfsclflayout) nfsfl_list;
uint8_t nfsfl_dev[NFSX_V4DEVICEID];
uint64_t nfsfl_off;
uint64_t nfsfl_end;
uint64_t nfsfl_patoff;
struct nfscldevinfo *nfsfl_devp;
uint32_t nfsfl_iomode;
uint32_t nfsfl_util;
uint32_t nfsfl_stripe1;
uint16_t nfsfl_flags;
uint16_t nfsfl_fhcnt;
struct nfsfh *nfsfl_fh[1];
};
#define NFSFL_RECALL 0x0001
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;
};
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;
uint16_t nfsdi_stripecnt;
uint16_t nfsdi_addrcnt;
struct nfsclds *nfsdi_data[0];
};
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