debugging, print out information on processes holding and waiting for lock
[unix-history] / usr / src / sys / ufs / ffs / ffs_vnops.c
index c2d422a..131c2ee 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)ffs_vnops.c 7.25 (Berkeley) %G%
+ *     @(#)ffs_vnops.c 7.28 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -237,7 +237,7 @@ ufs_close(vp, fflag, cred)
 {
        register struct inode *ip = VTOI(vp);
 
 {
        register struct inode *ip = VTOI(vp);
 
-       if (vp->v_count > 1 && !(ip->i_flag & ILOCKED))
+       if (vp->v_usecount > 1 && !(ip->i_flag & ILOCKED))
                ITIMES(ip, &time, &time);
        return (0);
 }
                ITIMES(ip, &time, &time);
        return (0);
 }
@@ -452,7 +452,7 @@ ufs_read(vp, uio, ioflag, cred)
        register struct fs *fs;
        struct buf *bp;
        daddr_t lbn, bn, rablock;
        register struct fs *fs;
        struct buf *bp;
        daddr_t lbn, bn, rablock;
-       int size, rasize, diff, error = 0;
+       int size, diff, error = 0;
        long n, on, type;
 
        if (uio->uio_rw != UIO_READ)
        long n, on, type;
 
        if (uio->uio_rw != UIO_READ)
@@ -477,13 +477,13 @@ ufs_read(vp, uio, ioflag, cred)
                        n = diff;
                size = blksize(fs, ip, lbn);
                rablock = lbn + 1;
                        n = diff;
                size = blksize(fs, ip, lbn);
                rablock = lbn + 1;
-               rasize = blksize(fs, ip, rablock);
-               if (ip->i_lastr + 1 == lbn)
-                       error = breada(ITOV(ip), lbn, size, rablock, rasize,
-                               NOCRED, &bp);
+               if (vp->v_lastr + 1 == lbn &&
+                   lblktosize(fs, rablock) < ip->i_size)
+                       error = breada(ITOV(ip), lbn, size, rablock,
+                               blksize(fs, ip, rablock), NOCRED, &bp);
                else
                        error = bread(ITOV(ip), lbn, size, NOCRED, &bp);
                else
                        error = bread(ITOV(ip), lbn, size, NOCRED, &bp);
-               ip->i_lastr = lbn;
+               vp->v_lastr = lbn;
                n = MIN(n, size - bp->b_resid);
                if (error) {
                        brelse(bp);
                n = MIN(n, size - bp->b_resid);
                if (error) {
                        brelse(bp);
@@ -1305,13 +1305,13 @@ ufs_strategy(bp)
        if (bp->b_blkno == bp->b_lblkno) {
                if (error = bmap(ip, bp->b_lblkno, &bp->b_blkno))
                        return (error);
        if (bp->b_blkno == bp->b_lblkno) {
                if (error = bmap(ip, bp->b_lblkno, &bp->b_blkno))
                        return (error);
-               if ((long)bp->b_blkno == -1) {
+               if ((long)bp->b_blkno == -1)
                        clrbuf(bp);
                        clrbuf(bp);
-                       biodone(bp);
-               }
        }
        }
-       if ((long)bp->b_blkno == -1)
+       if ((long)bp->b_blkno == -1) {
+               biodone(bp);
                return (0);
                return (0);
+       }
        if (checkoverlap) {
                ebp = &buf[nbuf];
                start = bp->b_blkno;
        if (checkoverlap) {
                ebp = &buf[nbuf];
                start = bp->b_blkno;
@@ -1328,7 +1328,10 @@ ufs_strategy(bp)
                        if (ep->b_bcount == 0 || ep->b_blkno > last ||
                            ep->b_blkno + btodb(ep->b_bcount) <= start)
                                continue;
                        if (ep->b_bcount == 0 || ep->b_blkno > last ||
                            ep->b_blkno + btodb(ep->b_bcount) <= start)
                                continue;
-                       panic("Disk overlap");
+                       vprint("Disk overlap", vp);
+                       printf("\tstart %d, end %d overlap start %d, end %d\n",
+                               start, last, ep->b_blkno,
+                               ep->b_blkno + btodb(ep->b_bcount) - 1);
                }
        }
        vp = ip->i_devvp;
                }
        }
        vp = ip->i_devvp;
@@ -1348,6 +1351,12 @@ ufs_print(vp)
        printf("tag VT_UFS, ino %d, on dev %d, %d%s\n", ip->i_number,
                major(ip->i_dev), minor(ip->i_dev),
                (ip->i_flag & ILOCKED) ? " (LOCKED)" : "");
        printf("tag VT_UFS, ino %d, on dev %d, %d%s\n", ip->i_number,
                major(ip->i_dev), minor(ip->i_dev),
                (ip->i_flag & ILOCKED) ? " (LOCKED)" : "");
+       if (ip->i_spare0 == 0)
+               return;
+       printf("\towner pid %d", ip->i_spare0);
+       if (ip->i_spare1)
+               printf(" waiting pid %d", ip->i_spare1);
+       printf("\n");
 }
 
 /*
 }
 
 /*
@@ -1396,7 +1405,7 @@ ufsspec_close(vp, fflag, cred)
 {
        register struct inode *ip = VTOI(vp);
 
 {
        register struct inode *ip = VTOI(vp);
 
-       if (vp->v_count > 1 && !(ip->i_flag & ILOCKED))
+       if (vp->v_usecount > 1 && !(ip->i_flag & ILOCKED))
                ITIMES(ip, &time, &time);
        return (spec_close(vp, fflag, cred));
 }
                ITIMES(ip, &time, &time);
        return (spec_close(vp, fflag, cred));
 }