Add non-blocking versions of nfsm_dissect() and friends, for use from
socket callbacks or similar callers, from both the NFS client and the server. Instituted nfsm_dissect_nonblock(), nfsm_dissect_xx_nonblock(). And nfsm_disct() now takes an extra M_TRYWAIT/M_DONTWAIT argument. Submitted by: Mohan Srinivasan mohans at yahoo-inc dot com
This commit is contained in:
parent
fdbbb5d25b
commit
9d4314b58b
@ -76,6 +76,8 @@ nfstype nfsv3_type[9] = {
|
||||
NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFSOCK, NFFIFO, NFNON
|
||||
};
|
||||
|
||||
static void *nfsm_dissect_xx_sub(int s, struct mbuf **md, caddr_t *dpos, int how);
|
||||
|
||||
u_quad_t
|
||||
nfs_curusec(void)
|
||||
{
|
||||
@ -164,7 +166,7 @@ nfsm_mbuftouio(struct mbuf **mrep, struct uio *uiop, int siz, caddr_t *dpos)
|
||||
* cases. (The macros use the vars. dpos and dpos2)
|
||||
*/
|
||||
void *
|
||||
nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left)
|
||||
nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, int how)
|
||||
{
|
||||
struct mbuf *mp, *mp2;
|
||||
int siz2, xfer;
|
||||
@ -187,7 +189,9 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left)
|
||||
} else if (siz > MHLEN) {
|
||||
panic("nfs S too big");
|
||||
} else {
|
||||
MGET(mp2, M_TRYWAIT, MT_DATA);
|
||||
MGET(mp2, how, MT_DATA);
|
||||
if (mp2 == NULL)
|
||||
return NULL;
|
||||
mp2->m_next = mp->m_next;
|
||||
mp->m_next = mp2;
|
||||
mp->m_len -= left;
|
||||
@ -266,6 +270,18 @@ nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos)
|
||||
|
||||
void *
|
||||
nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos)
|
||||
{
|
||||
return nfsm_dissect_xx_sub(s, md, dpos, M_TRYWAIT);
|
||||
}
|
||||
|
||||
void *
|
||||
nfsm_dissect_xx_nonblock(int s, struct mbuf **md, caddr_t *dpos)
|
||||
{
|
||||
return nfsm_dissect_xx_sub(s, md, dpos, M_DONTWAIT);
|
||||
}
|
||||
|
||||
static void *
|
||||
nfsm_dissect_xx_sub(int s, struct mbuf **md, caddr_t *dpos, int how)
|
||||
{
|
||||
int t1;
|
||||
char *cp2;
|
||||
@ -277,7 +293,7 @@ nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos)
|
||||
*dpos += s;
|
||||
return ret;
|
||||
}
|
||||
cp2 = nfsm_disct(md, dpos, s, t1);
|
||||
cp2 = nfsm_disct(md, dpos, s, t1, how);
|
||||
return cp2;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ extern nfstype nfsv3_type[];
|
||||
|
||||
int nfs_adv(struct mbuf **, caddr_t *, int, int);
|
||||
u_quad_t nfs_curusec(void);
|
||||
void *nfsm_disct(struct mbuf **, caddr_t *, int, int);
|
||||
void *nfsm_disct(struct mbuf **, caddr_t *, int, int, int);
|
||||
|
||||
/* ****************************** */
|
||||
/* Build request/reply phase macros */
|
||||
@ -62,6 +62,7 @@ void *nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos);
|
||||
/* Interpretation phase macros */
|
||||
|
||||
void *nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos);
|
||||
void *nfsm_dissect_xx_nonblock(int s, struct mbuf **md, caddr_t *dpos);
|
||||
int nfsm_strsiz_xx(int *s, int m, struct mbuf **md, caddr_t *dpos);
|
||||
int nfsm_adv_xx(int s, struct mbuf **md, caddr_t *dpos);
|
||||
|
||||
@ -94,6 +95,14 @@ do { \
|
||||
(c)ret; \
|
||||
})
|
||||
|
||||
#define nfsm_dissect_nonblock(c, s) \
|
||||
({ \
|
||||
void *ret; \
|
||||
ret = nfsm_dissect_xx_nonblock((s), &md, &dpos); \
|
||||
nfsm_dcheckp(ret, mrep); \
|
||||
(c)ret; \
|
||||
})
|
||||
|
||||
#define nfsm_strsiz(s,m) \
|
||||
do { \
|
||||
int t1; \
|
||||
|
@ -478,7 +478,7 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp,
|
||||
|
||||
md = *mdp;
|
||||
t1 = (mtod(md, caddr_t) + md->m_len) - *dposp;
|
||||
cp2 = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1);
|
||||
cp2 = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1, M_TRYWAIT);
|
||||
if (cp2 == NULL)
|
||||
return EBADRPC;
|
||||
fp = (struct nfs_fattr *)cp2;
|
||||
|
Loading…
Reference in New Issue
Block a user