Consolidate the code to generate a new XID for a NFS request into a
nfs_xid_gen() function instead of duplicating the logic in both nfsm_rpchead() and the NFS3ERR_JUKEBOX handling in nfs_request(). MFC after: 1 week Submitted by: mohans (a long while ago)
This commit is contained in:
parent
b0c2bc946d
commit
3156ea2d33
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176224
@ -77,9 +77,6 @@ __FBSDID("$FreeBSD$");
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
extern u_int32_t nfs_xid;
|
||||
extern struct mtx nfs_xid_mtx;
|
||||
|
||||
static int nfs_realign_test;
|
||||
static int nfs_realign_count;
|
||||
static int nfs_bufpackets = 4;
|
||||
@ -1351,11 +1348,7 @@ nfs_request(struct vnode *vp, struct mbuf *mrest, int procnum,
|
||||
while (time_second < waituntil) {
|
||||
(void) tsleep(&lbolt, PSOCK, "nqnfstry", 0);
|
||||
}
|
||||
mtx_lock(&nfs_xid_mtx);
|
||||
if (++nfs_xid == 0)
|
||||
nfs_xid++;
|
||||
rep->r_xid = *xidp = txdr_unsigned(nfs_xid);
|
||||
mtx_unlock(&nfs_xid_mtx);
|
||||
rep->r_xid = *xidp = txdr_unsigned(nfs_xid_gen());
|
||||
goto tryagain;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ u_int32_t rpc_call, rpc_vers, rpc_reply, rpc_msgdenied, rpc_autherr,
|
||||
u_int32_t nfs_true, nfs_false;
|
||||
|
||||
/* And other global data */
|
||||
u_int32_t nfs_xid = 0;
|
||||
static u_int32_t nfs_xid = 0;
|
||||
static enum vtype nv2tov_type[8]= {
|
||||
VNON, VREG, VDIR, VBLK, VCHR, VLNK, VNON, VNON
|
||||
};
|
||||
@ -102,7 +102,7 @@ int nfs_pbuf_freecnt = -1; /* start out unlimited */
|
||||
struct nfs_reqq nfs_reqq;
|
||||
struct mtx nfs_reqq_mtx;
|
||||
struct nfs_bufq nfs_bufq;
|
||||
struct mtx nfs_xid_mtx;
|
||||
static struct mtx nfs_xid_mtx;
|
||||
|
||||
/*
|
||||
* and the reverse mapping from generic to Version 2 procedure numbers
|
||||
@ -135,6 +135,26 @@ int nfsv2_procid[NFS_NPROCS] = {
|
||||
|
||||
LIST_HEAD(nfsnodehashhead, nfsnode);
|
||||
|
||||
u_int32_t
|
||||
nfs_xid_gen(void)
|
||||
{
|
||||
uint32_t xid;
|
||||
|
||||
mtx_lock(&nfs_xid_mtx);
|
||||
|
||||
/* Get a pretty random xid to start with */
|
||||
if (!nfs_xid)
|
||||
nfs_xid = random();
|
||||
/*
|
||||
* Skip zero xid if it should ever happen.
|
||||
*/
|
||||
if (++nfs_xid == 0)
|
||||
nfs_xid++;
|
||||
xid = nfs_xid;
|
||||
mtx_unlock(&nfs_xid_mtx);
|
||||
return xid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the header for an rpc request packet
|
||||
* The hsiz is the size of the rest of the nfs request header.
|
||||
@ -188,19 +208,8 @@ nfsm_rpchead(struct ucred *cr, int nmflag, int procid, int auth_type,
|
||||
*/
|
||||
tl = nfsm_build(u_int32_t *, 8 * NFSX_UNSIGNED);
|
||||
|
||||
mtx_lock(&nfs_xid_mtx);
|
||||
/* Get a pretty random xid to start with */
|
||||
if (!nfs_xid)
|
||||
nfs_xid = random();
|
||||
/*
|
||||
* Skip zero xid if it should ever happen.
|
||||
*/
|
||||
if (++nfs_xid == 0)
|
||||
nfs_xid++;
|
||||
|
||||
*xidpp = tl;
|
||||
*tl++ = txdr_unsigned(nfs_xid);
|
||||
mtx_unlock(&nfs_xid_mtx);
|
||||
*tl++ = txdr_unsigned(nfs_xid_gen());
|
||||
*tl++ = rpc_call;
|
||||
*tl++ = rpc_vers;
|
||||
*tl++ = txdr_unsigned(NFS_PROG);
|
||||
|
@ -52,6 +52,7 @@ struct vnode;
|
||||
/*
|
||||
* First define what the actual subs. return
|
||||
*/
|
||||
u_int32_t nfs_xid_gen(void);
|
||||
struct mbuf *nfsm_reqhead(struct vnode *vp, u_long procid, int hsiz);
|
||||
struct mbuf *nfsm_rpchead(struct ucred *cr, int nmflag, int procid,
|
||||
int auth_type, int auth_len,
|
||||
|
Loading…
Reference in New Issue
Block a user