From: Robert Elz Date: Thu, 29 Jan 1981 03:46:37 +0000 (-0800) Subject: buffer invalidate routine and checks for B_INVAL flag X-Git-Tag: BSD-4_1_snap-Snapshot-Development~2410 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/7b8b5a017ec860062c1f8626302492b3a164b77e buffer invalidate routine and checks for B_INVAL flag 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 --- diff --git a/usr/src/sys/kern/kern_physio.c b/usr/src/sys/kern/kern_physio.c index 022c45c572..ef91a456a9 100644 --- a/usr/src/sys/kern/kern_physio.c +++ b/usr/src/sys/kern/kern_physio.c @@ -1,4 +1,4 @@ -/* kern_physio.c 4.4 %G% */ +/* kern_physio.c 4.5 %G% */ #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]) - 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); } @@ -330,7 +331,8 @@ daddr_t blkno; (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) { @@ -794,3 +796,26 @@ register struct buf *bp; 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; +} diff --git a/usr/src/sys/kern/vfs_bio.c b/usr/src/sys/kern/vfs_bio.c index 3cc7073f4b..af42cbd023 100644 --- a/usr/src/sys/kern/vfs_bio.c +++ b/usr/src/sys/kern/vfs_bio.c @@ -1,4 +1,4 @@ -/* vfs_bio.c 4.4 %G% */ +/* vfs_bio.c 4.5 %G% */ #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]) - 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); } @@ -330,7 +331,8 @@ daddr_t blkno; (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) { @@ -794,3 +796,26 @@ register struct buf *bp; 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; +} diff --git a/usr/src/sys/kern/vfs_cluster.c b/usr/src/sys/kern/vfs_cluster.c index e0d9ed65ec..9be3827e7d 100644 --- a/usr/src/sys/kern/vfs_cluster.c +++ b/usr/src/sys/kern/vfs_cluster.c @@ -1,4 +1,4 @@ -/* vfs_cluster.c 4.4 %G% */ +/* vfs_cluster.c 4.5 %G% */ #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]) - 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); } @@ -330,7 +331,8 @@ daddr_t blkno; (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) { @@ -794,3 +796,26 @@ register struct buf *bp; 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; +}