From 562ebdfbed6da83efa5110cabff6bbb6c685cfea Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 28 Sep 2001 04:37:08 +0000 Subject: Unwind some more macros. NFSMADV() was kinda silly since it was right next to equivalent m_len adjustments. Move the nfsm_subs.h macros into groups depending on which phase they are used in, since that affects the error recovery requirements. Collect some of the common error checking into a single macro as preparation for unwinding some more. Have nfs_rephead return a value instead of secretly modifying args. Remove some unused function arguments that were being passed around. Clarify nfsm_reply()'s error handling (I hope). --- sys/nfsclient/nfsm_subs.h | 140 +++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 77 deletions(-) (limited to 'sys/nfsclient/nfsm_subs.h') diff --git a/sys/nfsclient/nfsm_subs.h b/sys/nfsclient/nfsm_subs.h index 47ca520..2795482 100644 --- a/sys/nfsclient/nfsm_subs.h +++ b/sys/nfsclient/nfsm_subs.h @@ -88,27 +88,19 @@ struct mbuf *nfsm_rpchead(struct ucred *cr, int nmflag, int procid, * unions. */ + +/* *********************************** */ +/* Request generation phase macros */ + int nfsm_fhtom_xx(struct vnode *v, int v3, u_int32_t **tl, struct mbuf **mb, caddr_t *bpos); -int nfsm_mtofh_xx(struct vnode *d, struct vnode **v, int v3, int *f, - u_int32_t **tl, struct mbuf **md, caddr_t *dpos); -int nfsm_getfh_xx(nfsfh_t **f, int *s, int v3, u_int32_t **tl, - struct mbuf **md, caddr_t *dpos); void nfsm_v3attrbuild_xx(struct vattr *va, int full, u_int32_t **tl, struct mbuf **mb, caddr_t *bpos); -int nfsm_loadattr_xx(struct vnode **v, struct vattr *va, u_int32_t **tl, - struct mbuf **md, caddr_t *dpos); -int nfsm_postop_attr_xx(struct vnode **v, int *f, u_int32_t **tl, - struct mbuf **md, caddr_t *dpos); -int nfsm_wcc_data_xx(struct vnode **v, int *f, u_int32_t **tl, - struct mbuf **md, caddr_t *dpos); int nfsm_strtom_xx(const char *a, int s, int m, u_int32_t **tl, struct mbuf **mb, caddr_t *bpos); -#define nfsm_fhtom(v, v3) \ +#define nfsm_bcheck(t1, mreq) \ do { \ - int32_t t1; \ - t1 = nfsm_fhtom_xx((v), (v3), &tl, &mb, &bpos); \ if (t1) { \ error = t1; \ m_freem(mreq); \ @@ -116,48 +108,85 @@ do { \ } \ } while (0) +#define nfsm_fhtom(v, v3) \ +do { \ + int32_t t1; \ + t1 = nfsm_fhtom_xx((v), (v3), &tl, &mb, &bpos); \ + nfsm_bcheck(t1, mreq); \ +} while (0) + +/* If full is true, set all fields, otherwise just set mode and time fields */ +#define nfsm_v3attrbuild(a, full) \ + nfsm_v3attrbuild_xx(a, full, &tl, &mb, &bpos) + +#define nfsm_uiotom(p, s) \ +do { \ + int t1; \ + t1 = nfsm_uiotombuf((p), &mb, (s), &bpos); \ + nfsm_bcheck(t1, mreq); \ +} while (0) + +#define nfsm_strtom(a, s, m) \ +do { \ + int t1; \ + t1 = nfsm_strtom_xx((a), (s), (m), &tl, &mb, &bpos); \ + nfsm_bcheck(t1, mreq); \ +} while (0) + +/* *********************************** */ +/* Send the request */ + +#define nfsm_request(v, t, p, c) \ +do { \ + error = nfs_request((v), mreq, (t), (p), (c), &mrep, &md, &dpos); \ + if (error != 0) { \ + if (error & NFSERR_RETERR) \ + error &= ~NFSERR_RETERR; \ + else \ + goto nfsmout; \ + } \ +} while (0) + +/* *********************************** */ +/* Reply interpretation phase macros */ + +int nfsm_mtofh_xx(struct vnode *d, struct vnode **v, int v3, int *f, + u_int32_t **tl, struct mbuf **md, caddr_t *dpos); +int nfsm_getfh_xx(nfsfh_t **f, int *s, int v3, u_int32_t **tl, + struct mbuf **md, caddr_t *dpos); +int nfsm_loadattr_xx(struct vnode **v, struct vattr *va, u_int32_t **tl, + struct mbuf **md, caddr_t *dpos); +int nfsm_postop_attr_xx(struct vnode **v, int *f, u_int32_t **tl, + struct mbuf **md, caddr_t *dpos); +int nfsm_wcc_data_xx(struct vnode **v, int *f, u_int32_t **tl, + struct mbuf **md, caddr_t *dpos); + #define nfsm_mtofh(d, v, v3, f) \ do { \ int32_t t1; \ t1 = nfsm_mtofh_xx((d), &(v), (v3), &(f), &tl, &md, &dpos); \ - if (t1) { \ - error = t1; \ - m_freem(mrep); \ - goto nfsmout; \ - } \ + nfsm_dcheck(t1, mrep); \ } while (0) #define nfsm_getfh(f, s, v3) \ do { \ int32_t t1; \ t1 = nfsm_getfh_xx(&(f), &(s), (v3), &tl, &md, &dpos); \ - if (t1) { \ - error = t1; \ - m_freem(mrep); \ - goto nfsmout; \ - } \ + nfsm_dcheck(t1, mrep); \ } while (0) #define nfsm_loadattr(v, a) \ do { \ int32_t t1; \ t1 = nfsm_loadattr_xx(&v, a, &tl, &md, &dpos); \ - if (t1 != 0) { \ - error = t1; \ - m_freem(mrep); \ - goto nfsmout; \ - } \ + nfsm_dcheck(t1, mrep); \ } while (0) #define nfsm_postop_attr(v, f) \ do { \ int32_t t1; \ t1 = nfsm_postop_attr_xx(&v, &f, &tl, &md, &dpos); \ - if (t1 != 0) { \ - error = t1; \ - m_freem(mrep); \ - goto nfsmout; \ - } \ + nfsm_dcheck(t1, mrep); \ } while (0) /* Used as (f) for nfsm_wcc_data() */ @@ -168,50 +197,7 @@ do { \ do { \ int32_t t1; \ t1 = nfsm_wcc_data_xx(&v, &f, &tl, &md, &dpos); \ - if (t1 != 0) { \ - error = t1; \ - m_freem(mrep); \ - goto nfsmout; \ - } \ -} while (0) - -/* If full is true, set all fields, otherwise just set mode and time fields */ -#define nfsm_v3attrbuild(a, full) \ -do { \ - nfsm_v3attrbuild_xx(a, full, &tl, &mb, &bpos); \ -} while(0) - -#define nfsm_uiotom(p, s) \ -do { \ - int t1; \ - t1 = nfsm_uiotombuf((p), &mb, (s), &bpos); \ - if (t1 != 0) { \ - error = t1; \ - m_freem(mreq); \ - goto nfsmout; \ - } \ -} while (0) - -#define nfsm_request(v, t, p, c) \ -do { \ - error = nfs_request((v), mreq, (t), (p), (c), &mrep, &md, &dpos); \ - if (error != 0) { \ - if (error & NFSERR_RETERR) \ - error &= ~NFSERR_RETERR; \ - else \ - goto nfsmout; \ - } \ -} while (0) - -#define nfsm_strtom(a, s, m) \ -do { \ - int t1; \ - t1 = nfsm_strtom_xx((a), (s), (m), &tl, &mb, &bpos); \ - if (t1 != 0) { \ - error = t1; \ - m_freem(mreq); \ - goto nfsmout; \ - } \ + nfsm_dcheck(t1, mrep); \ } while (0) #endif -- cgit v1.1