timeval => timespec in vattr and dinode
[unix-history] / usr / src / sys / nfs / nfs_bio.c
index 1d29f8a..94d506d 100644 (file)
@@ -5,32 +5,27 @@
  * This code is derived from software contributed to Berkeley by
  * Rick Macklem at The University of Guelph.
  *
  * This code is derived from software contributed to Berkeley by
  * Rick Macklem at The University of Guelph.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)nfs_bio.c   7.13 (Berkeley) %G%
+ *     @(#)nfs_bio.c   7.27 (Berkeley) %G%
  */
 
  */
 
-#include "param.h"
-#include "user.h"
-#include "buf.h"
-#include "vnode.h"
-#include "trace.h"
-#include "mount.h"
-#include "nfsnode.h"
-#include "nfsv2.h"
-#include "nfs.h"
-#include "nfsiom.h"
-#include "nfsmount.h"
+#include <sys/param.h>
+#include <sys/resourcevar.h>
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <sys/vnode.h>
+#include <sys/trace.h>
+#include <sys/mount.h>
+#include <sys/kernel.h>
+#include <machine/endian.h>
+#include <vm/vm.h>
+#include <nfs/nfsnode.h>
+#include <nfs/rpcv2.h>
+#include <nfs/nfsv2.h>
+#include <nfs/nfs.h>
+#include <nfs/nfsmount.h>
+#include <nfs/nqnfs.h>
 
 /* True and false, how exciting */
 #define        TRUE    1
 
 /* True and false, how exciting */
 #define        TRUE    1
  */
 nfs_bioread(vp, uio, ioflag, cred)
        register struct vnode *vp;
  */
 nfs_bioread(vp, uio, ioflag, cred)
        register struct vnode *vp;
-       struct uio *uio;
+       register struct uio *uio;
        int ioflag;
        struct ucred *cred;
 {
        int ioflag;
        struct ucred *cred;
 {
+       USES_VOP_GETATTR;
        register struct nfsnode *np = VTONFS(vp);
        register struct nfsnode *np = VTONFS(vp);
-       struct nfsmount *nmp;
+       register int biosize;
        struct buf *bp;
        struct vattr vattr;
        struct buf *bp;
        struct vattr vattr;
-       daddr_t lbn, bn, rablock;
-       int diff, error = 0;
-       long n, on;
+       struct nfsmount *nmp;
+       daddr_t lbn, bn, rablock[NFS_MAXRAHEAD];
+       int rasize[NFS_MAXRAHEAD], nra, diff, error = 0;
+       int n, on;
 
 
+#ifdef lint
+       ioflag = ioflag;
+#endif /* lint */
+#ifdef DIAGNOSTIC
        if (uio->uio_rw != UIO_READ)
                panic("nfs_read mode");
        if (uio->uio_rw != UIO_READ)
                panic("nfs_read mode");
+#endif
        if (uio->uio_resid == 0)
                return (0);
        if (uio->uio_offset < 0 && vp->v_type != VDIR)
                return (EINVAL);
        if (uio->uio_resid == 0)
                return (0);
        if (uio->uio_offset < 0 && vp->v_type != VDIR)
                return (EINVAL);
+       nmp = VFSTONFS(vp->v_mount);
+       biosize = nmp->nm_rsize;
        /*
        /*
+        * For nfs, cache consistency can only be maintained approximately.
+        * Although RFC1094 does not specify the criteria, the following is
+        * believed to be compatible with the reference port.
+        * For nqnfs, full cache consistency is maintained within the loop.
+        * For nfs:
         * If the file's modify time on the server has changed since the
         * last read rpc or you have written to the file,
         * you may have lost data cache consistency with the
         * server, so flush all of the file's data out of the cache.
         * Then force a getattr rpc to ensure that you have up to date
         * attributes.
         * If the file's modify time on the server has changed since the
         * last read rpc or you have written to the file,
         * you may have lost data cache consistency with the
         * server, so flush all of the file's data out of the cache.
         * Then force a getattr rpc to ensure that you have up to date
         * attributes.
+        * The mount flag NFSMNT_MYWRITE says "Assume that my writes are
+        * the ones changing the modify time.
         * NB: This implies that cache data can be read when up to
         * NFS_ATTRTIMEO seconds out of date. If you find that you need current
         * attributes this could be forced by setting n_attrstamp to 0 before
         * NB: This implies that cache data can be read when up to
         * NFS_ATTRTIMEO seconds out of date. If you find that you need current
         * attributes this could be forced by setting n_attrstamp to 0 before
-        * the nfs_getattr() call.
+        * the VOP_GETATTR() call.
         */
         */
-       if (vp->v_type != VLNK) {
+       if ((nmp->nm_flag & NFSMNT_NQNFS) == 0 && vp->v_type != VLNK) {
                if (np->n_flag & NMODIFIED) {
                        np->n_flag &= ~NMODIFIED;
                if (np->n_flag & NMODIFIED) {
                        np->n_flag &= ~NMODIFIED;
-                       vinvalbuf(vp, TRUE);
+                       if ((nmp->nm_flag & NFSMNT_MYWRITE) == 0 ||
+                            vp->v_type != VREG)
+                               vinvalbuf(vp, TRUE);
                        np->n_attrstamp = 0;
                        np->n_direofoffset = 0;
                        np->n_attrstamp = 0;
                        np->n_direofoffset = 0;
-                       if (error = nfs_getattr(vp, &vattr, cred))
+                       if (error = VOP_GETATTR(vp, &vattr, cred, uio->uio_procp))
                                return (error);
                                return (error);
-                       np->n_mtime = vattr.va_mtime.tv_sec;
+                       np->n_mtime = vattr.va_mtime.ts_sec;
                } else {
                } else {
-                       if (error = nfs_getattr(vp, &vattr, cred))
+                       if (error = VOP_GETATTR(vp, &vattr, cred, uio->uio_procp))
                                return (error);
                                return (error);
-                       if (np->n_mtime != vattr.va_mtime.tv_sec) {
+                       if (np->n_mtime != vattr.va_mtime.ts_sec) {
                                np->n_direofoffset = 0;
                                vinvalbuf(vp, TRUE);
                                np->n_direofoffset = 0;
                                vinvalbuf(vp, TRUE);
-                               np->n_mtime = vattr.va_mtime.tv_sec;
+                               np->n_mtime = vattr.va_mtime.ts_sec;
                        }
                }
        }
                        }
                }
        }
-       nmp = VFSTONFS(vp->v_mount);
        do {
        do {
+
+           /*
+            * Get a valid lease. If cached data is stale, flush it.
+            */
+           if ((nmp->nm_flag & NFSMNT_NQNFS) &&
+               NQNFS_CKINVALID(vp, np, NQL_READ)) {
+               do {
+                       error = nqnfs_getlease(vp, NQL_READ, cred, uio->uio_procp);
+               } while (error == NQNFS_EXPIRED);
+               if (error)
+                       return (error);
+               if (QUADNE(np->n_lrev, np->n_brev) ||
+                   ((np->n_flag & NMODIFIED) && vp->v_type == VDIR)) {
+                       if (vp->v_type == VDIR) {
+                               np->n_direofoffset = 0;
+                               cache_purge(vp);
+                       }
+                       np->n_flag &= ~NMODIFIED;
+                       vinvalbuf(vp, TRUE);
+                       np->n_brev = np->n_lrev;
+               }
+           }
+           if (np->n_flag & NQNFSNONCACHE) {
+               switch (vp->v_type) {
+               case VREG:
+                       error = nfs_readrpc(vp, uio, cred);
+                       break;
+               case VLNK:
+                       error = nfs_readlinkrpc(vp, uio, cred);
+                       break;
+               case VDIR:
+                       error = nfs_readdirrpc(vp, uio, cred);
+                       break;
+               };
+               return (error);
+           }
            switch (vp->v_type) {
            case VREG:
                nfsstats.biocache_reads++;
            switch (vp->v_type) {
            case VREG:
                nfsstats.biocache_reads++;
-               lbn = uio->uio_offset >> NFS_BIOSHIFT;
-               on = uio->uio_offset & (NFS_BIOSIZE-1);
-               n = MIN((unsigned)(NFS_BIOSIZE - on), uio->uio_resid);
+               lbn = uio->uio_offset / biosize;
+               on = uio->uio_offset & (biosize-1);
+               n = MIN((unsigned)(biosize - on), uio->uio_resid);
                diff = np->n_size - uio->uio_offset;
                if (diff <= 0)
                        return (error);
                if (diff < n)
                        n = diff;
                diff = np->n_size - uio->uio_offset;
                if (diff <= 0)
                        return (error);
                if (diff < n)
                        n = diff;
-               bn = lbn*(NFS_BIOSIZE/DEV_BSIZE);
-               rablock = (lbn+1)*(NFS_BIOSIZE/DEV_BSIZE);
-               if (vp->v_lastr + 1 == lbn &&
-                   np->n_size > (rablock * DEV_BSIZE))
-                       error = breada(vp, bn, NFS_BIOSIZE, rablock, NFS_BIOSIZE,
+               bn = lbn*(biosize/DEV_BSIZE);
+               for (nra = 0; nra < nmp->nm_readahead &&
+                       (lbn + 1 + nra) * biosize < np->n_size; nra++) {
+                       rablock[nra] = (lbn + 1 + nra) * (biosize / DEV_BSIZE);
+                       rasize[nra] = biosize;
+               }
+again:
+               if (nra > 0 && lbn >= vp->v_lastr)
+                       error = breadn(vp, bn, biosize, rablock, rasize, nra,
                                cred, &bp);
                else
                                cred, &bp);
                else
-                       error = bread(vp, bn, NFS_BIOSIZE, cred, &bp);
+                       error = bread(vp, bn, biosize, cred, &bp);
+               if (bp->b_validend > 0) {
+                       if (on < bp->b_validoff || (on+n) > bp->b_validend) {
+                               bp->b_flags |= B_INVAL;
+                               if (bp->b_dirtyend > 0) {
+                                       if ((bp->b_flags & B_DELWRI) == 0)
+                                               panic("nfsbioread");
+                                       (void) bwrite(bp);
+                               } else
+                                       brelse(bp);
+                               goto again;
+                       }
+               } else {
+                       bp->b_validoff = 0;
+                       bp->b_validend = biosize - bp->b_resid;
+               }
                vp->v_lastr = lbn;
                if (bp->b_resid) {
                vp->v_lastr = lbn;
                if (bp->b_resid) {
-                  diff = (on >= (NFS_BIOSIZE-bp->b_resid)) ? 0 :
-                       (NFS_BIOSIZE-bp->b_resid-on);
+                  diff = (on >= (biosize-bp->b_resid)) ? 0 :
+                       (biosize-bp->b_resid-on);
                   n = MIN(n, diff);
                }
                break;
                   n = MIN(n, diff);
                }
                break;
@@ -128,19 +195,60 @@ nfs_bioread(vp, uio, ioflag, cred)
            case VDIR:
                nfsstats.biocache_readdirs++;
                on = 0;
            case VDIR:
                nfsstats.biocache_readdirs++;
                on = 0;
-               error = bread(vp, uio->uio_offset, DIRBLKSIZ, cred, &bp);
-               n = MIN(uio->uio_resid, DIRBLKSIZ - bp->b_resid);
+               error = bread(vp, uio->uio_offset, NFS_DIRBLKSIZ, cred, &bp);
+               n = MIN(uio->uio_resid, NFS_DIRBLKSIZ - bp->b_resid);
                break;
            };
            if (error) {
                brelse(bp);
                return (error);
            }
                break;
            };
            if (error) {
                brelse(bp);
                return (error);
            }
+
+           /*
+            * For nqnfs:
+            * Must check for valid lease, since it may have expired while in
+            * bread(). If expired, get a lease.
+            * If data is stale, flush and try again.
+            * nb: If a read rpc is done by bread() or breada() and there is
+            *     no valid lease, a get_lease request will be piggy backed.
+            */
+           if (nmp->nm_flag & NFSMNT_NQNFS) {
+               if (NQNFS_CKINVALID(vp, np, NQL_READ)) {
+                       do {
+                               error = nqnfs_getlease(vp, NQL_READ, cred, uio->uio_procp);
+                       } while (error == NQNFS_EXPIRED);
+                       if (error) {
+                               brelse(bp);
+                               return (error);
+                       }
+                       if ((np->n_flag & NQNFSNONCACHE) ||
+                           QUADNE(np->n_lrev, np->n_brev) ||
+                           ((np->n_flag & NMODIFIED) && vp->v_type == VDIR)) {
+                               if (vp->v_type == VDIR) {
+                                       np->n_direofoffset = 0;
+                                       cache_purge(vp);
+                               }
+                               brelse(bp);
+                               np->n_flag &= ~NMODIFIED;
+                               vinvalbuf(vp, TRUE);
+                               np->n_brev = np->n_lrev;
+                               continue;
+                       }
+               } else if ((np->n_flag & NQNFSNONCACHE) ||
+                   ((np->n_flag & NMODIFIED) && vp->v_type == VDIR)) {
+                       np->n_direofoffset = 0;
+                       brelse(bp);
+                       np->n_flag &= ~NMODIFIED;
+                       vinvalbuf(vp, TRUE);
+                       np->n_brev = np->n_lrev;
+                       continue;
+               }
+           }
            if (n > 0)
                error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
            switch (vp->v_type) {
            case VREG:
            if (n > 0)
                error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
            switch (vp->v_type) {
            case VREG:
-               if (n+on == NFS_BIOSIZE || uio->uio_offset == np->n_size)
+               if (n+on == biosize || uio->uio_offset == np->n_size)
                        bp->b_flags |= B_AGE;
                break;
            case VLNK:
                        bp->b_flags |= B_AGE;
                break;
            case VLNK:
@@ -158,90 +266,161 @@ nfs_bioread(vp, uio, ioflag, cred)
 /*
  * Vnode op for write using bio
  */
 /*
  * Vnode op for write using bio
  */
-nfs_write(vp, uio, ioflag, cred)
-       register struct vnode *vp;
-       register struct uio *uio;
-       int ioflag;
-       struct ucred *cred;
+nfs_write (ap)
+       struct vop_write_args *ap;
 {
 {
+       USES_VOP_GETATTR;
+       register int biosize;
+       struct proc *p = ap->a_uio->uio_procp;
        struct buf *bp;
        struct buf *bp;
-       struct nfsnode *np = VTONFS(vp);
+       struct nfsnode *np = VTONFS(ap->a_vp);
        struct vattr vattr;
        struct vattr vattr;
+       struct nfsmount *nmp;
        daddr_t lbn, bn;
        int n, on, error = 0;
 
        daddr_t lbn, bn;
        int n, on, error = 0;
 
-       if (uio->uio_rw != UIO_WRITE)
+#ifdef DIAGNOSTIC
+       if (ap->a_uio->uio_rw != UIO_WRITE)
                panic("nfs_write mode");
                panic("nfs_write mode");
-       if (vp->v_type != VREG)
+       if (ap->a_uio->uio_segflg == UIO_USERSPACE && ap->a_uio->uio_procp != curproc)
+               panic("nfs_write proc");
+#endif
+       if (ap->a_vp->v_type != VREG)
                return (EIO);
                return (EIO);
-       /* Should we try and do this ?? */
-       if (ioflag & IO_APPEND) {
+       if (np->n_flag & NWRITEERR) {
+               np->n_flag &= ~NWRITEERR;
+               return (np->n_error);
+       }
+       if (ap->a_ioflag & (IO_APPEND | IO_SYNC)) {
                if (np->n_flag & NMODIFIED) {
                        np->n_flag &= ~NMODIFIED;
                if (np->n_flag & NMODIFIED) {
                        np->n_flag &= ~NMODIFIED;
-                       vinvalbuf(vp, TRUE);
+                       vinvalbuf(ap->a_vp, TRUE);
+               }
+               if (ap->a_ioflag & IO_APPEND) {
+                       np->n_attrstamp = 0;
+                       if (error = VOP_GETATTR(ap->a_vp, &vattr, ap->a_cred, p))
+                               return (error);
+                       ap->a_uio->uio_offset = np->n_size;
                }
                }
-               np->n_attrstamp = 0;
-               if (error = nfs_getattr(vp, &vattr, cred))
-                       return (error);
-               uio->uio_offset = np->n_size;
-               return (nfs_writerpc(vp, uio, cred, u.u_procp));
        }
        }
-#ifdef notdef
-       cnt = uio->uio_resid;
-       osize = np->n_size;
-#endif
-       if (uio->uio_offset < 0)
+       nmp = VFSTONFS(ap->a_vp->v_mount);
+       if (ap->a_uio->uio_offset < 0)
                return (EINVAL);
                return (EINVAL);
-       if (uio->uio_resid == 0)
+       if (ap->a_uio->uio_resid == 0)
                return (0);
        /*
         * Maybe this should be above the vnode op call, but so long as
         * file servers have no limits, i don't think it matters
         */
                return (0);
        /*
         * Maybe this should be above the vnode op call, but so long as
         * file servers have no limits, i don't think it matters
         */
-       if (uio->uio_offset + uio->uio_resid >
-             u.u_rlimit[RLIMIT_FSIZE].rlim_cur) {
-               psignal(u.u_procp, SIGXFSZ);
+       if (p && ap->a_uio->uio_offset + ap->a_uio->uio_resid >
+             p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
+               psignal(p, SIGXFSZ);
                return (EFBIG);
        }
                return (EFBIG);
        }
+       /*
+        * I use nm_rsize, not nm_wsize so that all buffer cache blocks
+        * will be the same size within a filesystem. nfs_writerpc will
+        * still use nm_wsize when sizing the rpc's.
+        */
+       biosize = nmp->nm_rsize;
        np->n_flag |= NMODIFIED;
        do {
        np->n_flag |= NMODIFIED;
        do {
+
+               /*
+                * Check for a valid write lease.
+                * If non-cachable, just do the rpc
+                */
+               if ((nmp->nm_flag & NFSMNT_NQNFS) &&
+                   NQNFS_CKINVALID(ap->a_vp, np, NQL_WRITE)) {
+                       do {
+                               error = nqnfs_getlease(ap->a_vp, NQL_WRITE, ap->a_cred, p);
+                       } while (error == NQNFS_EXPIRED);
+                       if (error)
+                               return (error);
+                       if (QUADNE(np->n_lrev, np->n_brev) ||
+                           (np->n_flag & NQNFSNONCACHE)) {
+                               vinvalbuf(ap->a_vp, TRUE);
+                               np->n_brev = np->n_lrev;
+                       }
+               }
+               if (np->n_flag & NQNFSNONCACHE)
+                       return (nfs_writerpc(ap->a_vp, ap->a_uio, ap->a_cred));
                nfsstats.biocache_writes++;
                nfsstats.biocache_writes++;
-               lbn = uio->uio_offset >> NFS_BIOSHIFT;
-               on = uio->uio_offset & (NFS_BIOSIZE-1);
-               n = MIN((unsigned)(NFS_BIOSIZE - on), uio->uio_resid);
-               if (uio->uio_offset+n > np->n_size)
-                       np->n_size = uio->uio_offset+n;
-               bn = lbn*(NFS_BIOSIZE/DEV_BSIZE);
+               lbn = ap->a_uio->uio_offset / biosize;
+               on = ap->a_uio->uio_offset & (biosize-1);
+               n = MIN((unsigned)(biosize - on), ap->a_uio->uio_resid);
+               if (ap->a_uio->uio_offset + n > np->n_size) {
+                       np->n_size = ap->a_uio->uio_offset + n;
+                       vnode_pager_setsize(ap->a_vp, (u_long)np->n_size);
+               }
+               bn = lbn * (biosize / DEV_BSIZE);
 again:
 again:
-               bp = getblk(vp, bn, NFS_BIOSIZE);
+               bp = getblk(ap->a_vp, bn, biosize);
                if (bp->b_wcred == NOCRED) {
                if (bp->b_wcred == NOCRED) {
-                       crhold(cred);
-                       bp->b_wcred = cred;
+                       crhold(ap->a_cred);
+                       bp->b_wcred = ap->a_cred;
                }
                }
-               if (bp->b_dirtyend > 0) {
-                       /*
-                        * If the new write will leave a contiguous dirty
-                        * area, just update the b_dirtyoff and b_dirtyend,
-                        * otherwise force a write rpc of the old dirty area.
-                        */
-                       if (on <= bp->b_dirtyend && (on+n) >= bp->b_dirtyoff) {
-                               bp->b_dirtyoff = MIN(on, bp->b_dirtyoff);
-                               bp->b_dirtyend = MAX((on+n), bp->b_dirtyend);
-                       } else {
-                               bp->b_proc = u.u_procp;
-                               if (error = bwrite(bp))
-                                       return (error);
-                               goto again;
+
+               /*
+                * If the new write will leave a contiguous dirty
+                * area, just update the b_dirtyoff and b_dirtyend,
+                * otherwise force a write rpc of the old dirty area.
+                */
+               if (bp->b_dirtyend > 0 &&
+                   (on > bp->b_dirtyend || (on + n) < bp->b_dirtyoff)) {
+                       bp->b_proc = p;
+                       if (error = bwrite(bp))
+                               return (error);
+                       goto again;
+               }
+
+               /*
+                * Check for valid write lease and get one as required.
+                * In case getblk() and/or bwrite() delayed us.
+                */
+               if ((nmp->nm_flag & NFSMNT_NQNFS) &&
+                   NQNFS_CKINVALID(ap->a_vp, np, NQL_WRITE)) {
+                       do {
+                               error = nqnfs_getlease(ap->a_vp, NQL_WRITE, ap->a_cred, p);
+                       } while (error == NQNFS_EXPIRED);
+                       if (error) {
+                               brelse(bp);
+                               return (error);
+                       }
+                       if (QUADNE(np->n_lrev, np->n_brev) ||
+                           (np->n_flag & NQNFSNONCACHE)) {
+                               vinvalbuf(ap->a_vp, TRUE);
+                               np->n_brev = np->n_lrev;
                        }
                        }
+               }
+               if (error = uiomove(bp->b_un.b_addr + on, n, ap->a_uio)) {
+                       brelse(bp);
+                       return (error);
+               }
+               if (bp->b_dirtyend > 0) {
+                       bp->b_dirtyoff = MIN(on, bp->b_dirtyoff);
+                       bp->b_dirtyend = MAX((on+n), bp->b_dirtyend);
                } else {
                        bp->b_dirtyoff = on;
                        bp->b_dirtyend = on+n;
                }
                } else {
                        bp->b_dirtyoff = on;
                        bp->b_dirtyend = on+n;
                }
-               if (error = uiomove(bp->b_un.b_addr + on, n, uio)) {
-                       brelse(bp);
-                       return (error);
+               if (bp->b_validend == 0 || bp->b_validend < bp->b_dirtyoff ||
+                   bp->b_validoff > bp->b_dirtyend) {
+                       bp->b_validoff = bp->b_dirtyoff;
+                       bp->b_validend = bp->b_dirtyend;
+               } else {
+                       bp->b_validoff = MIN(bp->b_validoff, bp->b_dirtyoff);
+                       bp->b_validend = MAX(bp->b_validend, bp->b_dirtyend);
                }
                }
-               if ((n+on) == NFS_BIOSIZE) {
+
+               /*
+                * If the lease is non-cachable or IO_SYNC do bwrite().
+                */
+               if ((np->n_flag & NQNFSNONCACHE) || (ap->a_ioflag & IO_SYNC)) {
+                       bp->b_proc = p;
+                       bwrite(bp);
+               } else if ((n+on) == biosize &&
+                        (nmp->nm_flag & NFSMNT_NQNFS) == 0) {
                        bp->b_flags |= B_AGE;
                        bp->b_proc = (struct proc *)0;
                        bawrite(bp);
                        bp->b_flags |= B_AGE;
                        bp->b_proc = (struct proc *)0;
                        bawrite(bp);
@@ -249,14 +428,6 @@ again:
                        bp->b_proc = (struct proc *)0;
                        bdwrite(bp);
                }
                        bp->b_proc = (struct proc *)0;
                        bdwrite(bp);
                }
-       } while (error == 0 && uio->uio_resid > 0 && n != 0);
-#ifdef notdef
-       /* Should we try and do this for nfs ?? */
-       if (error && (ioflag & IO_UNIT)) {
-               np->n_size = osize;
-               uio->uio_offset -= cnt - uio->uio_resid;
-               uio->uio_resid = cnt;
-       }
-#endif
+       } while (error == 0 && ap->a_uio->uio_resid > 0 && n != 0);
        return (error);
 }
        return (error);
 }