Wed Aug 5 15:39:57 2009 UTC ()
Compensate v_numoutput & nestbuf for lfs's rather peculiar I/O habits.


(pooka)
diff -r1.276 -r1.277 src/sys/ufs/lfs/lfs_vfsops.c

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

--- src/sys/ufs/lfs/lfs_vfsops.c 2009/08/05 14:37:01 1.276
+++ src/sys/ufs/lfs/lfs_vfsops.c 2009/08/05 15:39:57 1.277
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lfs_vfsops.c,v 1.276 2009/08/05 14:37:01 pooka Exp $ */ 1/* $NetBSD: lfs_vfsops.c,v 1.277 2009/08/05 15:39:57 pooka Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007 4 * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
5 * The NetBSD Foundation, Inc. 5 * The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Konrad E. Schroder <perseant@hhhh.org>. 9 * by Konrad E. Schroder <perseant@hhhh.org>.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -51,27 +51,27 @@ @@ -51,27 +51,27 @@
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE. 58 * SUCH DAMAGE.
59 * 59 *
60 * @(#)lfs_vfsops.c 8.20 (Berkeley) 6/10/95 60 * @(#)lfs_vfsops.c 8.20 (Berkeley) 6/10/95
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.276 2009/08/05 14:37:01 pooka Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.277 2009/08/05 15:39:57 pooka Exp $");
65 65
66#if defined(_KERNEL_OPT) 66#if defined(_KERNEL_OPT)
67#include "opt_lfs.h" 67#include "opt_lfs.h"
68#include "opt_quota.h" 68#include "opt_quota.h"
69#endif 69#endif
70 70
71#include <sys/param.h> 71#include <sys/param.h>
72#include <sys/systm.h> 72#include <sys/systm.h>
73#include <sys/namei.h> 73#include <sys/namei.h>
74#include <sys/proc.h> 74#include <sys/proc.h>
75#include <sys/kernel.h> 75#include <sys/kernel.h>
76#include <sys/vnode.h> 76#include <sys/vnode.h>
77#include <sys/mount.h> 77#include <sys/mount.h>
@@ -1746,26 +1746,35 @@ lfs_gop_write(struct vnode *vp, struct v @@ -1746,26 +1746,35 @@ lfs_gop_write(struct vnode *vp, struct v
1746 mutex_exit(&vp->v_interlock); 1746 mutex_exit(&vp->v_interlock);
1747 } else { 1747 } else {
1748 bp = getiobuf(NULL, true); 1748 bp = getiobuf(NULL, true);
1749 UVMHIST_LOG(ubchist, "vp %p bp %p num now %d", 1749 UVMHIST_LOG(ubchist, "vp %p bp %p num now %d",
1750 vp, bp, vp->v_numoutput, 0); 1750 vp, bp, vp->v_numoutput, 0);
1751 nestiobuf_setup(mbp, bp, offset - pg->offset, iobytes); 1751 nestiobuf_setup(mbp, bp, offset - pg->offset, iobytes);
1752 /* 1752 /*
1753 * LFS doesn't like async I/O here, dies with 1753 * LFS doesn't like async I/O here, dies with
1754 * and assert in lfs_bwrite(). Is that assert 1754 * and assert in lfs_bwrite(). Is that assert
1755 * valid? I retained non-async behaviour when 1755 * valid? I retained non-async behaviour when
1756 * converted this to use nestiobuf --pooka 1756 * converted this to use nestiobuf --pooka
1757 */ 1757 */
1758 bp->b_flags &= ~B_ASYNC; 1758 bp->b_flags &= ~B_ASYNC;
 1759 /*
 1760 * LFS uses VOP_BWRITE instead of VOP_STRATEGY.
 1761 * Therefore biodone doesn't get called for
 1762 * the buffer. Therefore decrement the output
 1763 * counter that nestiobuf_setup() incremented.
 1764 */
 1765 mutex_enter(&vp->v_interlock);
 1766 vp->v_numoutput--;
 1767 mutex_exit(&vp->v_interlock);
1759 } 1768 }
1760 1769
1761 /* XXX This is silly ... is this necessary? */ 1770 /* XXX This is silly ... is this necessary? */
1762 mutex_enter(&bufcache_lock); 1771 mutex_enter(&bufcache_lock);
1763 mutex_enter(&vp->v_interlock); 1772 mutex_enter(&vp->v_interlock);
1764 bgetvp(vp, bp); 1773 bgetvp(vp, bp);
1765 mutex_exit(&vp->v_interlock); 1774 mutex_exit(&vp->v_interlock);
1766 mutex_exit(&bufcache_lock); 1775 mutex_exit(&bufcache_lock);
1767 1776
1768 bp->b_lblkno = lblkno(fs, offset); 1777 bp->b_lblkno = lblkno(fs, offset);
1769 bp->b_private = mbp; 1778 bp->b_private = mbp;
1770 if (devvp->v_type == VBLK) { 1779 if (devvp->v_type == VBLK) {
1771 bp->b_dev = devvp->v_rdev; 1780 bp->b_dev = devvp->v_rdev;