Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/nfs cut down another 7K by more NFS_V2_ONLY ifdefs.



details:   https://anonhg.NetBSD.org/src/rev/f86784e4d2d4
branches:  trunk
changeset: 566885:f86784e4d2d4
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 23 05:53:01 2004 +0000

description:
cut down another 7K by more NFS_V2_ONLY ifdefs.

diffstat:

 sys/nfs/nfs_bio.c   |   22 +++++-
 sys/nfs/nfs_vnops.c |  187 +++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 175 insertions(+), 34 deletions(-)

diffs (truncated from 792 to 300 lines):

diff -r cd0a4c7eb0e5 -r f86784e4d2d4 sys/nfs/nfs_bio.c
--- a/sys/nfs/nfs_bio.c Sun May 23 05:09:52 2004 +0000
+++ b/sys/nfs/nfs_bio.c Sun May 23 05:53:01 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_bio.c,v 1.116 2004/03/12 16:52:14 yamt Exp $       */
+/*     $NetBSD: nfs_bio.c,v 1.117 2004/05/23 05:53:01 christos Exp $   */
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.116 2004/03/12 16:52:14 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.117 2004/05/23 05:53:01 christos Exp $");
 
 #include "opt_nfs.h"
 #include "opt_ddb.h"
@@ -930,11 +930,15 @@
        case VDIR:
                nfsstats.readdir_bios++;
                uiop->uio_offset = bp->b_dcookie;
+#ifndef NFS_V2_ONLY
                if (nmp->nm_flag & NFSMNT_RDIRPLUS) {
                        error = nfs_readdirplusrpc(vp, uiop, curproc->p_ucred);
                        if (error == NFSERR_NOTSUPP)
                                nmp->nm_flag &= ~NFSMNT_RDIRPLUS;
                }
+#else
+               nmp->nm_flag &= ~NFSMNT_RDIRPLUS;
+#endif
                if ((nmp->nm_flag & NFSMNT_RDIRPLUS) == 0)
                        error = nfs_readdirrpc(vp, uiop, curproc->p_ucred);
                if (!error) {
@@ -967,7 +971,11 @@
        boolean_t stalewriteverf = FALSE;
        int i, npages = (bp->b_bcount + PAGE_SIZE - 1) >> PAGE_SHIFT;
        struct vm_page *pgs[npages];
+#ifndef NFS_V2_ONLY
        boolean_t needcommit = TRUE; /* need only COMMIT RPC */
+#else
+       boolean_t needcommit = FALSE; /* need only COMMIT RPC */
+#endif
        boolean_t pageprotected;
        struct uvm_object *uobj = &vp->v_uobj;
        int error;
@@ -979,7 +987,9 @@
                iomode = NFSV3WRITE_FILESYNC;
        }
 
+#ifndef NFS_V2_ONLY
 again:
+#endif
        lockmgr(&nmp->nm_writeverflock, LK_SHARED, NULL);
 
        for (i = 0; i < npages; i++) {
@@ -1028,7 +1038,7 @@
         * Send the data to the server if necessary,
         * otherwise just send a commit rpc.
         */
-
+#ifndef NFS_V2_ONLY
        if (needcommit) {
 
                /*
@@ -1088,11 +1098,13 @@
                }
                return error;
        }
+#endif
        off = uiop->uio_offset;
        cnt = bp->b_bcount;
        uiop->uio_rw = UIO_WRITE;
        nfsstats.write_bios++;
        error = nfs_writerpc(vp, uiop, &iomode, pageprotected, &stalewriteverf);
+#ifndef NFS_V2_ONLY
        if (!error && iomode == NFSV3WRITE_UNSTABLE) {
                /*
                 * we need to commit pages later.
@@ -1126,7 +1138,9 @@
                        simple_unlock(&uobj->vmobjlock);
                }
                lockmgr(&np->n_commitlock, LK_RELEASE, NULL);
-       } else if (!error) {
+       } else
+#endif
+       if (!error) {
                /*
                 * pages are now on stable storage.
                 */
diff -r cd0a4c7eb0e5 -r f86784e4d2d4 sys/nfs/nfs_vnops.c
--- a/sys/nfs/nfs_vnops.c       Sun May 23 05:09:52 2004 +0000
+++ b/sys/nfs/nfs_vnops.c       Sun May 23 05:53:01 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_vnops.c,v 1.199 2004/05/17 12:17:18 yamt Exp $     */
+/*     $NetBSD: nfs_vnops.c,v 1.200 2004/05/23 05:53:01 christos Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.199 2004/05/17 12:17:18 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.200 2004/05/23 05:53:01 christos Exp $");
 
 #include "opt_nfs.h"
 #include "opt_uvmhist.h"
@@ -325,14 +325,17 @@
                struct proc *a_p;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
+#ifndef NFS_V2_ONLY
        u_int32_t *tl;
        caddr_t cp;
        int32_t t1, t2;
        caddr_t bpos, dpos, cp2;
-       int error = 0, attrflag, cachevalid;
+       int error = 0, attrflag;
        struct mbuf *mreq, *mrep, *md, *mb;
        u_int32_t mode, rmode;
        const int v3 = NFS_ISV3(vp);
+#endif
+       int cachevalid;
        struct nfsnode *np = VTONFS(vp);
 
        cachevalid = (np->n_accstamp != -1 &&
@@ -351,6 +354,7 @@
                        return np->n_accerror;
        }
 
+#ifndef NFS_V2_ONLY
        /*
         * For nfs v3, do an access rpc, otherwise you are stuck emulating
         * ufs_access() locally using the vattr. This may not be correct,
@@ -396,7 +400,9 @@
                }
                nfsm_reqdone;
        } else
+#endif
                return (nfsspec_access(ap));
+#ifndef NFS_V2_ONLY
        /*
         * Disallow write attempts on filesystems mounted read-only;
         * unless the file is a socket, fifo, or a block or character
@@ -435,6 +441,7 @@
        }
 
        return (error);
+#endif
 }
 
 /*
@@ -585,10 +592,12 @@
        if (vp->v_type == VREG) {
            if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NQNFS) == 0 &&
                (np->n_flag & NMODIFIED)) {
+#ifndef NFS_V2_ONLY
                if (NFS_ISV3(vp)) {
                    error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_p, 0);
                    np->n_flag &= ~NMODIFIED;
                } else
+#endif
                    error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1);
                NFS_INVALIDATE_ATTRCACHE(np);
            }
@@ -754,21 +763,27 @@
        struct nfsv2_sattr *sp;
        caddr_t cp;
        int32_t t1, t2;
-       caddr_t bpos, dpos, cp2;
+       caddr_t bpos, dpos;
        u_int32_t *tl;
-       int error = 0, wccflag = NFSV3_WCCRATTR;
+       int error = 0;
        struct mbuf *mreq, *mrep, *md, *mb;
        const int v3 = NFS_ISV3(vp);
        struct nfsnode *np = VTONFS(vp);
+#ifndef NFS_V2_ONLY
+       int wccflag = NFSV3_WCCRATTR;
+       caddr_t cp2;
+#endif
 
        nfsstats.rpccnt[NFSPROC_SETATTR]++;
        nfsm_reqhead(np, NFSPROC_SETATTR, NFSX_FH(v3) + NFSX_SATTR(v3));
        nfsm_fhtom(np, v3);
+#ifndef NFS_V2_ONLY
        if (v3) {
                nfsm_v3attrbuild(vap, TRUE);
                nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
                *tl = nfs_false;
        } else {
+#endif
                nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
                if (vap->va_mode == (mode_t)VNOVAL)
                        sp->sa_mode = nfs_xdrneg1;
@@ -785,11 +800,15 @@
                sp->sa_size = txdr_unsigned(vap->va_size);
                txdr_nfsv2time(&vap->va_atime, &sp->sa_atime);
                txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime);
+#ifndef NFS_V2_ONLY
        }
+#endif
        nfsm_request(np, NFSPROC_SETATTR, procp, cred);
+#ifndef NFS_V2_ONLY
        if (v3) {
                nfsm_wcc_data(vp, wccflag, 0);
        } else
+#endif
                nfsm_loadattr(vp, (struct vattr *)0, 0);
        nfsm_reqdone;
        return (error);
@@ -982,10 +1001,12 @@
                        return error;
                }
                newvp = NFSTOV(np);
+#ifndef NFS_V2_ONLY
                if (v3) {
                        nfsm_postop_attr(newvp, attrflag, 0);
                        nfsm_postop_attr(dvp, attrflag, 0);
                } else
+#endif
                        nfsm_loadattr(newvp, (struct vattr *)0, 0);
                *vpp = newvp;
                m_freem(mrep);
@@ -1009,10 +1030,12 @@
                 */
                VREF(dvp);
                newvp = dvp;
+#ifndef NFS_V2_ONLY
                if (v3) {
                        nfsm_postop_attr(newvp, attrflag, 0);
                        nfsm_postop_attr(dvp, attrflag, 0);
                } else
+#endif
                        nfsm_loadattr(newvp, (struct vattr *)0, 0);
        } else if (flags & ISDOTDOT) {
                /*
@@ -1030,10 +1053,12 @@
                }
                newvp = NFSTOV(np);
 
+#ifndef NFS_V2_ONLY
                if (v3) {
                        nfsm_postop_attr(newvp, attrflag, 0);
                        nfsm_postop_attr(dvp, attrflag, 0);
                } else
+#endif
                        nfsm_loadattr(newvp, (struct vattr *)0, 0);
 
                if (lockparent && (flags & ISLASTCN)) {
@@ -1054,10 +1079,12 @@
                        return error;
                }
                newvp = NFSTOV(np);
+#ifndef NFS_V2_ONLY
                if (v3) {
                        nfsm_postop_attr(newvp, attrflag, 0);
                        nfsm_postop_attr(dvp, attrflag, 0);
                } else
+#endif
                        nfsm_loadattr(newvp, (struct vattr *)0, 0);
                if (!lockparent || !(flags & ISLASTCN)) {
                        VOP_UNLOCK(dvp, 0);
@@ -1175,19 +1202,25 @@
        caddr_t cp;
        int32_t t1, t2;
        caddr_t bpos, dpos, cp2;
-       int error = 0, attrflag;
+       int error = 0;
        uint32_t len;
        struct mbuf *mreq, *mrep, *md, *mb;
        const int v3 = NFS_ISV3(vp);
        struct nfsnode *np = VTONFS(vp);
+#ifndef NFS_V2_ONLY
+       int attrflag;
+#endif
 
        nfsstats.rpccnt[NFSPROC_READLINK]++;
        nfsm_reqhead(np, NFSPROC_READLINK, NFSX_FH(v3));
        nfsm_fhtom(np, v3);
        nfsm_request(np, NFSPROC_READLINK, uiop->uio_procp, cred);
+#ifndef NFS_V2_ONLY
        if (v3)
                nfsm_postop_attr(vp, attrflag, 0);
+#endif
        if (!error) {
+#ifndef NFS_V2_ONLY
                if (v3) {
                        nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED);
                        len = fxdr_unsigned(uint32_t, *tl);
@@ -1200,7 +1233,9 @@
                                error = ENAMETOOLONG;
                                goto nfsmout;
                        }
-               } else {
+               } else
+#endif
+               {
                        nfsm_strsiz(len, NFS_MAXPATHLEN);



Home | Main Index | Thread Index | Old Index