Source-Changes-HG archive

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

[src/chs-ubc2]: src/sys/msdosfs UBCify.



details:   https://anonhg.NetBSD.org/src/rev/dcb6b63ebbe2
branches:  chs-ubc2
changeset: 471416:dcb6b63ebbe2
user:      chs <chs%NetBSD.org@localhost>
date:      Sun Aug 01 05:17:45 1999 +0000

description:
UBCify.

diffstat:

 sys/msdosfs/msdosfs_denode.c |    7 +-
 sys/msdosfs/msdosfs_fat.c    |   53 +++++++-------
 sys/msdosfs/msdosfs_vfsops.c |    7 +-
 sys/msdosfs/msdosfs_vnops.c  |  159 ++++++++++++++++++------------------------
 4 files changed, 107 insertions(+), 119 deletions(-)

diffs (truncated from 431 to 300 lines):

diff -r 1d98adafc63b -r dcb6b63ebbe2 sys/msdosfs/msdosfs_denode.c
--- a/sys/msdosfs/msdosfs_denode.c      Sat Jul 31 20:03:14 1999 +0000
+++ b/sys/msdosfs/msdosfs_denode.c      Sun Aug 01 05:17:45 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_denode.c,v 1.36 1999/03/24 05:51:27 mrg Exp $  */
+/*     $NetBSD: msdosfs_denode.c,v 1.36.4.1 1999/08/01 05:17:45 chs Exp $      */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -117,7 +117,7 @@
                        return (dep);
                }
        }
-       simple_lock(&msdosfs_ihash_slock);
+       simple_unlock(&msdosfs_ihash_slock);
        return (NULL);
 }
 
@@ -317,6 +317,7 @@
                nvp->v_type = VREG;
        VREF(ldep->de_devvp);
        *depp = ldep;
+       nvp->v_uvm.u_size = ldep->de_FileSize;
        return (0);
 }
 
@@ -422,7 +423,7 @@
 #endif
                        return (error);
                }
-               uvm_vnp_uncache(DETOV(dep));    /* what's this for? */
+
                /*
                 * is this the right place for it?
                 */
diff -r 1d98adafc63b -r dcb6b63ebbe2 sys/msdosfs/msdosfs_fat.c
--- a/sys/msdosfs/msdosfs_fat.c Sat Jul 31 20:03:14 1999 +0000
+++ b/sys/msdosfs/msdosfs_fat.c Sun Aug 01 05:17:45 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_fat.c,v 1.30 1998/08/09 20:52:20 perry Exp $   */
+/*     $NetBSD: msdosfs_fat.c,v 1.30.8.1 1999/08/01 05:17:45 chs Exp $ */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -979,6 +979,7 @@
  * the de_flag field of the denode and it does not change the de_FileSize
  * field.  This is left for the caller to do.
  */
+
 int
 extendfile(dep, count, bpp, ncp, flags)
        struct denode *dep;
@@ -988,8 +989,7 @@
        int flags;
 {
        int error;
-       u_long frcn;
-       u_long cn, got;
+       u_long frcn, cn, got, origcount;
        struct msdosfsmount *pmp = dep->de_pmp;
        struct buf *bp;
 
@@ -1016,16 +1016,19 @@
                        return (error);
        }
 
+       origcount = count;
        while (count > 0) {
+
                /*
                 * Allocate a new cluster chain and cat onto the end of the
-                * file.  * If the file is empty we make de_StartCluster point
+                * file.  If the file is empty we make de_StartCluster point
                 * to the new block.  Note that de_StartCluster being 0 is
                 * sufficient to be sure the file is empty since we exclude
                 * attempts to extend the root directory above, and the root
                 * dir is the only file with a startcluster of 0 that has
                 * blocks allocated (sort of).
                 */
+
                if (dep->de_StartCluster == 0)
                        cn = 0;
                else
@@ -1060,41 +1063,39 @@
                }
 
                /*
-                * Update the "last cluster of the file" entry in the denode's fat
-                * cache.
+                * Update the "last cluster of the file" entry in the
+                * denode's fat cache.
                 */
-               fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1);
 
-               if (flags & DE_CLEAR) {
+               fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1);
+               if ((flags & DE_CLEAR) &&
+                   (dep->de_Attributes & ATTR_DIRECTORY)) {
                        while (got-- > 0) {
+
                                /*
-                                * Get the buf header for the new block of the file.
+                                * Get the buf header for the
+                                * new block of the file.
                                 */
-                               if (dep->de_Attributes & ATTR_DIRECTORY)
-                                       bp = getblk(pmp->pm_devvp, cntobn(pmp, cn++),
-                                                   pmp->pm_bpcluster, 0, 0);
-                               else {
-                                       bp = getblk(DETOV(dep), de_cn2bn(pmp, frcn++),
+
+                               bp = getblk(pmp->pm_devvp, cntobn(pmp, cn++),
                                            pmp->pm_bpcluster, 0, 0);
-                                       /*
-                                        * Do the bmap now, as in msdosfs_write
-                                        */
-                                       if (pcbmap(dep,
-                                           de_bn2cn(pmp, bp->b_lblkno),
-                                           &bp->b_blkno, 0, 0))
-                                               bp->b_blkno = -1;
-                                       if (bp->b_blkno == -1)
-                                               panic("extendfile: pcbmap");
-                               }
                                clrbuf(bp);
                                if (bpp) {
                                        *bpp = bp;
-                                       bpp = NULL;
-                               } else
+                                               bpp = NULL;
+                               } else {
                                        bdwrite(bp);
+                               }                                       
                        }
                }
        }
 
+       if ((flags & DE_CLEAR) && !(dep->de_Attributes & ATTR_DIRECTORY)) {
+               int cnshift = pmp->pm_cnshift;
+
+               uvm_vnp_zerorange(DETOV(dep), frcn << cnshift,
+                                 origcount << cnshift);
+       }
+
        return (0);
 }
diff -r 1d98adafc63b -r dcb6b63ebbe2 sys/msdosfs/msdosfs_vfsops.c
--- a/sys/msdosfs/msdosfs_vfsops.c      Sat Jul 31 20:03:14 1999 +0000
+++ b/sys/msdosfs/msdosfs_vfsops.c      Sun Aug 01 05:17:45 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vfsops.c,v 1.61 1999/03/07 13:57:20 tron Exp $ */
+/*     $NetBSD: msdosfs_vfsops.c,v 1.61.4.1 1999/08/01 05:17:46 chs Exp $      */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -694,6 +694,11 @@
         mp->mnt_stat.f_fsid.val[0] = (long)dev;
         mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_MSDOS);
        mp->mnt_flag |= MNT_LOCAL;
+
+/* XXX pm_BytesPerSec is stored in the filesystem?? */
+       mp->mnt_dev_bshift = pmp->pm_bnshift;
+       mp->mnt_fs_bshift = pmp->pm_cnshift;
+
 #ifdef QUOTA
        /*
         * If we ever do quotas for DOS filesystems this would be a place
diff -r 1d98adafc63b -r dcb6b63ebbe2 sys/msdosfs/msdosfs_vnops.c
--- a/sys/msdosfs/msdosfs_vnops.c       Sat Jul 31 20:03:14 1999 +0000
+++ b/sys/msdosfs/msdosfs_vnops.c       Sun Aug 01 05:17:45 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vnops.c,v 1.79.2.1.2.1 1999/06/21 01:26:56 thorpej Exp $       */
+/*     $NetBSD: msdosfs_vnops.c,v 1.79.2.1.2.2 1999/08/01 05:17:46 chs Exp $   */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -449,11 +449,11 @@
        int error = 0;
        int diff;
        int blsize;
-       int isadir;
        long n;
        long on;
        daddr_t lbn;
-       daddr_t rablock;
+       void *win;
+       vsize_t bytelen;
        struct buf *bp;
        struct vnode *vp = ap->a_vp;
        struct denode *dep = VTODE(vp);
@@ -463,12 +463,35 @@
        /*
         * If they didn't ask for any data, then we are done.
         */
+
        if (uio->uio_resid == 0)
                return (0);
        if (uio->uio_offset < 0)
                return (EINVAL);
 
-       isadir = dep->de_Attributes & ATTR_DIRECTORY;
+       if (vp->v_type == VREG) {
+               while (uio->uio_resid > 0) {
+                       bytelen = min(dep->de_FileSize - uio->uio_offset,
+                                     uio->uio_resid);
+
+                       if (bytelen == 0)
+                               break;
+                       win = ubc_alloc(&vp->v_uvm.u_obj, uio->uio_offset,
+                                       &bytelen, UBC_READ);
+#ifdef DIAGNOSTIC
+                       if (win == NULL)
+                               panic("msdosfs_read: ubc_alloc -> NULL");
+#endif
+                       error = uiomove(win, bytelen, uio);
+                       ubc_release(win, 0);
+                       if (error)
+                               break;
+               }
+               dep->de_flag |= DE_ACCESS;
+               goto out;
+       }
+
+       /* this loop is only for directories now */
        do {
                lbn = de_cluster(pmp, uio->uio_offset);
                on = uio->uio_offset & pmp->pm_crbomask;
@@ -478,41 +501,28 @@
                        return (0);
                if (diff < n)
                        n = diff;
-               /* convert cluster # to block # if a directory */
-               if (isadir) {
-                       error = pcbmap(dep, lbn, &lbn, 0, &blsize);
-                       if (error)
-                               return (error);
-               }
+
+               /* convert cluster # to block # */
+               error = pcbmap(dep, lbn, &lbn, 0, &blsize);
+               if (error)
+                       return (error);
+
                /*
                 * If we are operating on a directory file then be sure to
                 * do i/o with the vnode for the filesystem instead of the
                 * vnode for the directory.
                 */
-               if (isadir) {
-                       error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
-               } else {
-                       rablock = lbn + 1;
-                       if (vp->v_lastr + 1 == lbn &&
-                           de_cn2off(pmp, rablock) < dep->de_FileSize)
-                               error = breada(vp, de_cn2bn(pmp, lbn),
-                                   pmp->pm_bpcluster, de_cn2bn(pmp, rablock),
-                                   pmp->pm_bpcluster, NOCRED, &bp);
-                       else
-                               error = bread(vp, de_cn2bn(pmp, lbn),
-                                   pmp->pm_bpcluster, NOCRED, &bp);
-                       vp->v_lastr = lbn;
-               }
+               error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
                n = min(n, pmp->pm_bpcluster - bp->b_resid);
                if (error) {
                        brelse(bp);
                        return (error);
                }
                error = uiomove(bp->b_data + on, (int) n, uio);
-               if (!isadir)
-                       dep->de_flag |= DE_ACCESS;
                brelse(bp);
        } while (error == 0 && uio->uio_resid > 0 && n != 0);
+
+out:
        if ((ap->a_ioflag & IO_SYNC) == IO_SYNC)
                error = deupdat(dep, 1);
        return (error);
@@ -531,19 +541,17 @@
                int a_ioflag;
                struct ucred *a_cred;
        } */ *ap = v;
-       int n;
-       int croffset;
        int resid;
        u_long osize;
        int error = 0;
        u_long count;
        daddr_t bn, lastcn;
-       struct buf *bp;
        int ioflag = ap->a_ioflag;
+       vsize_t bytelen;
+       void *win;
        struct uio *uio = ap->a_uio;
        struct proc *p = uio->uio_procp;
        struct vnode *vp = ap->a_vp;
-       struct vnode *thisvp;
        struct denode *dep = VTODE(vp);
        struct msdosfsmount *pmp = dep->de_pmp;
        struct ucred *cred = ap->a_cred;
@@ -559,7 +567,6 @@



Home | Main Index | Thread Index | Old Index