mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
- Define a new flag for getblk(): GB_NOCREAT. This flag causes getblk() to
bail out if the buffer is not already present. - The buffer returned by incore() is not locked and should not be sent to brelse(). Use getblk() with the new GB_NOCREAT flag to preserve the desired semantics.
This commit is contained in:
parent
a707b683e7
commit
d919a11d06
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=119603
@ -2537,6 +2537,14 @@ getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo,
|
||||
* 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)
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user