buffer invalidate routine and checks for B_INVAL flag
authorRobert Elz <kre@ucbvax.Berkeley.EDU>
Thu, 29 Jan 1981 03:46:37 +0000 (19:46 -0800)
committerRobert Elz <kre@ucbvax.Berkeley.EDU>
Thu, 29 Jan 1981 03:46:37 +0000 (19:46 -0800)
SCCS-vsn: sys/kern/kern_physio.c 4.5
SCCS-vsn: sys/kern/vfs_bio.c 4.5
SCCS-vsn: sys/kern/vfs_cluster.c 4.5

usr/src/sys/kern/kern_physio.c
usr/src/sys/kern/vfs_bio.c
usr/src/sys/kern/vfs_cluster.c

index 022c45c..ef91a45 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_physio.c   4.4     %G%     */
+/*     kern_physio.c   4.5     %G%     */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -294,7 +294,8 @@ daddr_t blkno;
 
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink])
 
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink])
-               if (bp->b_blkno == dblkno && bp->b_dev == dev)
+               if (bp->b_blkno == dblkno && bp->b_dev == dev
+                                       && !(bp->b_flags & B_INVAL))
                        return (1);
        return (0);
 }
                        return (1);
        return (0);
 }
@@ -330,7 +331,8 @@ daddr_t blkno;
        (void) spl0();
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink]) {
        (void) spl0();
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink]) {
-               if (bp->b_blkno != dblkno || bp->b_dev != dev)
+               if (bp->b_blkno != dblkno || bp->b_dev != dev
+                                       || bp->b_flags & B_INVAL)
                        continue;
                (void) spl6();
                if (bp->b_flags&B_BUSY) {
                        continue;
                (void) spl6();
                if (bp->b_flags&B_BUSY) {
@@ -794,3 +796,26 @@ register struct buf *bp;
                if ((u.u_error = bp->b_error)==0)
                        u.u_error = EIO;
 }
                if ((u.u_error = bp->b_error)==0)
                        u.u_error = EIO;
 }
+
+/*
+ * Invalidate in core blocks belonging to closed or umounted filesystem
+ *
+ * This is not nicely done at all - the buffer ought to be removed from the
+ * hash chains & have its dev/blkno fields clobbered, but unfortunately we
+ * can't do that here, as it is quite possible that the block is still
+ * being used for i/o. Eventually, all disc drivers should be forced to
+ * have a close routine, which ought ensure that the queue is empty, then
+ * properly flush the queues. Until that happy day, this suffices for
+ * correctness.                                                ... kre
+ */
+binval(dev)
+dev_t dev;
+{
+       register struct buf *bp, *dp;
+
+       dp = bdevsw[major(dev)].d_tab;
+
+       for (bp = dp->b_forw; bp != dp; bp = bp->b_forw)
+               if (bp->b_dev == dev)
+                       bp->b_flags |= B_INVAL;
+}
index 3cc7073..af42cbd 100644 (file)
@@ -1,4 +1,4 @@
-/*     vfs_bio.c       4.4     %G%     */
+/*     vfs_bio.c       4.5     %G%     */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -294,7 +294,8 @@ daddr_t blkno;
 
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink])
 
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink])
-               if (bp->b_blkno == dblkno && bp->b_dev == dev)
+               if (bp->b_blkno == dblkno && bp->b_dev == dev
+                                       && !(bp->b_flags & B_INVAL))
                        return (1);
        return (0);
 }
                        return (1);
        return (0);
 }
@@ -330,7 +331,8 @@ daddr_t blkno;
        (void) spl0();
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink]) {
        (void) spl0();
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink]) {
-               if (bp->b_blkno != dblkno || bp->b_dev != dev)
+               if (bp->b_blkno != dblkno || bp->b_dev != dev
+                                       || bp->b_flags & B_INVAL)
                        continue;
                (void) spl6();
                if (bp->b_flags&B_BUSY) {
                        continue;
                (void) spl6();
                if (bp->b_flags&B_BUSY) {
@@ -794,3 +796,26 @@ register struct buf *bp;
                if ((u.u_error = bp->b_error)==0)
                        u.u_error = EIO;
 }
                if ((u.u_error = bp->b_error)==0)
                        u.u_error = EIO;
 }
+
+/*
+ * Invalidate in core blocks belonging to closed or umounted filesystem
+ *
+ * This is not nicely done at all - the buffer ought to be removed from the
+ * hash chains & have its dev/blkno fields clobbered, but unfortunately we
+ * can't do that here, as it is quite possible that the block is still
+ * being used for i/o. Eventually, all disc drivers should be forced to
+ * have a close routine, which ought ensure that the queue is empty, then
+ * properly flush the queues. Until that happy day, this suffices for
+ * correctness.                                                ... kre
+ */
+binval(dev)
+dev_t dev;
+{
+       register struct buf *bp, *dp;
+
+       dp = bdevsw[major(dev)].d_tab;
+
+       for (bp = dp->b_forw; bp != dp; bp = bp->b_forw)
+               if (bp->b_dev == dev)
+                       bp->b_flags |= B_INVAL;
+}
index e0d9ed6..9be3827 100644 (file)
@@ -1,4 +1,4 @@
-/*     vfs_cluster.c   4.4     %G%     */
+/*     vfs_cluster.c   4.5     %G%     */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -294,7 +294,8 @@ daddr_t blkno;
 
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink])
 
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink])
-               if (bp->b_blkno == dblkno && bp->b_dev == dev)
+               if (bp->b_blkno == dblkno && bp->b_dev == dev
+                                       && !(bp->b_flags & B_INVAL))
                        return (1);
        return (0);
 }
                        return (1);
        return (0);
 }
@@ -330,7 +331,8 @@ daddr_t blkno;
        (void) spl0();
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink]) {
        (void) spl0();
        for (bp = &buf[bufhash[BUFHASH(blkno)]]; bp != &buf[-1];
            bp = &buf[bp->b_hlink]) {
-               if (bp->b_blkno != dblkno || bp->b_dev != dev)
+               if (bp->b_blkno != dblkno || bp->b_dev != dev
+                                       || bp->b_flags & B_INVAL)
                        continue;
                (void) spl6();
                if (bp->b_flags&B_BUSY) {
                        continue;
                (void) spl6();
                if (bp->b_flags&B_BUSY) {
@@ -794,3 +796,26 @@ register struct buf *bp;
                if ((u.u_error = bp->b_error)==0)
                        u.u_error = EIO;
 }
                if ((u.u_error = bp->b_error)==0)
                        u.u_error = EIO;
 }
+
+/*
+ * Invalidate in core blocks belonging to closed or umounted filesystem
+ *
+ * This is not nicely done at all - the buffer ought to be removed from the
+ * hash chains & have its dev/blkno fields clobbered, but unfortunately we
+ * can't do that here, as it is quite possible that the block is still
+ * being used for i/o. Eventually, all disc drivers should be forced to
+ * have a close routine, which ought ensure that the queue is empty, then
+ * properly flush the queues. Until that happy day, this suffices for
+ * correctness.                                                ... kre
+ */
+binval(dev)
+dev_t dev;
+{
+       register struct buf *bp, *dp;
+
+       dp = bdevsw[major(dev)].d_tab;
+
+       for (bp = dp->b_forw; bp != dp; bp = bp->b_forw)
+               if (bp->b_dev == dev)
+                       bp->b_flags |= B_INVAL;
+}