Sun Jul 26 08:13:24 2015 UTC ()
lfs_flush_pchain: replace vget() with vcache_get().


(hannken)
diff -r1.276 -r1.277 src/sys/ufs/lfs/lfs_vnops.c

cvs diff -r1.276 -r1.277 src/sys/ufs/lfs/lfs_vnops.c (expand / switch to unified diff)

--- src/sys/ufs/lfs/lfs_vnops.c 2015/07/25 10:40:35 1.276
+++ src/sys/ufs/lfs/lfs_vnops.c 2015/07/26 08:13:23 1.277
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lfs_vnops.c,v 1.276 2015/07/25 10:40:35 martin Exp $ */ 1/* $NetBSD: lfs_vnops.c,v 1.277 2015/07/26 08:13:23 hannken Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * by Konrad E. Schroder <perseant@hhhh.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -115,27 +115,27 @@ @@ -115,27 +115,27 @@
115 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 115 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
116 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 116 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
117 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 117 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
118 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 118 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
119 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 119 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
120 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 120 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
121 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 121 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
122 * SUCH DAMAGE. 122 * SUCH DAMAGE.
123 * 123 *
124 * @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95 124 * @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95
125 */ 125 */
126 126
127#include <sys/cdefs.h> 127#include <sys/cdefs.h>
128__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.276 2015/07/25 10:40:35 martin Exp $"); 128__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.277 2015/07/26 08:13:23 hannken Exp $");
129 129
130#ifdef _KERNEL_OPT 130#ifdef _KERNEL_OPT
131#include "opt_compat_netbsd.h" 131#include "opt_compat_netbsd.h"
132#include "opt_uvm_page_trkown.h" 132#include "opt_uvm_page_trkown.h"
133#endif 133#endif
134 134
135#include <sys/param.h> 135#include <sys/param.h>
136#include <sys/systm.h> 136#include <sys/systm.h>
137#include <sys/namei.h> 137#include <sys/namei.h>
138#include <sys/resourcevar.h> 138#include <sys/resourcevar.h>
139#include <sys/kernel.h> 139#include <sys/kernel.h>
140#include <sys/file.h> 140#include <sys/file.h>
141#include <sys/stat.h> 141#include <sys/stat.h>
@@ -1672,51 +1672,54 @@ lfs_flush_pchain(struct lfs *fs) @@ -1672,51 +1672,54 @@ lfs_flush_pchain(struct lfs *fs)
1672 lfs_imtime(fs); 1672 lfs_imtime(fs);
1673 lfs_seglock(fs, 0); 1673 lfs_seglock(fs, 0);
1674 sp = fs->lfs_sp; 1674 sp = fs->lfs_sp;
1675 1675
1676 /* 1676 /*
1677 * lfs_writevnodes, optimized to clear pageout requests. 1677 * lfs_writevnodes, optimized to clear pageout requests.
1678 * Only write non-dirop files that are in the pageout queue. 1678 * Only write non-dirop files that are in the pageout queue.
1679 * We're very conservative about what we write; we want to be 1679 * We're very conservative about what we write; we want to be
1680 * fast and async. 1680 * fast and async.
1681 */ 1681 */
1682 mutex_enter(&lfs_lock); 1682 mutex_enter(&lfs_lock);
1683 top: 1683 top:
1684 for (ip = TAILQ_FIRST(&fs->lfs_pchainhd); ip != NULL; ip = nip) { 1684 for (ip = TAILQ_FIRST(&fs->lfs_pchainhd); ip != NULL; ip = nip) {
 1685 struct mount *mp = ITOV(ip)->v_mount;
 1686 ino_t ino = ip->i_number;
 1687
1685 nip = TAILQ_NEXT(ip, i_lfs_pchain); 1688 nip = TAILQ_NEXT(ip, i_lfs_pchain);
1686 vp = ITOV(ip); 
1687 1689
1688 if (!(ip->i_flags & IN_PAGING)) 1690 if (!(ip->i_flags & IN_PAGING))
1689 goto top; 1691 goto top;
1690 1692
1691 mutex_enter(vp->v_interlock); 
1692 if (vdead_check(vp, VDEAD_NOWAIT) != 0 || 
1693 (vp->v_uflag & VU_DIROP) != 0) { 
1694 mutex_exit(vp->v_interlock); 
1695 continue; 
1696 } 
1697 if (vp->v_type != VREG) { 
1698 mutex_exit(vp->v_interlock); 
1699 continue; 
1700 } 
1701 if (vget(vp, LK_NOWAIT, false /* !wait */)) 
1702 continue; 
1703 mutex_exit(&lfs_lock); 1693 mutex_exit(&lfs_lock);
1704 1694 if (vcache_get(mp, &ino, sizeof(ino), &vp) != 0) {
1705 if (vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_RETRY) != 0) { 1695 mutex_enter(&lfs_lock);
 1696 continue;
 1697 };
 1698 if (vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT) != 0) {
1706 vrele(vp); 1699 vrele(vp);
1707 mutex_enter(&lfs_lock); 1700 mutex_enter(&lfs_lock);
1708 continue; 1701 continue;
1709 } 1702 }
 1703 ip = VTOI(vp);
 1704 mutex_enter(&lfs_lock);
 1705 if ((vp->v_uflag & VU_DIROP) != 0 || vp->v_type != VREG ||
 1706 !(ip->i_flags & IN_PAGING)) {
 1707 mutex_exit(&lfs_lock);
 1708 vput(vp);
 1709 mutex_enter(&lfs_lock);
 1710 goto top;
 1711 }
 1712 mutex_exit(&lfs_lock);
1710 1713
1711 error = lfs_writefile(fs, sp, vp); 1714 error = lfs_writefile(fs, sp, vp);
1712 if (!VPISEMPTY(vp) && !WRITEINPROG(vp) && 1715 if (!VPISEMPTY(vp) && !WRITEINPROG(vp) &&
1713 !(ip->i_flag & IN_ALLMOD)) { 1716 !(ip->i_flag & IN_ALLMOD)) {
1714 mutex_enter(&lfs_lock); 1717 mutex_enter(&lfs_lock);
1715 LFS_SET_UINO(ip, IN_MODIFIED); 1718 LFS_SET_UINO(ip, IN_MODIFIED);
1716 mutex_exit(&lfs_lock); 1719 mutex_exit(&lfs_lock);
1717 } 1720 }
1718 KDASSERT(ip->i_number != LFS_IFILE_INUM); 1721 KDASSERT(ip->i_number != LFS_IFILE_INUM);
1719 error2 = lfs_writeinode(fs, sp, ip); 1722 error2 = lfs_writeinode(fs, sp, ip);
1720 1723
1721 VOP_UNLOCK(vp); 1724 VOP_UNLOCK(vp);
1722 vrele(vp); 1725 vrele(vp);