diff options
-rw-r--r-- | sys/kern/vfs_bio.c | 8 | ||||
-rw-r--r-- | sys/sys/buf.h | 1 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 8 |
3 files changed, 14 insertions, 3 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index bea2269..021458c 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -2537,6 +2537,14 @@ loop: * buffer is also considered valid (not marked B_INVAL). */ VI_UNLOCK(vp); + /* + * If the user does not want us to create the buffer, bail out + * here. + */ + if (flags & GB_NOCREAT) { + splx(s); + return NULL; + } if (vn_isdisk(vp, NULL)) bsize = DEV_BSIZE; else if (vp->v_mountedhere) diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 3965764..78ef55b 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -461,6 +461,7 @@ buf_countdeps(struct buf *bp, int i) * Flags for getblk's last parameter. */ #define GB_LOCK_NOWAIT 0x0001 /* Fail if we block on a buf lock. */ +#define GB_NOCREAT 0x0002 /* Don't create a buf if not found. */ #ifdef _KERNEL extern int nbuf; /* The number of buffer headers */ diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 429f98f..6ea776a 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -2563,10 +2563,10 @@ indir_trunc(freeblks, dbn, level, lbn, countp) * a complete copy of the indirect block in memory for our use. * Otherwise we have to read the blocks in from the disk. */ + bp = getblk(freeblks->fb_devvp, dbn, (int)fs->fs_bsize, 0, 0, + GB_NOCREAT); ACQUIRE_LOCK(&lk); - /* XXX Buf not locked! */ - if ((bp = incore(freeblks->fb_devvp, dbn)) != NULL && - (wk = LIST_FIRST(&bp->b_dep)) != NULL) { + if (bp != NULL && (wk = LIST_FIRST(&bp->b_dep)) != NULL) { if (wk->wk_type != D_INDIRDEP || (indirdep = WK_INDIRDEP(wk))->ir_savebp != bp || (indirdep->ir_state & GOINGAWAY) == 0) { @@ -2582,6 +2582,8 @@ indir_trunc(freeblks, dbn, level, lbn, countp) VFSTOUFS(freeblks->fb_mnt)->um_numindirdeps -= 1; FREE_LOCK(&lk); } else { + if (bp) + brelse(bp); FREE_LOCK(&lk); error = bread(freeblks->fb_devvp, dbn, (int)fs->fs_bsize, NOCRED, &bp); |