From owner-svn-src-stable-6@FreeBSD.ORG Tue Sep 8 14:19:14 2009 Return-Path: Delivered-To: svn-src-stable-6@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A018106566B; Tue, 8 Sep 2009 14:19:14 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6DBE28FC22; Tue, 8 Sep 2009 14:19:14 +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 n88EJEba049983; Tue, 8 Sep 2009 14:19:14 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n88EJE4P049981; Tue, 8 Sep 2009 14:19:14 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200909081419.n88EJE4P049981@svn.freebsd.org> From: Attilio Rao Date: Tue, 8 Sep 2009 14:19:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196973 - stable/6/sys/ufs/ffs X-BeenThere: svn-src-stable-6@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 6-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2009 14:19:14 -0000 Author: attilio Date: Tue Sep 8 14:19:14 2009 New Revision: 196973 URL: http://svn.freebsd.org/changeset/base/196973 Log: MFC r180758: Prevent the bdflush() activity when trying to lock an indirect block buffer setting TDP_INBDFUSH in the appropriate code paths. Sponsored by: Sandvine Incorporated Modified: stable/6/sys/ufs/ffs/ffs_balloc.c Modified: stable/6/sys/ufs/ffs/ffs_balloc.c ============================================================================== --- stable/6/sys/ufs/ffs/ffs_balloc.c Tue Sep 8 14:15:14 2009 (r196972) +++ stable/6/sys/ufs/ffs/ffs_balloc.c Tue Sep 8 14:19:14 2009 (r196973) @@ -104,6 +104,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t ufs1_daddr_t *allocib, *blkp, *allocblk, allociblk[NIADDR + 1]; ufs2_daddr_t *lbns_remfree, lbns[NIADDR + 1]; int unwindidx = -1; + int saved_inbdflush; ip = VTOI(vp); dp = ip->i_din1; @@ -225,6 +226,9 @@ ffs_balloc_ufs1(struct vnode *vp, off_t if (num < 1) panic ("ffs_balloc_ufs1: ufs_getlbns returned indirect block"); #endif + saved_inbdflush = ~TDP_INBDFLUSH | (curthread->td_pflags & + TDP_INBDFLUSH); + curthread->td_pflags |= TDP_INBDFLUSH; /* * Fetch the first indirect block allocating if necessary. */ @@ -237,8 +241,10 @@ ffs_balloc_ufs1(struct vnode *vp, off_t UFS_LOCK(ump); pref = ffs_blkpref_ufs1(ip, lbn, 0, (ufs1_daddr_t *)0); if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, - cred, &newb)) != 0) + cred, &newb)) != 0) { + curthread->td_pflags &= saved_inbdflush; return (error); + } nb = newb; *allocblk++ = nb; *lbns_remfree++ = indirs[1].in_lbn; @@ -329,6 +335,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t * If asked only for the indirect block, then return it. */ if (flags & BA_METAONLY) { + curthread->td_pflags &= saved_inbdflush; *bpp = bp; return (0); } @@ -366,6 +373,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t bp->b_flags |= B_CLUSTEROK; bdwrite(bp); } + curthread->td_pflags &= saved_inbdflush; *bpp = nbp; return (0); } @@ -387,9 +395,11 @@ ffs_balloc_ufs1(struct vnode *vp, off_t nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); } + curthread->td_pflags &= saved_inbdflush; *bpp = nbp; return (0); fail: + curthread->td_pflags &= saved_inbdflush; /* * If we have failed to allocate any blocks, simply return the error. * This is the usual case and avoids the need to fsync the file. @@ -489,6 +499,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t ufs2_daddr_t *lbns_remfree, lbns[NIADDR + 1]; int deallocated, osize, nsize, num, i, error; int unwindidx = -1; + int saved_inbdflush; ip = VTOI(vp); dp = ip->i_din2; @@ -719,6 +730,9 @@ ffs_balloc_ufs2(struct vnode *vp, off_t if (num < 1) panic ("ffs_balloc_ufs2: ufs_getlbns returned indirect block"); #endif + saved_inbdflush = ~TDP_INBDFLUSH | (curthread->td_pflags & + TDP_INBDFLUSH); + curthread->td_pflags |= TDP_INBDFLUSH; /* * Fetch the first indirect block allocating if necessary. */ @@ -731,8 +745,10 @@ ffs_balloc_ufs2(struct vnode *vp, off_t UFS_LOCK(ump); pref = ffs_blkpref_ufs2(ip, lbn, 0, (ufs2_daddr_t *)0); if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, - cred, &newb)) != 0) + cred, &newb)) != 0) { + curthread->td_pflags &= saved_inbdflush; return (error); + } nb = newb; *allocblk++ = nb; *lbns_remfree++ = indirs[1].in_lbn; @@ -823,6 +839,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t * If asked only for the indirect block, then return it. */ if (flags & BA_METAONLY) { + curthread->td_pflags &= saved_inbdflush; *bpp = bp; return (0); } @@ -860,6 +877,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t bp->b_flags |= B_CLUSTEROK; bdwrite(bp); } + curthread->td_pflags &= saved_inbdflush; *bpp = nbp; return (0); } @@ -887,9 +905,11 @@ ffs_balloc_ufs2(struct vnode *vp, off_t nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); } + curthread->td_pflags &= saved_inbdflush; *bpp = nbp; return (0); fail: + curthread->td_pflags &= saved_inbdflush; /* * If we have failed to allocate any blocks, simply return the error. * This is the usual case and avoids the need to fsync the file.