From owner-svn-src-user@FreeBSD.ORG Thu Nov 19 04:47:43 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EED57106566C; Thu, 19 Nov 2009 04:47:43 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C577B8FC17; Thu, 19 Nov 2009 04:47:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nAJ4lhN7093929; Thu, 19 Nov 2009 04:47:43 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nAJ4lhw3093927; Thu, 19 Nov 2009 04:47:43 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200911190447.nAJ4lhw3093927@svn.freebsd.org> From: Kip Macy Date: Thu, 19 Nov 2009 04:47:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199505 - user/kmacy/releng_8_fcs_buf/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2009 04:47:44 -0000 Author: kmacy Date: Thu Nov 19 04:47:43 2009 New Revision: 199505 URL: http://svn.freebsd.org/changeset/base/199505 Log: aggressively invalidate any cached buffers on write completion Modified: user/kmacy/releng_8_fcs_buf/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: user/kmacy/releng_8_fcs_buf/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/releng_8_fcs_buf/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Nov 19 03:37:06 2009 (r199504) +++ user/kmacy/releng_8_fcs_buf/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Nov 19 04:47:43 2009 (r199505) @@ -1301,6 +1301,41 @@ arc_buf_add_ref(arc_buf_t *buf, void* ta } static void +arc_brelvp(arc_buf_hdr_t *hdr) +{ + uint64_t blkno = hdr->b_dva.dva_word[1] & ~(1UL<<63); + struct vnode *vp = spa_get_vnode(hdr->b_spa); + struct bufobj *bo = &vp->v_bufobj; + struct buf *bp; + + if (zfs_page_cache_disable) + return; + + if (blkno == 0 || hdr->b_birth == 0) + return; + + BO_LOCK(bo); + bp = gbincore(bo, blkno); + if (bp != NULL) { + /* + * XXX we have a race with getblk here + */ + BUF_LOCK(bp, LK_EXCLUSIVE | LK_INTERLOCK, BO_MTX(bo)); + bremfree(bp); + /* + * buffer is not valid or is older + */ + if (((bp->b_flags & (B_CACHE|B_INVAL)) != B_CACHE) || + (bp->b_birth <= hdr->b_birth)) { + bp->b_flags |= B_INVAL; + bp->b_birth = 0; + } + brelse(bp); + } else + BO_UNLOCK(bo); +} + +static void arc_bgetvp(arc_buf_t *buf) { uint64_t blkno = buf->b_hdr->b_dva.dva_word[1] & ~(1UL<<63); @@ -1344,7 +1379,7 @@ arc_bgetvp(arc_buf_t *buf) bgetvp(vp, newbp); BO_UNLOCK(bo); } - } else if ((hdr->b_datacnt == 1) && + } else if ((hdr->b_datacnt == 1) && !(hdr->b_flags & ARC_IO_ERROR) && (newbp->b_flags & (B_INVAL|B_CACHE)) == B_CACHE) { bgetvp(vp, newbp); @@ -3417,6 +3452,8 @@ arc_write_done(zio_t *zio) exists = buf_hash_insert(hdr, &hash_lock); ASSERT3P(exists, ==, NULL); } else if (buf->b_bp != NULL) { + arc_brelvp(hdr); + buf->b_bp->b_flags |= B_CACHE; buf->b_bp->b_flags &= ~B_INVAL; } @@ -3432,6 +3469,7 @@ arc_write_done(zio_t *zio) * This is an anonymous buffer with no user callback, * destroy it if there are no active references. */ + arc_brelvp(hdr); mutex_enter(&arc_eviction_mtx); destroy_hdr = refcount_is_zero(&hdr->b_refcnt); hdr->b_flags &= ~ARC_IO_IN_PROGRESS; @@ -3440,6 +3478,7 @@ arc_write_done(zio_t *zio) arc_hdr_destroy(hdr); } else { hdr->b_flags &= ~ARC_IO_IN_PROGRESS; + arc_brelvp(hdr); } hdr->b_flags &= ~ARC_STORED;