summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_subr.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-07-11 11:21:56 +0000
committerkib <kib@FreeBSD.org>2015-07-11 11:21:56 +0000
commit564e88d4999f488b5bfa09bee75872f9c90ce973 (patch)
treebca300d2a3d9ca2e7338d9364c17c31e27364ad7 /sys/kern/vfs_subr.c
parent4be9e0b1219fc98eed398023bf9b940df30300fd (diff)
downloadFreeBSD-src-564e88d4999f488b5bfa09bee75872f9c90ce973.zip
FreeBSD-src-564e88d4999f488b5bfa09bee75872f9c90ce973.tar.gz
Do not allow creation of the dirty buffers for the dead buffer
objects, i.e. for buffer objects which vnode was reclaimed. Buffer cache cannot write such buffers. Return the error and discard the buffer immediately on write attempt. BO_DIRTY now always set during vnode reclamation, since it is used not only for the INVARIANTS checks. Do allow placement of the clean buffers on dead bufobj list, otherwise filesystems cannot use bufcache at all after the devvp reclaim. Reported and tested by: trasz Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r--sys/kern/vfs_subr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 30aea62..a6093bd 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1584,7 +1584,8 @@ buf_vlist_add(struct buf *bp, struct bufobj *bo, b_xflags_t xflags)
int error;
ASSERT_BO_WLOCKED(bo);
- KASSERT((bo->bo_flag & BO_DEAD) == 0, ("dead bo %p", bo));
+ KASSERT((xflags & BX_VNDIRTY) == 0 || (bo->bo_flag & BO_DEAD) == 0,
+ ("dead bo %p", bo));
KASSERT((bp->b_xflags & (BX_VNDIRTY|BX_VNCLEAN)) == 0,
("buf_vlist_add: Buf %p has existing xflags %d", bp, bp->b_xflags));
bp->b_xflags |= xflags;
@@ -2841,7 +2842,7 @@ vgonel(struct vnode *vp)
while (vinvalbuf(vp, 0, 0, 0) != 0)
;
}
-#ifdef INVARIANTS
+
BO_LOCK(&vp->v_bufobj);
KASSERT(TAILQ_EMPTY(&vp->v_bufobj.bo_dirty.bv_hd) &&
vp->v_bufobj.bo_dirty.bv_cnt == 0 &&
@@ -2850,7 +2851,6 @@ vgonel(struct vnode *vp)
("vp %p bufobj not invalidated", vp));
vp->v_bufobj.bo_flag |= BO_DEAD;
BO_UNLOCK(&vp->v_bufobj);
-#endif
/*
* Reclaim the vnode.
OpenPOWER on IntegriCloud