Date: Sun, 6 Oct 2013 06:09:43 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r256077 - stable/9/sys/kern Message-ID: <201310060609.r9669hQM028286@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sun Oct 6 06:09:43 2013 New Revision: 256077 URL: http://svnweb.freebsd.org/changeset/base/256077 Log: MFC r255941: Increase the chance of the buffer write from the bufdaemon helper context to succeed. If the locked vnode which owns the buffer to be written is shared locked, try the non-blocking upgrade of the lock to exclusive. Modified: stable/9/sys/kern/vfs_bio.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/vfs_bio.c ============================================================================== --- stable/9/sys/kern/vfs_bio.c Sun Oct 6 06:05:11 2013 (r256076) +++ stable/9/sys/kern/vfs_bio.c Sun Oct 6 06:09:43 2013 (r256077) @@ -2671,6 +2671,8 @@ flushbufqueues(struct vnode *lvp, int qu int hasdeps; int flushed; int target; + int error; + bool unlock; if (lvp == NULL) { target = numdirtybuffers - lodirtybuffers; @@ -2751,7 +2753,16 @@ flushbufqueues(struct vnode *lvp, int qu BUF_UNLOCK(bp); continue; } - if (vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_CANRECURSE) == 0) { + if (lvp == NULL) { + unlock = true; + error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT); + } else { + ASSERT_VOP_LOCKED(vp, "getbuf"); + unlock = false; + error = VOP_ISLOCKED(vp) == LK_EXCLUSIVE ? 0 : + vn_lock(vp, LK_TRYUPGRADE); + } + if (error == 0) { mtx_unlock(&bqlock); CTR3(KTR_BUF, "flushbufqueue(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); @@ -2763,7 +2774,8 @@ flushbufqueues(struct vnode *lvp, int qu notbufdflashes++; } vn_finished_write(mp); - VOP_UNLOCK(vp, 0); + if (unlock) + VOP_UNLOCK(vp, 0); flushwithdeps += hasdeps; flushed++;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310060609.r9669hQM028286>