From 5d934daa21cf1de100846d6a6e8fdf7a8379f31a Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Tue, 12 Nov 1985 03:42:14 -0800 Subject: [PATCH 1/1] must unhash blocks at the beginning of a new fragment SCCS-vsn: sys/ufs/ffs/ffs_alloc.c 6.18 SCCS-vsn: sys/ufs/lfs/lfs_alloc.c 6.18 --- usr/src/sys/ufs/ffs/ffs_alloc.c | 15 ++++++++++++--- usr/src/sys/ufs/lfs/lfs_alloc.c | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/usr/src/sys/ufs/ffs/ffs_alloc.c b/usr/src/sys/ufs/ffs/ffs_alloc.c index a54f8d7c6d..7aaba8c86d 100644 --- a/usr/src/sys/ufs/ffs/ffs_alloc.c +++ b/usr/src/sys/ufs/ffs/ffs_alloc.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)ffs_alloc.c 6.17 (Berkeley) %G% + * @(#)ffs_alloc.c 6.18 (Berkeley) %G% */ #include "param.h" @@ -109,10 +109,12 @@ realloccg(ip, bprev, bpref, osize, nsize) daddr_t bprev, bpref; int osize, nsize; { - daddr_t bno; register struct fs *fs; register struct buf *bp, *obp; int cg, request; + daddr_t bno, bn; + int i, count, s; + extern struct cmap *mfind(); fs = ip->i_fs; if ((unsigned)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || @@ -202,8 +204,15 @@ realloccg(ip, bprev, bpref, osize, nsize) brelse(obp); return (NULL); } - bp = getblk(ip->i_dev, fsbtodb(fs, bno), nsize); + bn = fsbtodb(fs, bno); + bp = getblk(ip->i_dev, bn, nsize); bcopy(obp->b_un.b_addr, bp->b_un.b_addr, (u_int)osize); + count = howmany(osize, DEV_BSIZE); + s = splimp(); + for (i = 0; i < count; i += CLBYTES / DEV_BSIZE) + if (mfind(ip->i_dev, bn + i)) + munhash(ip->i_dev, bn + i); + splx(s); bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize); if (obp->b_flags & B_DELWRI) { obp->b_flags &= ~B_DELWRI; diff --git a/usr/src/sys/ufs/lfs/lfs_alloc.c b/usr/src/sys/ufs/lfs/lfs_alloc.c index d67ef2232b..884d1dbaed 100644 --- a/usr/src/sys/ufs/lfs/lfs_alloc.c +++ b/usr/src/sys/ufs/lfs/lfs_alloc.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)lfs_alloc.c 6.17 (Berkeley) %G% + * @(#)lfs_alloc.c 6.18 (Berkeley) %G% */ #include "param.h" @@ -109,10 +109,12 @@ realloccg(ip, bprev, bpref, osize, nsize) daddr_t bprev, bpref; int osize, nsize; { - daddr_t bno; register struct fs *fs; register struct buf *bp, *obp; int cg, request; + daddr_t bno, bn; + int i, count, s; + extern struct cmap *mfind(); fs = ip->i_fs; if ((unsigned)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || @@ -202,8 +204,15 @@ realloccg(ip, bprev, bpref, osize, nsize) brelse(obp); return (NULL); } - bp = getblk(ip->i_dev, fsbtodb(fs, bno), nsize); + bn = fsbtodb(fs, bno); + bp = getblk(ip->i_dev, bn, nsize); bcopy(obp->b_un.b_addr, bp->b_un.b_addr, (u_int)osize); + count = howmany(osize, DEV_BSIZE); + s = splimp(); + for (i = 0; i < count; i += CLBYTES / DEV_BSIZE) + if (mfind(ip->i_dev, bn + i)) + munhash(ip->i_dev, bn + i); + splx(s); bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize); if (obp->b_flags & B_DELWRI) { obp->b_flags &= ~B_DELWRI; -- 2.20.1