Author: kib
Date: Sat Dec 20 15:46:15 2014
New Revision: 275956
URL: https://svnweb.freebsd.org/changeset/base/275956

Log:
  MFC r275743:
  Put the buffer cleanup code after inactivation.

Modified:
  stable/10/sys/kern/vfs_subr.c
  stable/10/sys/sys/bufobj.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/vfs_subr.c
==============================================================================
--- stable/10/sys/kern/vfs_subr.c       Sat Dec 20 14:19:46 2014        
(r275955)
+++ stable/10/sys/kern/vfs_subr.c       Sat Dec 20 15:46:15 2014        
(r275956)
@@ -1567,6 +1567,7 @@ buf_vlist_add(struct buf *bp, struct buf
        int error;
 
        ASSERT_BO_WLOCKED(bo);
+       KASSERT((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;
@@ -2794,16 +2795,6 @@ vgonel(struct vnode *vp)
        vfs_notify_upper(vp, VFS_NOTIFY_UPPER_RECLAIM);
 
        /*
-        * Clean out any buffers associated with the vnode.
-        * If the flush fails, just toss the buffers.
-        */
-       mp = NULL;
-       if (!TAILQ_EMPTY(&vp->v_bufobj.bo_dirty.bv_hd))
-               (void) vn_start_secondary_write(vp, &mp, V_WAIT);
-       if (vinvalbuf(vp, V_SAVE, 0, 0) != 0)
-               vinvalbuf(vp, 0, 0, 0);
-
-       /*
         * If purging an active vnode, it must be closed and
         * deactivated before being reclaimed.
         */
@@ -2817,6 +2808,29 @@ vgonel(struct vnode *vp)
        }
        if (vp->v_type == VSOCK)
                vfs_unp_reclaim(vp);
+
+       /*
+        * Clean out any buffers associated with the vnode.
+        * If the flush fails, just toss the buffers.
+        */
+       mp = NULL;
+       if (!TAILQ_EMPTY(&vp->v_bufobj.bo_dirty.bv_hd))
+               (void) vn_start_secondary_write(vp, &mp, V_WAIT);
+       if (vinvalbuf(vp, V_SAVE, 0, 0) != 0) {
+               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 &&
+           TAILQ_EMPTY(&vp->v_bufobj.bo_clean.bv_hd) &&
+           vp->v_bufobj.bo_clean.bv_cnt == 0,
+           ("vp %p bufobj not invalidated", vp));
+       vp->v_bufobj.bo_flag |= BO_DEAD;
+       BO_UNLOCK(&vp->v_bufobj);
+#endif
+
        /*
         * Reclaim the vnode.
         */

Modified: stable/10/sys/sys/bufobj.h
==============================================================================
--- stable/10/sys/sys/bufobj.h  Sat Dec 20 14:19:46 2014        (r275955)
+++ stable/10/sys/sys/bufobj.h  Sat Dec 20 15:46:15 2014        (r275956)
@@ -112,6 +112,7 @@ struct bufobj {
  */
 #define        BO_ONWORKLST    (1 << 0)        /* On syncer work-list */
 #define        BO_WWAIT        (1 << 1)        /* Wait for output to complete 
*/
+#define        BO_DEAD         (1 << 2)        /* Dead; only with INVARIANTS */
 
 #define        BO_LOCKPTR(bo)          (&(bo)->bo_lock)
 #define        BO_LOCK(bo)             rw_wlock(BO_LOCKPTR((bo)))
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to