summaryrefslogtreecommitdiffstats
path: root/sys/nfs
diff options
context:
space:
mode:
authorps <ps@FreeBSD.org>2004-12-06 17:33:52 +0000
committerps <ps@FreeBSD.org>2004-12-06 17:33:52 +0000
commit5feadd3eba463ffad1e8b8e55a5ff30c5ccc861a (patch)
tree534a6e09b19a42319606629ce43460d95a24d8ef /sys/nfs
parente196d800834b17b34ab2b098462739d2da4b3a24 (diff)
downloadFreeBSD-src-5feadd3eba463ffad1e8b8e55a5ff30c5ccc861a.zip
FreeBSD-src-5feadd3eba463ffad1e8b8e55a5ff30c5ccc861a.tar.gz
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
Diffstat (limited to 'sys/nfs')
-rw-r--r--sys/nfs/nfs_common.c22
-rw-r--r--sys/nfs/nfs_common.h11
2 files changed, 29 insertions, 4 deletions
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c
index 019918d..6c66a39 100644
--- a/sys/nfs/nfs_common.c
+++ b/sys/nfs/nfs_common.c
@@ -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;
@@ -267,6 +271,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;
void *ret;
@@ -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;
}
diff --git a/sys/nfs/nfs_common.h b/sys/nfs/nfs_common.h
index f68dad1..877b351 100644
--- a/sys/nfs/nfs_common.h
+++ b/sys/nfs/nfs_common.h
@@ -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; \
OpenPOWER on IntegriCloud