CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Mon Mar 15 09:20:10 UTC 2010 Modified Files: src/sys/ufs/ufs: ufs_inode.c Log Message: Allow ufs_inactive() while a file system is suspending. Removes a possible deadlock between vrele() and ffs_sync() during suspension. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/ufs/ufs/ufs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_inode.c diff -u src/sys/ufs/ufs/ufs_inode.c:1.79 src/sys/ufs/ufs/ufs_inode.c:1.80 --- src/sys/ufs/ufs/ufs_inode.c:1.79 Sun Feb 7 17:12:40 2010 +++ src/sys/ufs/ufs/ufs_inode.c Mon Mar 15 09:20:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_inode.c,v 1.79 2010/02/07 17:12:40 bouyer Exp $ */ +/* $NetBSD: ufs_inode.c,v 1.80 2010/03/15 09:20:10 hannken Exp $ */ /* * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.79 2010/02/07 17:12:40 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: ufs_inode.c,v 1.80 2010/03/15 09:20:10 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -92,7 +92,7 @@ UFS_WAPBL_JUNLOCK_ASSERT(vp-v_mount); transmp = vp-v_mount; - fstrans_start(transmp, FSTRANS_SHARED); + fstrans_start(transmp, FSTRANS_LAZY); /* * Ignore inodes related to stale file handles. */
CVS commit: src/sys/net
Module Name:src Committed By: hannken Date: Sat May 30 09:04:35 UTC 2009 Modified Files: src/sys/net: Makefile Log Message: No need to include bsd.subdir.mk as bsd.kinc.mk already includes it. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/net/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/Makefile diff -u src/sys/net/Makefile:1.26 src/sys/net/Makefile:1.27 --- src/sys/net/Makefile:1.26 Tue May 26 21:58:31 2009 +++ src/sys/net/Makefile Sat May 30 09:04:35 2009 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.26 2009/05/26 21:58:31 pooka Exp $ +# $NetBSD: Makefile,v 1.27 2009/05/30 09:04:35 hannken Exp $ INCSDIR= /usr/include/net @@ -12,7 +12,6 @@ SUBDIR= agr -.include bsd.subdir.mk .include bsd.kinc.mk .PATH: ${NETBSDSRCDIR}/sys/dist/pf/net
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Sat May 30 13:54:36 UTC 2009 Modified Files: src/sys/ufs/ufs: ufs_dirhash.c Log Message: ufsdirhash_lookup(): call ufs_blkatoff() with modify == false. This buffer is used read-only here and from caller. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/ufs/ufs/ufs_dirhash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_dirhash.c diff -u src/sys/ufs/ufs/ufs_dirhash.c:1.32 src/sys/ufs/ufs/ufs_dirhash.c:1.33 --- src/sys/ufs/ufs/ufs_dirhash.c:1.32 Wed May 6 16:43:47 2009 +++ src/sys/ufs/ufs/ufs_dirhash.c Sat May 30 13:54:36 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.32 2009/05/06 16:43:47 rmind Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.33 2009/05/30 13:54:36 hannken Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. @@ -28,7 +28,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ufs_dirhash.c,v 1.32 2009/05/06 16:43:47 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: ufs_dirhash.c,v 1.33 2009/05/30 13:54:36 hannken Exp $); /* * This implements a hash-based lookup scheme for UFS directories. @@ -416,7 +416,7 @@ brelse(bp, 0); blkoff = offset ~bmask; if (ufs_blkatoff(vp, (off_t)blkoff, - NULL, bp, true) != 0) { + NULL, bp, false) != 0) { DIRHASH_UNLOCK(dh); return (EJUSTRETURN); }
CVS commit: src/sys/dev/pci
Module Name:src Committed By: hannken Date: Thu Feb 10 13:52:36 UTC 2011 Modified Files: src/sys/dev/pci: alipm.c ichsmb.c piixpm.c Log Message: Make the SMbus Send/Receive functions work. If cmdlen = 0 and len = 1 use the XXX_HC_CMD_BYTE protocol, send data through XXX_SMB_HCMD or receive data from XXX_SMB_HD0. Ok: Paul Goyette To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/alipm.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/pci/ichsmb.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/piixpm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/alipm.c diff -u src/sys/dev/pci/alipm.c:1.7 src/sys/dev/pci/alipm.c:1.8 --- src/sys/dev/pci/alipm.c:1.7 Thu Mar 11 04:00:36 2010 +++ src/sys/dev/pci/alipm.c Thu Feb 10 13:52:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: alipm.c,v 1.7 2010/03/11 04:00:36 mrg Exp $ */ +/* $NetBSD: alipm.c,v 1.8 2011/02/10 13:52:36 hannken Exp $ */ /* $OpenBSD: alipm.c,v 1.13 2007/05/03 12:19:01 dlg Exp $ */ /* @@ -18,7 +18,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: alipm.c,v 1.7 2010/03/11 04:00:36 mrg Exp $); +__KERNEL_RCSID(0, $NetBSD: alipm.c,v 1.8 2011/02/10 13:52:36 hannken Exp $); #include sys/param.h #include sys/device.h @@ -255,7 +255,8 @@ flags 0x%x\n, device_xname(sc-sc_dev), op, addr, cmdlen, len, flags)); - if (!I2C_OP_STOP_P(op) || cmdlen 1 || len 2) + if (!I2C_OP_STOP_P(op) || cmdlen 1 || len 2 || + (cmdlen == 0 len 1)) return (EOPNOTSUPP); /* Clear status bits */ @@ -298,7 +299,10 @@ if (I2C_OP_WRITE_P(op)) { /* Write data. */ b = buf; - if (len 0) + if (cmdlen == 0 len == 1) + bus_space_write_1(sc-sc_iot, sc-sc_ioh, + ALIPM_SMB_HCMD, b[0]); + else if (len 0) bus_space_write_1(sc-sc_iot, sc-sc_ioh, ALIPM_SMB_HD0, b[0]); if (len 1) @@ -307,8 +311,8 @@ } /* Set SMBus command */ - if (len == 0) { - if (cmdlen == 0) + if (cmdlen == 0) { + if (len == 0) ctl = ALIPM_SMB_HC_CMD_QUICK; else ctl = ALIPM_SMB_HC_CMD_BYTE; Index: src/sys/dev/pci/ichsmb.c diff -u src/sys/dev/pci/ichsmb.c:1.23 src/sys/dev/pci/ichsmb.c:1.24 --- src/sys/dev/pci/ichsmb.c:1.23 Fri Jul 30 15:28:09 2010 +++ src/sys/dev/pci/ichsmb.c Thu Feb 10 13:52:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ichsmb.c,v 1.23 2010/07/30 15:28:09 njoly Exp $ */ +/* $NetBSD: ichsmb.c,v 1.24 2011/02/10 13:52:36 hannken Exp $ */ /* $OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $ */ /* @@ -22,7 +22,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ichsmb.c,v 1.23 2010/07/30 15:28:09 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: ichsmb.c,v 1.24 2011/02/10 13:52:36 hannken Exp $); #include sys/param.h #include sys/device.h @@ -238,7 +238,8 @@ if (cold || sc-sc_poll) flags |= I2C_F_POLL; - if (!I2C_OP_STOP_P(op) || cmdlen 1 || len 2) + if (!I2C_OP_STOP_P(op) || cmdlen 1 || len 2 || + (cmdlen == 0 len 1)) return (1); /* Setup transfer */ @@ -261,7 +262,10 @@ if (I2C_OP_WRITE_P(op)) { /* Write data */ b = buf; - if (len 0) + if (cmdlen == 0 len == 1) + bus_space_write_1(sc-sc_iot, sc-sc_ioh, + LPCIB_SMB_HCMD, b[0]); + else if (len 0) bus_space_write_1(sc-sc_iot, sc-sc_ioh, LPCIB_SMB_HD0, b[0]); if (len 1) @@ -270,8 +274,8 @@ } /* Set SMBus command */ - if (len == 0) { - if (cmdlen == 0) + if (cmdlen == 0) { + if (len == 0) ctl = LPCIB_SMB_HC_CMD_QUICK; else ctl = LPCIB_SMB_HC_CMD_BYTE; Index: src/sys/dev/pci/piixpm.c diff -u src/sys/dev/pci/piixpm.c:1.33 src/sys/dev/pci/piixpm.c:1.34 --- src/sys/dev/pci/piixpm.c:1.33 Tue Jul 27 05:29:05 2010 +++ src/sys/dev/pci/piixpm.c Thu Feb 10 13:52:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: piixpm.c,v 1.33 2010/07/27 05:29:05 jakllsch Exp $ */ +/* $NetBSD: piixpm.c,v 1.34 2011/02/10 13:52:36 hannken Exp $ */ /* $OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $ */ /* @@ -22,7 +22,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: piixpm.c,v 1.33 2010/07/27 05:29:05 jakllsch Exp $); +__KERNEL_RCSID(0, $NetBSD: piixpm.c,v 1.34 2011/02/10 13:52:36 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -316,7 +316,8 @@ if (cold || sc-sc_poll) flags |= I2C_F_POLL; - if (!I2C_OP_STOP_P(op) || cmdlen 1 || len 2) + if (!I2C_OP_STOP_P(op) || cmdlen 1 || len 2 || + (cmdlen == 0 len 1)) return (1); /* Setup transfer */ @@ -340,7 +341,10 @@ if (I2C_OP_WRITE_P(op)) { /* Write data */ b = buf; - if (len 0) + if (cmdlen == 0 len == 1) + bus_space_write_1(sc-sc_smb_iot, sc-sc_smb_ioh, + PIIX_SMB_HCMD, b[0]); + else if (len 0) bus_space_write_1(sc-sc_smb_iot, sc-sc_smb_ioh, PIIX_SMB_HD0, b[0]); if (len 1) @@ -349,8 +353,8 @@ } /* Set SMBus command */ - if (len == 0) { - if (cmdlen == 0) + if (cmdlen == 0) { + if (len == 0) ctl = PIIX_SMB_HC_CMD_QUICK; else
CVS commit: src/sys/dev/pci
Module Name:src Committed By: hannken Date: Sun Feb 13 11:20:12 UTC 2011 Modified Files: src/sys/dev/pci: piixpm.c piixpmreg.h Log Message: The ServerWorks CSB5 smbus controller often times out and hangs until reboot. Increase the delay between setting the command register and reading the status register. Reset the smbus controller if it has timed out. Tested on an IBM eServer x335. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/piixpm.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/piixpmreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/piixpm.c diff -u src/sys/dev/pci/piixpm.c:1.34 src/sys/dev/pci/piixpm.c:1.35 --- src/sys/dev/pci/piixpm.c:1.34 Thu Feb 10 13:52:36 2011 +++ src/sys/dev/pci/piixpm.c Sun Feb 13 11:20:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: piixpm.c,v 1.34 2011/02/10 13:52:36 hannken Exp $ */ +/* $NetBSD: piixpm.c,v 1.35 2011/02/13 11:20:12 hannken Exp $ */ /* $OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $ */ /* @@ -22,7 +22,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: piixpm.c,v 1.34 2011/02/10 13:52:36 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: piixpm.c,v 1.35 2011/02/13 11:20:12 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -49,6 +49,9 @@ #define DPRINTF(x) #endif +#define PIIXPM_IS_CSB5(id) \ + (PCI_VENDOR((id)) == PCI_VENDOR_SERVERWORKS \ + PCI_PRODUCT((id)) == PCI_PRODUCT_SERVERWORKS_CSB5) #define PIIXPM_DELAY 200 #define PIIXPM_TIMEOUT 1 @@ -65,6 +68,7 @@ pci_chipset_tag_t sc_pc; pcitag_t sc_pcitag; + pcireg_t sc_id; struct i2c_controller sc_i2c_tag; krwlock_t sc_i2c_rwlock; @@ -85,6 +89,7 @@ static bool piixpm_suspend(device_t, const pmf_qual_t *); static bool piixpm_resume(device_t, const pmf_qual_t *); +static void piixpm_csb5_reset(void *); static int piixpm_i2c_acquire_bus(void *, int); static void piixpm_i2c_release_bus(void *, int); static int piixpm_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, @@ -144,6 +149,7 @@ const char *intrstr = NULL; sc-sc_dev = self; + sc-sc_id = pa-pa_id; sc-sc_pc = pa-pa_pc; sc-sc_pcitag = pa-pa_tag; @@ -266,6 +272,27 @@ return true; } +static void +piixpm_csb5_reset(void *arg) +{ + struct piixpm_softc *sc = arg; + pcireg_t base, hostc, pmbase; + + base = pci_conf_read(sc-sc_pc, sc-sc_pcitag, PIIX_SMB_BASE); + hostc = pci_conf_read(sc-sc_pc, sc-sc_pcitag, PIIX_SMB_HOSTC); + + pmbase = pci_conf_read(sc-sc_pc, sc-sc_pcitag, PIIX_PM_BASE); + pmbase |= PIIX_PM_BASE_CSB5_RESET; + pci_conf_write(sc-sc_pc, sc-sc_pcitag, PIIX_PM_BASE, pmbase); + pmbase = ~PIIX_PM_BASE_CSB5_RESET; + pci_conf_write(sc-sc_pc, sc-sc_pcitag, PIIX_PM_BASE, pmbase); + + pci_conf_write(sc-sc_pc, sc-sc_pcitag, PIIX_SMB_BASE, base); + pci_conf_write(sc-sc_pc, sc-sc_pcitag, PIIX_SMB_HOSTC, hostc); + + (void) tsleep(sc, PRIBIO, csb5reset, hz/2); +} + static int piixpm_i2c_acquire_bus(void *cookie, int flags) { @@ -372,7 +399,10 @@ if (flags I2C_F_POLL) { /* Poll for completion */ - DELAY(PIIXPM_DELAY); + if (PIIXPM_IS_CSB5(sc-sc_id)) + DELAY(2*PIIXPM_DELAY); + else + DELAY(PIIXPM_DELAY); for (retries = 1000; retries 0; retries--) { st = bus_space_read_1(sc-sc_smb_iot, sc-sc_smb_ioh, PIIX_SMB_HS); @@ -406,6 +436,11 @@ if ((st PIIX_SMB_HS_FAILED) == 0) aprint_error_dev(sc-sc_dev, transaction abort failed, status 0x%x\n, st); bus_space_write_1(sc-sc_smb_iot, sc-sc_smb_ioh, PIIX_SMB_HS, st); + /* + * CSB5 needs hard reset to unlock the smbus after timeout. + */ + if (PIIXPM_IS_CSB5(sc-sc_id)) + piixpm_csb5_reset(sc); return (1); } Index: src/sys/dev/pci/piixpmreg.h diff -u src/sys/dev/pci/piixpmreg.h:1.4 src/sys/dev/pci/piixpmreg.h:1.5 --- src/sys/dev/pci/piixpmreg.h:1.4 Mon Jun 26 17:33:40 2006 +++ src/sys/dev/pci/piixpmreg.h Sun Feb 13 11:20:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: piixpmreg.h,v 1.4 2006/06/26 17:33:40 drochner Exp $ */ +/* $NetBSD: piixpmreg.h,v 1.5 2011/02/13 11:20:12 hannken Exp $ */ /* $OpenBSD: piixreg.h,v 1.3 2006/01/03 22:39:03 grange Exp $ */ /* @@ -30,6 +30,7 @@ /* PCI configuration registers */ #define PIIX_PM_BASE 0x40 /* Power management base address */ +#define PIIX_PM_BASE_CSB5_RESET 0x10 /* CSB5 PM reset */ #define PIIX_DEVACTA 0x54 /* Device activity A (function 3) */ #define PIIX_DEVACTB 0x58 /* Device activity B (function 3) */ #define PIIX_PMREGMISC 0x80 /* Misc. Power management */
CVS commit: src
--- src/sys/arch/i386/conf/ALL:1.286 Fri Feb 11 01:59:56 2011 +++ src/sys/arch/i386/conf/ALL Mon Feb 14 08:50:39 2011 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.286 2011/02/11 01:59:56 jmcneill Exp $ +# $NetBSD: ALL,v 1.287 2011/02/14 08:50:39 hannken Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident ALL-$Revision: 1.286 $ +#ident ALL-$Revision: 1.287 $ maxusers 64 # estimated number of users @@ -708,6 +708,9 @@ dbcool* at iic? addr 0x2D # Tyan S2881 dbcool* at iic? addr 0x2E # Tyan S2882-D +# IBM Hawk Integrated Systems Management Processor +ibmhawk0 at iic? addr 0x37 + # LM7[89] and compatible hardware monitors # Use flags to select temp sensor type (see lm(4) man page for details) lm0 at iic? addr 0x2e flags 0x0 Index: src/sys/arch/i386/conf/GENERIC diff -u src/sys/arch/i386/conf/GENERIC:1.1013 src/sys/arch/i386/conf/GENERIC:1.1014 --- src/sys/arch/i386/conf/GENERIC:1.1013 Sun Feb 13 04:37:21 2011 +++ src/sys/arch/i386/conf/GENERIC Mon Feb 14 08:50:39 2011 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.1013 2011/02/13 04:37:21 jym Exp $ +# $NetBSD: GENERIC,v 1.1014 2011/02/14 08:50:39 hannken Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident GENERIC-$Revision: 1.1013 $ +#ident GENERIC-$Revision: 1.1014 $ maxusers 64 # estimated number of users @@ -678,6 +678,9 @@ #wbsio* at isa? port 0x2e #wbsio* at isa? port 0x4e +# IBM Hawk Integrated Systems Management Processor +#ibmhawk0 at iic? addr 0x37 + # LM7[89] and compatible hardware monitors # Use flags to select temp sensor type (see lm(4) man page for details) #lm0 at isa? port 0x290 flags 0x0 # other common: 0x280, 0x310 Index: src/sys/dev/i2c/files.i2c diff -u src/sys/dev/i2c/files.i2c:1.32 src/sys/dev/i2c/files.i2c:1.33 --- src/sys/dev/i2c/files.i2c:1.32 Fri Jan 21 19:11:47 2011 +++ src/sys/dev/i2c/files.i2c Mon Feb 14 08:50:39 2011 @@ -1,4 +1,4 @@ -# $NetBSD: files.i2c,v 1.32 2011/01/21 19:11:47 jakllsch Exp $ +# $NetBSD: files.i2c,v 1.33 2011/02/14 08:50:39 hannken Exp $ defflag opt_i2cbus.hI2C_SCAN define i2cbus { } @@ -145,3 +145,8 @@ device g760a: sysmon_envsys attach g760a at iic file dev/i2c/g760a.c g760a + +# IBM Hawk Integrated Systems Management Processor +device ibmhawk: sysmon_envsys +attach ibmhawk at iic +file dev/i2c/ibmhawk.c ibmhawk Added files: Index: src/share/man/man4/ibmhawk.4 diff -u /dev/null src/share/man/man4/ibmhawk.4:1.1 --- /dev/null Mon Feb 14 08:50:40 2011 +++ src/share/man/man4/ibmhawk.4 Mon Feb 14 08:50:39 2011 @@ -0,0 +1,58 @@ +.\ $NetBSD: ibmhawk.4,v 1.1 2011/02/14 08:50:39 hannken Exp $ +.\ +.\ Copyright (c) 2011 The NetBSD Foundation, Inc. +.\ All rights reserved. +.\ +.\ This code is derived from software contributed to The NetBSD Foundation +.\ by Juergen Hannken-Illjes. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\ POSSIBILITY OF SUCH DAMAGE. +.\ +.Dd February 14, 2011 +.Dt IBMHAWK 4 +.Os +.Sh NAME +.Nm ibmhawk +.Nd IBM Hawk Integrated Systems Management Processor +.Sh SYNOPSUS +.Cd ibmhawk0 at iic? +.Sh DESCRIPTION +The +.Nm +driver provides support for the temperature, voltage and +fan sensors present on IBM eServers equipped with an on-board +Hawk Integrated Systems Management Processor. +.Pp +The +.Nm +driver reports these sensors through the +.Xr envsys 4 +API. +.Sh SEE ALSO +.Xr envsys 4 , +.Xr envstat 8 , +.Xr powerd 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Nx 6.0 . Index: src/sys/dev/i2c/ibmhawk.c diff -u /dev/null src/sys/dev/i2c/ibmhawk.c:1.1 --- /dev/null Mon Feb 14 08:50:40 2011
CVS commit: src/sys/dev/i2c
Module Name:src Committed By: hannken Date: Mon Feb 14 14:15:25 UTC 2011 Modified Files: src/sys/dev/i2c: ibmhawk.c Log Message: ibmhawk_set: No need to set states ENVSYS_SWARNxxx, sysmon will do it. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/ibmhawk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/i2c/ibmhawk.c diff -u src/sys/dev/i2c/ibmhawk.c:1.1 src/sys/dev/i2c/ibmhawk.c:1.2 --- src/sys/dev/i2c/ibmhawk.c:1.1 Mon Feb 14 08:50:39 2011 +++ src/sys/dev/i2c/ibmhawk.c Mon Feb 14 14:15:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ibmhawk.c,v 1.1 2011/02/14 08:50:39 hannken Exp $ */ +/* $NetBSD: ibmhawk.c,v 1.2 2011/02/14 14:15:25 hannken Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -318,15 +318,11 @@ failed to attach \%s\\n, dp-desc); } - dp-value_cur = ibmhawk_normalize(value, dp-units); - if (!valid) - dp-state = ENVSYS_SINVALID; - else if (sd-ihs_warnmin != 0 value sd-ihs_warnmin) - dp-state = ENVSYS_SWARNUNDER; - else if (sd-ihs_warnmax != 0 value sd-ihs_warnmax) - dp-state = ENVSYS_SWARNOVER; - else + if (valid) { + dp-value_cur = ibmhawk_normalize(value, dp-units); dp-state = ENVSYS_SVALID; + } else + dp-state = ENVSYS_SINVALID; } static void
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Feb 16 19:43:06 UTC 2011 Modified Files: src/sys/kern: vfs_wapbl.c Log Message: Set the limit for deallocations in one transaction to a more realistic (and much lower) value. When flushing the log these deallocations will produce new blocks and that may execeed the journal size resulting in a wapbl_flush: current transaction too big to flush panic. Seen when removing a large snapshot. Adresses PR #44568 (WAPBL doens't play nice with snapshots). To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/kern/vfs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_wapbl.c diff -u src/sys/kern/vfs_wapbl.c:1.40 src/sys/kern/vfs_wapbl.c:1.41 --- src/sys/kern/vfs_wapbl.c:1.40 Mon Feb 14 16:05:11 2011 +++ src/sys/kern/vfs_wapbl.c Wed Feb 16 19:43:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_wapbl.c,v 1.40 2011/02/14 16:05:11 bouyer Exp $ */ +/* $NetBSD: vfs_wapbl.c,v 1.41 2011/02/16 19:43:05 hannken Exp $ */ /*- * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #define WAPBL_INTERNAL #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_wapbl.c,v 1.40 2011/02/14 16:05:11 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_wapbl.c,v 1.41 2011/02/16 19:43:05 hannken Exp $); #include sys/param.h #include sys/bitops.h @@ -479,7 +479,7 @@ wl-wl_bufcount_max = (nbuf / 2) * 1024; /* XXX tie this into resource estimation */ - wl-wl_dealloclim = 2 * btodb(wl-wl_bufbytes_max); + wl-wl_dealloclim = wl-wl_bufbytes_max / mp-mnt_stat.f_bsize / 2; wl-wl_deallocblks = wapbl_malloc(sizeof(*wl-wl_deallocblks) * wl-wl_dealloclim);
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Wed Feb 16 19:43:50 UTC 2011 Modified Files: src/sys/ufs/ffs: ffs_snapshot.c Log Message: Refine the scope of WAPBL transactions so we should no longer get a wapbl_flush: current transaction too big to flush panic when creating or removing snapshots on larger logging disks. Adresses PR #44568 (WAPBL doens't play nice with snapshots). To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/ufs/ffs/ffs_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.102 src/sys/ufs/ffs/ffs_snapshot.c:1.103 --- src/sys/ufs/ffs/ffs_snapshot.c:1.102 Mon Dec 20 00:25:47 2010 +++ src/sys/ufs/ffs/ffs_snapshot.c Wed Feb 16 19:43:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.102 2010/12/20 00:25:47 matt Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.103 2011/02/16 19:43:50 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.102 2010/12/20 00:25:47 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.103 2011/02/16 19:43:50 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -114,6 +114,7 @@ static int rwfsblk(struct vnode *, int, void *, daddr_t); static int syncsnap(struct vnode *); static int wrsnapblk(struct vnode *, void *, daddr_t); +static int blocks_in_journal(struct fs *); static inline bool is_active_snapshot(struct snap_info *, struct inode *); static inline daddr_t db_get(struct inode *, int); @@ -403,11 +404,12 @@ static int snapshot_setup(struct mount *mp, struct vnode *vp) { - int error, i, len, loc; + int error, n, len, loc; daddr_t blkno, numblks; struct buf *ibp, *nbp; struct fs *fs = VFSTOUFS(mp)-um_fs; struct lwp *l = curlwp; + const int wbreak = blocks_in_journal(fs)/8; /* * Check mount, exclusive reference and owner. @@ -452,13 +454,13 @@ error = UFS_WAPBL_BEGIN(mp); if (error) return error; - for (blkno = NDADDR, i = 0; blkno numblks; blkno += NINDIR(fs)) { + for (blkno = NDADDR, n = 0; blkno numblks; blkno += NINDIR(fs)) { error = ffs_balloc(vp, lblktosize(fs, (off_t)blkno), fs-fs_bsize, l-l_cred, B_METAONLY, ibp); if (error) goto out; brelse(ibp, 0); - if ((++i % 16) == 0) { + if (wbreak 0 (++n % wbreak) == 0) { UFS_WAPBL_END(mp); error = UFS_WAPBL_BEGIN(mp); if (error) @@ -561,7 +563,6 @@ snapshot_expunge(struct mount *mp, struct vnode *vp, struct fs *copy_fs, daddr_t *snaplistsize, daddr_t **snaplist) { - bool has_wapbl = false; int cg, error, len, loc; daddr_t blkno, *blkp; struct fs *fs = VFSTOUFS(mp)-um_fs; @@ -593,10 +594,6 @@ */ *snaplistsize = fs-fs_ncg + howmany(fs-fs_cssize, fs-fs_bsize) + FSMAXSNAP + 1 /* superblock */ + 1 /* last block */ + 1 /* size */; - error = UFS_WAPBL_BEGIN(mp); - if (error) - goto out; - has_wapbl = true; mutex_enter(mntvnode_lock); /* * NOTE: not using the TAILQ_FOREACH here since in this loop vgone() @@ -648,19 +645,30 @@ if (loc NDADDR) { len = fragroundup(fs, blkoff(fs, xp-i_size)); if (len 0 len fs-fs_bsize) { +error = UFS_WAPBL_BEGIN(mp); +if (error) { + (void)vunmark(mvp); + goto out; +} ffs_blkfree_snap(copy_fs, vp, db_get(xp, loc), len, xp-i_number); blkno = db_get(xp, loc); db_assign(xp, loc, 0); +UFS_WAPBL_END(mp); } } *snaplistsize += 1; error = expunge(vp, xp, copy_fs, fullacct, BLK_NOCOPY); if (blkno) db_assign(xp, loc, blkno); - if (!error) - error = ffs_freefile_snap(copy_fs, vp, xp-i_number, - xp-i_mode); + if (!error) { + error = UFS_WAPBL_BEGIN(mp); + if (!error) { +error = ffs_freefile_snap(copy_fs, vp, +xp-i_number, xp-i_mode); +UFS_WAPBL_END(mp); + } + } if (error) { (void)vunmark(mvp); goto out; @@ -688,8 +696,6 @@ (*snaplist)[0] = blkp - (*snaplist)[0]; out: - if (has_wapbl) - UFS_WAPBL_END(mp); if (mvp != NULL) vnfree(mvp); if (logvp != NULL) @@ -711,16 +717,13 @@ snapshot_expunge_snap(struct mount *mp, struct vnode *vp, struct fs *copy_fs, daddr_t snaplistsize) { - int error, i; + int error = 0, i; daddr_t numblks, *snaplist = NULL; struct fs *fs = VFSTOUFS(mp)-um_fs; struct inode *ip = VTOI(vp), *xp; struct lwp *l = curlwp; struct snap_info *si = VFSTOUFS(mp)-um_snapinfo; - error = UFS_WAPBL_BEGIN(mp); - if (error) - return error; TAILQ_FOREACH(xp, si-si_snapshots, i_nextsnap) { if (xp == ip) break; @@ -729,7 +732,11 @@ break; if (xp-i_nlink != 0) continue; + error = UFS_WAPBL_BEGIN(mp); + if (error) + break; error = ffs_freefile_snap(copy_fs, vp, xp-i_number, xp-i_mode); + UFS_WAPBL_END(mp); if (error) break; } @@ -761,12 +768,10 @@
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Fri Feb 18 08:39:13 UTC 2011 Modified Files: src/sys/ufs/ffs: ffs_snapshot.c Log Message: Revert rev. 1.101. Dead snapshots would hang around until unmount. Adresses PR #44568 (WAPBL doens't play nice with snapshots). To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/sys/ufs/ffs/ffs_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.103 src/sys/ufs/ffs/ffs_snapshot.c:1.104 --- src/sys/ufs/ffs/ffs_snapshot.c:1.103 Wed Feb 16 19:43:50 2011 +++ src/sys/ufs/ffs/ffs_snapshot.c Fri Feb 18 08:39:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.103 2011/02/16 19:43:50 hannken Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.104 2011/02/18 08:39:13 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.103 2011/02/16 19:43:50 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.104 2011/02/18 08:39:13 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -280,7 +280,6 @@ fs-fs_snapinum[snaploc] = ip-i_number; mutex_enter(si-si_lock); - vref(vp); if (is_active_snapshot(si, ip)) panic(ffs_snapshot: %PRIu64 already on list, ip-i_number); TAILQ_INSERT_TAIL(si-si_snapshots, ip, i_nextsnap); @@ -394,7 +393,8 @@ (void) ffs_truncate(vp, (off_t)0, 0, NOCRED); UFS_WAPBL_END(mp); } - } + } else + vref(vp); return (error); } @@ -1313,8 +1313,10 @@ if (xp == ip) break; mutex_exit(si-si_lock); + if (xp != NULL) + vrele(ITOV(ip)); #ifdef DEBUG - if (snapdebug xp == NULL) + else if (snapdebug) printf(ffs_snapgone: lost snapshot vnode %llu\n, (unsigned long long)ip-i_number); #endif @@ -1382,7 +1384,6 @@ free(ip-i_snapblklist, M_UFSMNT); ip-i_snapblklist = NULL; } - vrele(vp); } else mutex_exit(si-si_lock); /* @@ -1763,25 +1764,28 @@ ffs_snapshot_unmount(struct mount *mp) { struct vnode *devvp = VFSTOUFS(mp)-um_devvp; - struct inode *ip; + struct inode *xp; + struct vnode *vp = NULL; struct snap_info *si; - bool list_empty = true; si = VFSTOUFS(mp)-um_snapinfo; mutex_enter(si-si_lock); - while ((ip = TAILQ_FIRST(si-si_snapshots)) != 0) { - list_empty = false; - TAILQ_REMOVE(si-si_snapshots, ip, i_nextsnap); - if (ip-i_snapblklist == si-si_snapblklist) + while ((xp = TAILQ_FIRST(si-si_snapshots)) != 0) { + vp = ITOV(xp); + TAILQ_REMOVE(si-si_snapshots, xp, i_nextsnap); + if (xp-i_snapblklist == si-si_snapblklist) si-si_snapblklist = NULL; - free(ip-i_snapblklist, M_UFSMNT); - si-si_gen++; - mutex_exit(si-si_lock); - vrele(ITOV(ip)); - mutex_enter(si-si_lock); + free(xp-i_snapblklist, M_UFSMNT); + if (xp-i_nlink 0) { + si-si_gen++; + mutex_exit(si-si_lock); + vrele(vp); + mutex_enter(si-si_lock); + } } + si-si_gen++; mutex_exit(si-si_lock); - if (! list_empty) + if (vp) fscow_disestablish(mp, ffs_copyonwrite, devvp); }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Feb 18 13:24:40 UTC 2011 Modified Files: src/sys/kern: vfs_wapbl.c Log Message: Adjust previous: set the dealloc soft limit to half hard limit. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/kern/vfs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_wapbl.c diff -u src/sys/kern/vfs_wapbl.c:1.41 src/sys/kern/vfs_wapbl.c:1.42 --- src/sys/kern/vfs_wapbl.c:1.41 Wed Feb 16 19:43:05 2011 +++ src/sys/kern/vfs_wapbl.c Fri Feb 18 13:24:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_wapbl.c,v 1.41 2011/02/16 19:43:05 hannken Exp $ */ +/* $NetBSD: vfs_wapbl.c,v 1.42 2011/02/18 13:24:40 hannken Exp $ */ /*- * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #define WAPBL_INTERNAL #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_wapbl.c,v 1.41 2011/02/16 19:43:05 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_wapbl.c,v 1.42 2011/02/18 13:24:40 hannken Exp $); #include sys/param.h #include sys/bitops.h @@ -852,8 +852,7 @@ ((wl-wl_bufcount + (lockcount * 10)) wl-wl_bufcount_max / 2) || (wapbl_transaction_len(wl) wl-wl_circ_size / 2) || - (wl-wl_dealloccnt = - (wl-wl_dealloclim - (wl-wl_dealloclim 8))); + (wl-wl_dealloccnt = (wl-wl_dealloclim / 2)); mutex_exit(wl-wl_mtx); if (doflush) {
CVS commit: src/sys/ddb
Module Name:src Committed By: hannken Date: Sun Feb 20 10:24:45 UTC 2011 Modified Files: src/sys/ddb: db_cpu.c Log Message: When looking for the next element of cpu_queue compare the pointer to the address of the head, not to the head itself. Not sure if the cast of the arg to db_value_name() is right, but works on i386 and compiles on sparc64. Stack traces from ddb work again on i386. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ddb/db_cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_cpu.c diff -u src/sys/ddb/db_cpu.c:1.3 src/sys/ddb/db_cpu.c:1.4 --- src/sys/ddb/db_cpu.c:1.3 Mon Mar 9 06:07:05 2009 +++ src/sys/ddb/db_cpu.c Sun Feb 20 10:24:45 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: db_cpu.c,v 1.3 2009/03/09 06:07:05 mrg Exp $ */ +/* $NetBSD: db_cpu.c,v 1.4 2011/02/20 10:24:45 hannken Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: db_cpu.c,v 1.3 2009/03/09 06:07:05 mrg Exp $); +__KERNEL_RCSID(0, $NetBSD: db_cpu.c,v 1.4 2011/02/20 10:24:45 hannken Exp $); #ifndef _KERNEL #include stdbool.h @@ -43,12 +43,14 @@ #include ddb/ddb.h static struct cpu_info *head; +static void *head_addr; struct cpu_info * db_cpu_first(void) { head = db_read_ptr(cpu_queue); + (void) db_value_of_name(cpu_queue, (db_expr_t *)head_addr); return head; } @@ -58,7 +60,7 @@ db_read_bytes((db_addr_t)ci-ci_data.cpu_qchain.cqe_next, sizeof(ci), (char *)ci); - if (ci == head) { + if (ci == head_addr) { ci = NULL; } return ci;
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Mon Feb 21 09:29:21 UTC 2011 Modified Files: src/sys/ufs/ffs: ffs_snapshot.c Log Message: Change the snapshot lock: - No need to take the snapshot lock while the file system is suspended. - Allow ffs_copyonwrite() one level of recursion with snapshots locked. - Do the block address lookup with snapshots locked. - Take the snapshot lock while removing a snapshot from the list. While hunting deadlocks change the transaction scope for ffs_snapremove(). We could deadlock from UFS_WAPBL_BEGIN() with a buffer held. To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/sys/ufs/ffs/ffs_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.105 src/sys/ufs/ffs/ffs_snapshot.c:1.106 --- src/sys/ufs/ffs/ffs_snapshot.c:1.105 Fri Feb 18 14:48:54 2011 +++ src/sys/ufs/ffs/ffs_snapshot.c Mon Feb 21 09:29:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.105 2011/02/18 14:48:54 bouyer Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.106 2011/02/21 09:29:21 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.105 2011/02/18 14:48:54 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.106 2011/02/21 09:29:21 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -79,6 +79,7 @@ struct snap_info { kmutex_t si_lock; /* Lock this snapinfo */ kmutex_t si_snaplock; /* Snapshot vnode common lock */ + lwp_t *si_owner; /* Sanplock owner */ TAILQ_HEAD(inodelst, inode) si_snapshots; /* List of active snapshots */ daddr_t *si_snapblklist; /* Snapshot block hints list */ uint32_t si_gen; /* Incremented on change */ @@ -140,6 +141,7 @@ TAILQ_INIT(si-si_snapshots); mutex_init(si-si_lock, MUTEX_DEFAULT, IPL_NONE); mutex_init(si-si_snaplock, MUTEX_DEFAULT, IPL_NONE); + si-si_owner = NULL; si-si_gen = 0; si-si_snapblklist = NULL; @@ -173,7 +175,6 @@ } #else /* defined(FFS_NO_SNAPSHOT) */ bool suspended = false; - bool snapshot_locked = false; int error, redo = 0, snaploc; void *sbbuf = NULL; daddr_t *snaplist = NULL, snaplistsize = 0; @@ -269,11 +270,6 @@ if (error) goto out; /* - * Acquire the snapshot lock. - */ - mutex_enter(si-si_snaplock); - snapshot_locked = true; - /* * Record snapshot inode. Since this is the newest snapshot, * it must be placed at the end of the list. */ @@ -376,8 +372,6 @@ si-si_gen++; mutex_exit(si-si_lock); - if (snapshot_locked) - mutex_exit(si-si_snaplock); if (suspended) { vfs_resume(vp-v_mount); #ifdef DEBUG @@ -1354,8 +1348,7 @@ struct snap_info *si; struct lwp *l = curlwp; daddr_t numblks, blkno, dblk; - int error, loc, last, n; - const int wbreak = blocks_in_journal(fs)/8; + int error, loc, last; si = VFSTOUFS(mp)-um_snapinfo; /* @@ -1365,6 +1358,7 @@ * * Clear copy-on-write flag if last snapshot. */ + mutex_enter(si-si_snaplock); mutex_enter(si-si_lock); if (is_active_snapshot(si, ip)) { TAILQ_REMOVE(si-si_snapshots, ip, i_nextsnap); @@ -1374,18 +1368,22 @@ si-si_snapblklist = xp-i_snapblklist; si-si_gen++; mutex_exit(si-si_lock); + mutex_exit(si-si_snaplock); } else { si-si_snapblklist = 0; si-si_gen++; mutex_exit(si-si_lock); + mutex_exit(si-si_snaplock); fscow_disestablish(mp, ffs_copyonwrite, devvp); } if (ip-i_snapblklist != NULL) { free(ip-i_snapblklist, M_UFSMNT); ip-i_snapblklist = NULL; } - } else + } else { mutex_exit(si-si_lock); + mutex_exit(si-si_snaplock); + } /* * Clear all BLK_NOCOPY fields. Pass any block claims to other * snapshots that want them (see ffs_snapblkfree below). @@ -1402,7 +1400,7 @@ } } numblks = howmany(ip-i_size, fs-fs_bsize); - for (blkno = NDADDR, n = 0; blkno numblks; blkno += NINDIR(fs)) { + for (blkno = NDADDR; blkno numblks; blkno += NINDIR(fs)) { error = ffs_balloc(vp, lblktosize(fs, (off_t)blkno), fs-fs_bsize, l-l_cred, B_METAONLY, ibp); if (error) @@ -1412,12 +1410,6 @@ else last = fs-fs_size - blkno; for (loc = 0; loc last; loc++) { - if (wbreak 0 (++n % wbreak) == 0) { -UFS_WAPBL_END(mp); -error = UFS_WAPBL_BEGIN(mp); -if (error) - panic(UFS_WAPBL_BEGIN failed); - } dblk = idb_get(ip, ibp-b_data, loc); if (dblk == BLK_NOCOPY || dblk == BLK_SNAP) idb_assign(ip, ibp-b_data, loc, 0); @@ -1429,6 +1421,9 @@ } } bawrite(ibp); + UFS_WAPBL_END(mp); + error = UFS_WAPBL_BEGIN(mp); + KASSERT(error == 0); } /* * Clear snapshot flag and drop reference. @@ -1469,25 +1464,18 @@ daddr_t lbn; daddr_t blkno; uint32_t gen; - int indiroff = 0, snapshot_locked = 0, error = 0, claimedblk = 0; + int indiroff = 0, error = 0, claimedblk =
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Wed Feb 23 08:53:22 UTC 2011 Modified Files: src/sys/ufs/ffs: ffs_snapshot.c Log Message: Quiesce CC ('blkno' may be used uninitialized in this function). To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/sys/ufs/ffs/ffs_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.107 src/sys/ufs/ffs/ffs_snapshot.c:1.108 --- src/sys/ufs/ffs/ffs_snapshot.c:1.107 Tue Feb 22 20:25:54 2011 +++ src/sys/ufs/ffs/ffs_snapshot.c Wed Feb 23 08:53:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.107 2011/02/22 20:25:54 he Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.108 2011/02/23 08:53:21 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.107 2011/02/22 20:25:54 he Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.108 2011/02/23 08:53:21 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -1826,6 +1826,8 @@ uint32_t gen; int lower, upper, mid, snapshot_locked = 0, error = 0; + blkno = 0; /* XXX: GCC */ + /* * Check for valid snapshots. */
CVS commit: src
Module Name:src Committed By: hannken Date: Thu Feb 24 09:38:58 UTC 2011 Modified Files: src/sbin/dump: snapshot.c src/share/man/man4: fss.4 src/sys/dev: fss.c fssvar.h src/sys/ufs/ffs: ffs_snapshot.c src/usr.sbin/fssconfig: fssconfig.c Log Message: fss(4): Allow FSSIOCSET to set the initial flags. Add a new flag FSS_UNLINK_ON_CREATE to unlink the backing store before the snapshot gets created. With this change dump(8) no longer dumps the zero-sized, but named snapshot it is working on. Same applies to fsck_ffs(8). To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sbin/dump/snapshot.c cvs rdiff -u -r1.14 -r1.15 src/share/man/man4/fss.4 cvs rdiff -u -r1.72 -r1.73 src/sys/dev/fss.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/fssvar.h cvs rdiff -u -r1.109 -r1.110 src/sys/ufs/ffs/ffs_snapshot.c cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/fssconfig/fssconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/dump/snapshot.c diff -u src/sbin/dump/snapshot.c:1.5 src/sbin/dump/snapshot.c:1.6 --- src/sbin/dump/snapshot.c:1.5 Sun Apr 11 08:23:51 2010 +++ src/sbin/dump/snapshot.c Thu Feb 24 09:38:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: snapshot.c,v 1.5 2010/04/11 08:23:51 hannken Exp $ */ +/* $NetBSD: snapshot.c,v 1.6 2011/02/24 09:38:57 hannken Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ int snap_open(char *file, char *backup, time_t *snap_date, char **snap_dev) { - int i, n, fd, israw, fsinternal, dounlink, flags; + int i, n, fd, israw, fsinternal, dounlink; char path[MAXPATHLEN], fss_dev[14], *cp; dev_t mountdev; struct fss_set fss; @@ -144,6 +144,9 @@ if (close(fd) 0) goto fail; + fss.fss_flags = FSS_UNCONFIG_ON_CLOSE; + if (dounlink) + fss.fss_flags |= FSS_UNLINK_ON_CREATE; /* * Create the snapshot on the first free snapshot device. */ @@ -152,9 +155,6 @@ if ((fd = open(fss_dev, O_RDWR, 0)) 0) goto fail; - if (ioctl(fd, FSSIOFGET, flags) 0) - goto fail; - if (ioctl(fd, FSSIOCSET, fss) 0) { if (errno != EBUSY) goto fail; @@ -162,6 +162,7 @@ fd = -1; continue; } + dounlink = 0; if (snap_dev != NULL) { *snap_dev = strdup(fss_dev); @@ -171,10 +172,7 @@ } } - flags |= FSS_UNCONFIG_ON_CLOSE; - if (ioctl(fd, FSSIOCGET, fsg) 0 || - ioctl(fd, FSSIOFSET, flags) 0 || - (!israw unlink(fss.fss_bstore) 0)) { + if (ioctl(fd, FSSIOCGET, fsg) 0) { ioctl(fd, FSSIOCCLR); goto fail; } Index: src/share/man/man4/fss.4 diff -u src/share/man/man4/fss.4:1.14 src/share/man/man4/fss.4:1.15 --- src/share/man/man4/fss.4:1.14 Fri Nov 5 10:02:53 2010 +++ src/share/man/man4/fss.4 Thu Feb 24 09:38:57 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: fss.4,v 1.14 2010/11/05 10:02:53 hannken Exp $ */ +.\ $NetBSD: fss.4,v 1.15 2011/02/24 09:38:57 hannken Exp $ */ .\ .\ .\ Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd November 5, 2010 +.Dd February 24, 2011 .Dt FSS 4 .Os .Sh NAME @@ -65,6 +65,7 @@ char *fss_mount; char *fss_bstore; blksize_t fss_csize; + int fss_flags; }; .Ed .Pp @@ -78,6 +79,9 @@ The struct element .Va fss_csize is the preferred size of this data. +The struct element +.Va fss_flags +is the initial set of flags. .It Dv FSSIOCGET(struct fss_get) Gets the status of a .Nm @@ -120,6 +124,10 @@ Unconfigure the .Nm device on the last close. +.It Dv FSS_UNLINK_ON_CREATE +Unlink the backing file before the +.Nm +device is created. .El .It Dv FSSIOFGET(int) Gets the flags of a Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.72 src/sys/dev/fss.c:1.73 --- src/sys/dev/fss.c:1.72 Mon Dec 27 18:41:07 2010 +++ src/sys/dev/fss.c Thu Feb 24 09:38:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.72 2010/12/27 18:41:07 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.73 2011/02/24 09:38:57 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.72 2010/12/27 18:41:07 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.73 2011/02/24 09:38:57 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -58,6 +58,7 @@ #include sys/kthread.h #include sys/fstrans.h #include sys/simplelock.h +#include sys/vfs_syscalls.h /* For do_sys_unlink(). */ #include miscfs/specfs/specdev.h @@ -303,6 +304,9 @@ struct fss_get *fsg = (struct fss_get *)data; switch (cmd) { + case FSSIOCSET50: + fss-fss_flags = 0; + /* Fall through */ case FSSIOCSET: mutex_enter(sc-sc_lock); if ((flag FWRITE) == 0) @@ -311,6 +315,8 @@ error = EBUSY; else error = fss_create_snapshot(sc, fss, l); + if (error == 0) + sc-sc_uflags = fss-fss_flags; mutex_exit(sc-sc_lock);
CVS commit: src
Module Name:src Committed By: hannken Date: Sat Mar 19 20:05:21 UTC 2011 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c src/tests/fs/vfs: t_vnops.c Log Message: Remove a vnode reference leak from msdosfs_rename. Release tdvp if either doscheckpath() or relookup() fails. Adjust test fs/vfs/t_vnops.c and remove the link count test for msdos. Fixes PR #44661 To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/fs/msdosfs/msdosfs_vnops.c cvs rdiff -u -r1.21 -r1.22 src/tests/fs/vfs/t_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.72 src/sys/fs/msdosfs/msdosfs_vnops.c:1.73 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.72 Thu Mar 3 08:10:45 2011 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Sat Mar 19 20:05:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.72 2011/03/03 08:10:45 pooka Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.72 2011/03/03 08:10:45 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -935,11 +935,11 @@ */ vref(tdvp); if ((error = doscheckpath(ip, dp)) != 0) - goto out; + goto bad; vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY); if ((error = relookup(tdvp, tvp, tcnp, 0)) != 0) { VOP_UNLOCK(tdvp); - goto out; + goto bad; } dp = VTODE(tdvp); xp = tvp ? VTODE(tvp) : NULL; @@ -1114,7 +1114,6 @@ if (tvp) vput(tvp); vrele(tdvp); -out: ip-de_flag = ~DE_RENAME; vrele(fdvp); vrele(fvp); Index: src/tests/fs/vfs/t_vnops.c diff -u src/tests/fs/vfs/t_vnops.c:1.21 src/tests/fs/vfs/t_vnops.c:1.22 --- src/tests/fs/vfs/t_vnops.c:1.21 Thu Mar 3 10:57:30 2011 +++ src/tests/fs/vfs/t_vnops.c Sat Mar 19 20:05:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_vnops.c,v 1.21 2011/03/03 10:57:30 pooka Exp $ */ +/* $NetBSD: t_vnops.c,v 1.22 2011/03/19 20:05:21 hannken Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -290,14 +290,12 @@ RL(rump_sys_rename(pb2, pb3)); RL(rump_sys_stat(pb1, sb)); - ATF_CHECK_EQ(sb.st_nlink, 3); + if (! FSTYPE_MSDOS(tc)) + ATF_CHECK_EQ(sb.st_nlink, 3); RL(rump_sys_rmdir(pb3)); if (FSTYPE_TMPFS(tc)) atf_tc_expect_signal(-1, PR kern/44288); RL(rump_sys_rmdir(pb1)); - - if (FSTYPE_MSDOS(tc)) - atf_tc_expect_fail(PR kern/44661); } static void
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Sun Mar 20 12:21:28 UTC 2011 Modified Files: src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vnops.c Log Message: When extending a file, either by truncating or by writing past EOF make sure the unallocated remainder of the last page gets zeroed. Detected by fsx. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.73 -r1.74 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_denode.c diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.40 src/sys/fs/msdosfs/msdosfs_denode.c:1.41 --- src/sys/fs/msdosfs/msdosfs_denode.c:1.40 Wed Jul 21 17:52:10 2010 +++ src/sys/fs/msdosfs/msdosfs_denode.c Sun Mar 20 12:21:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_denode.c,v 1.40 2010/07/21 17:52:10 hannken Exp $ */ +/* $NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.40 2010/07/21 17:52:10 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -583,7 +583,7 @@ uvm_vnp_setwritesize(DETOV(dep), (voff_t)dep-de_FileSize); dep-de_flag |= DE_UPDATE|DE_MODIFIED; uvm_vnp_zerorange(DETOV(dep), (off_t)osize, - (size_t)(dep-de_FileSize - osize)); + (size_t)(round_page(dep-de_FileSize) - osize)); uvm_vnp_setsize(DETOV(dep), (voff_t)dep-de_FileSize); return (deupdat(dep, 1)); } Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.73 src/sys/fs/msdosfs/msdosfs_vnops.c:1.74 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.73 Sat Mar 19 20:05:21 2011 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Sun Mar 20 12:21:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.74 2011/03/20 12:21:28 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.74 2011/03/20 12:21:28 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -554,6 +554,7 @@ u_long count; vsize_t bytelen; off_t oldoff; + size_t rem; struct uio *uio = ap-a_uio; struct vnode *vp = ap-a_vp; struct denode *dep = VTODE(vp); @@ -623,6 +624,10 @@ dep-de_FileSize = uio-uio_offset + resid; /* hint uvm to not read in extended part */ uvm_vnp_setwritesize(vp, dep-de_FileSize); + /* zero out the remainder of the last page */ + rem = round_page(dep-de_FileSize) - dep-de_FileSize; + if (rem 0) + uvm_vnp_zerorange(vp, (off_t)dep-de_FileSize, rem); extended = 1; }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Tue Mar 22 20:33:51 UTC 2011 Modified Files: src/sys/fs/msdosfs: msdosfs_denode.c Log Message: When truncating a file purge the fat cache after setting the new size and after all io but before actually updating the cluster chain. Both uvm_vnp_zerorange() and vtruncbuf() call get/putpages - bmap - pcbmap and here the fat cache gets updated with information no longer valid after truncation. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/fs/msdosfs/msdosfs_denode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_denode.c diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.41 src/sys/fs/msdosfs/msdosfs_denode.c:1.42 --- src/sys/fs/msdosfs/msdosfs_denode.c:1.41 Sun Mar 20 12:21:28 2011 +++ src/sys/fs/msdosfs/msdosfs_denode.c Tue Mar 22 20:33:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $ */ +/* $NetBSD: msdosfs_denode.c,v 1.42 2011/03/22 20:33:51 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.42 2011/03/22 20:33:51 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -461,8 +461,6 @@ } } - fc_purge(dep, lastblock + 1); - /* * If the new length is not a multiple of the cluster size then we * must zero the tail end of the new last cluster in case it @@ -506,6 +504,8 @@ allerror, eofentry); #endif + fc_purge(dep, lastblock + 1); + /* * If we need to break the cluster chain for the file then do it * now.
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Mon Apr 5 09:30:46 UTC 2010 Modified Files: src/sys/dev: fss.c fssvar.h Log Message: Remove unused fss_softc member sc_bs_size. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/fss.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/fssvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.65 src/sys/dev/fss.c:1.66 --- src/sys/dev/fss.c:1.65 Sat Oct 17 10:29:29 2009 +++ src/sys/dev/fss.c Mon Apr 5 09:30:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.65 2009/10/17 10:29:29 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.66 2010/04/05 09:30:46 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.65 2009/10/17 10:29:29 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.66 2010/04/05 09:30:46 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -579,7 +579,6 @@ int error, bits, fsbsize; struct timespec ts; struct partinfo dpart; - struct vattr va; /* nd - nd2 to reduce mistakes while updating only some namei calls */ struct nameidata nd2; struct vnode *vp; @@ -686,10 +685,6 @@ return EINVAL; if (sc-sc_bs_vp-v_type == VREG) { - error = VOP_GETATTR(sc-sc_bs_vp, va, l-l_cred); - if (error != 0) - return error; - sc-sc_bs_size = va.va_size; fsbsize = sc-sc_bs_vp-v_mount-mnt_stat.f_iosize; if (fsbsize (fsbsize-1)) /* No power of two */ return EINVAL; Index: src/sys/dev/fssvar.h diff -u src/sys/dev/fssvar.h:1.23 src/sys/dev/fssvar.h:1.24 --- src/sys/dev/fssvar.h:1.23 Wed Sep 17 14:49:25 2008 +++ src/sys/dev/fssvar.h Mon Apr 5 09:30:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fssvar.h,v 1.23 2008/09/17 14:49:25 hannken Exp $ */ +/* $NetBSD: fssvar.h,v 1.24 2010/04/05 09:30:46 hannken Exp $ */ /*- * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. @@ -138,7 +138,6 @@ struct timeval sc_time; /* Time this snapshot was taken */ dev_t sc_bdev; /* Underlying block device */ struct vnode *sc_bs_vp; /* Our backing store */ - off_t sc_bs_size; /* Its size in bytes */ int sc_bs_bshift; /* Shift of backing store block */ u_int32_t sc_bs_bmask; /* Mask of backing store block */ struct lwp *sc_bs_lwp; /* Our kernel thread */
CVS commit: src
Module Name:src Committed By: hannken Date: Fri Apr 9 08:09:18 UTC 2010 Modified Files: src/doc: CHANGES src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vfsops.c msdosfs_vnops.c Log Message: Add file system suspension support (vfs_suspend(9)) to msdosfs. Reviewed by: Antti Kantee po...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.1378 -r1.1379 src/doc/CHANGES cvs rdiff -u -r1.37 -r1.38 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.80 -r1.81 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.63 -r1.64 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.1378 src/doc/CHANGES:1.1379 --- src/doc/CHANGES:1.1378 Thu Apr 8 05:13:52 2010 +++ src/doc/CHANGES Fri Apr 9 08:09:18 2010 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: $Revision: 1.1378 $ +# LIST OF CHANGES FROM LAST RELEASE: $Revision: 1.1379 $ # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -580,3 +580,4 @@ connected to Atari ROM cartridge slot. [tsutsui 20100401] agp(4): Add support for the Intel 82855GM AGP port. [jakllsch 20100404] acpi(4): Updated ACPICA to 20100121. [jruoho 20100408] + fss(4): Add snapshot support for MSDOS file systems. [hannken 20100409] Index: src/sys/fs/msdosfs/msdosfs_denode.c diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.37 src/sys/fs/msdosfs/msdosfs_denode.c:1.38 --- src/sys/fs/msdosfs/msdosfs_denode.c:1.37 Fri Jan 8 11:35:08 2010 +++ src/sys/fs/msdosfs/msdosfs_denode.c Fri Apr 9 08:09:18 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_denode.c,v 1.37 2010/01/08 11:35:08 pooka Exp $ */ +/* $NetBSD: msdosfs_denode.c,v 1.38 2010/04/09 08:09:18 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,11 +48,12 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.37 2010/01/08 11:35:08 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_denode.c,v 1.38 2010/04/09 08:09:18 hannken Exp $); #include sys/param.h #include sys/systm.h #include sys/mount.h +#include sys/fstrans.h #include sys/malloc.h #include sys/pool.h #include sys/proc.h @@ -655,6 +656,7 @@ bool *a_recycle; } */ *ap = v; struct vnode *vp = ap-a_vp; + struct mount *mp = vp-v_mount; struct denode *dep = VTODE(vp); int error = 0; @@ -662,6 +664,7 @@ printf(msdosfs_inactive(): dep %p, de_Name[0] %x\n, dep, dep-de_Name[0]); #endif + fstrans_start(mp, FSTRANS_LAZY); /* * Get rid of denodes related to stale file handles. */ @@ -696,6 +699,7 @@ #endif *ap-a_recycle = (dep-de_Name[0] == SLOT_DELETED); VOP_UNLOCK(vp, 0); + fstrans_done(mp); return (error); } Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.80 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.81 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.80 Wed Apr 7 15:19:09 2010 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Fri Apr 9 08:09:18 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.80 2010/04/07 15:19:09 pooka Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.81 2010/04/09 08:09:18 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.80 2010/04/07 15:19:09 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.81 2010/04/09 08:09:18 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -69,6 +69,7 @@ #include sys/device.h #include sys/disklabel.h #include sys/disk.h +#include sys/fstrans.h #include sys/ioctl.h #include sys/malloc.h #include sys/dirent.h @@ -136,7 +137,7 @@ msdosfs_mountroot, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, - (void *)eopnotsupp, /* vfs_suspendctl */ + msdosfs_suspendctl, genfs_renamelock_enter, genfs_renamelock_exit, (void *)eopnotsupp, @@ -483,6 +484,10 @@ bp = NULL; /* both used in error_exit */ pmp = NULL; + error = fstrans_mount(mp); + if (error) + goto error_exit; + error = getdisksize(devvp, psize, secsize); if (error) goto error_exit; @@ -812,6 +817,7 @@ return (0); error_exit: + fstrans_unmount(mp); if (bp) brelse(bp, BC_AGE); if (pmp) { @@ -878,6 +884,7 @@ free(pmp, M_MSDOSFSMNT); mp-mnt_data = NULL; mp-mnt_flag = ~MNT_LOCAL; + fstrans_unmount(mp); return (0); } @@ -924,7 +931,8 @@ struct vnode *vp, *mvp; struct denode *dep; struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); - int error, allerror = 0; + int lk_flags, error, allerror = 0; + bool is_suspending; /* * If we ever switch to not updating all of the fats all the time, @@ -940,6 +948,16 @@ /* Allocate a marker vnode. */ if ((mvp = vnalloc(mp)) == NULL) return ENOMEM; + fstrans_start(mp, FSTRANS_SHARED); + is_suspending = (fstrans_getstate(mp) ==
CVS commit: src
Module Name:src Committed By: hannken Date: Sun Apr 11 08:23:52 UTC 2010 Modified Files: src/doc: CHANGES src/sbin/dump: snapshot.c src/sbin/fsck_ffs: main.c src/sbin/fsck_msdos: Makefile fsck_msdos.8 main.c Log Message: Add -x option which allows to run `fsck_msdos -n' on a snapshot of a live file system. While here modify snap_open() to accept a character device as its first arg and remove now unneeded get_snap_device(). Reviewed by: Manuel Bouyer bou...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.1379 -r1.1380 src/doc/CHANGES cvs rdiff -u -r1.4 -r1.5 src/sbin/dump/snapshot.c cvs rdiff -u -r1.75 -r1.76 src/sbin/fsck_ffs/main.c cvs rdiff -u -r1.11 -r1.12 src/sbin/fsck_msdos/Makefile cvs rdiff -u -r1.15 -r1.16 src/sbin/fsck_msdos/fsck_msdos.8 cvs rdiff -u -r1.21 -r1.22 src/sbin/fsck_msdos/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.1379 src/doc/CHANGES:1.1380 --- src/doc/CHANGES:1.1379 Fri Apr 9 08:09:18 2010 +++ src/doc/CHANGES Sun Apr 11 08:23:51 2010 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: $Revision: 1.1379 $ +# LIST OF CHANGES FROM LAST RELEASE: $Revision: 1.1380 $ # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -581,3 +581,5 @@ agp(4): Add support for the Intel 82855GM AGP port. [jakllsch 20100404] acpi(4): Updated ACPICA to 20100121. [jruoho 20100408] fss(4): Add snapshot support for MSDOS file systems. [hannken 20100409] + fsck_msdos(8): add -x option which allows to run fsck_msdos -n on + a snapshot of a live file system. [hannken 20100411] Index: src/sbin/dump/snapshot.c diff -u src/sbin/dump/snapshot.c:1.4 src/sbin/dump/snapshot.c:1.5 --- src/sbin/dump/snapshot.c:1.4 Mon Apr 28 20:23:08 2008 +++ src/sbin/dump/snapshot.c Sun Apr 11 08:23:51 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: snapshot.c,v 1.4 2008/04/28 20:23:08 martin Exp $ */ +/* $NetBSD: snapshot.c,v 1.5 2010/04/11 08:23:51 hannken Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -54,25 +54,51 @@ * snapshot device path. */ int -snap_open(char *mountpoint, char *backup, time_t *snap_date, char **snap_dev) +snap_open(char *file, char *backup, time_t *snap_date, char **snap_dev) { - int i, fd, israw, fsinternal, dounlink, flags; - char path[MAXPATHLEN], fss_dev[14]; + int i, n, fd, israw, fsinternal, dounlink, flags; + char path[MAXPATHLEN], fss_dev[14], *cp; dev_t mountdev; struct fss_set fss; struct fss_get fsg; struct stat sb; - struct statvfs fsb; + struct statvfs *mntbuf, *fs, fsb; dounlink = 0; fd = -1; + mntbuf = NULL; - fss.fss_mount = mountpoint; + /* + * Lookup the mount point. `file' is either a directory or a raw + * character device. + */ + if (lstat(file, sb) 0) + goto fail; + fss.fss_mount = NULL; + if (S_ISCHR(sb.st_mode)) { + if ((cp = strrchr(file, '/')) == NULL || cp[1] != 'r') { + errno = EINVAL; + goto fail; + } + snprintf(path, sizeof(path), %.*s/%s, + (int)(cp - file), file, cp + 2); + n = getmntinfo(mntbuf, MNT_NOWAIT); + for (fs = mntbuf, i = 0; i n; i++, fs++) { + if (strcmp(fs-f_mntfromname, path) == 0) { +fss.fss_mount = fs-f_mntonname; +if (stat(fss.fss_mount, sb) 0) + goto fail; +break; + } + } + } else if (S_ISDIR(sb.st_mode)) + fss.fss_mount = file; + if (fss.fss_mount == NULL) { + errno = EINVAL; + goto fail; + } fss.fss_bstore = backup ? backup : fss.fss_mount; fss.fss_csize = 0; - - if (stat(fss.fss_mount, sb) 0) - goto fail; mountdev = sb.st_dev; /* @@ -153,12 +179,16 @@ goto fail; } + if (mntbuf) + free(mntbuf); if (snap_date != NULL) *snap_date = fsg.fsg_time.tv_sec; return fd; } fail: + if (mntbuf) + free(mntbuf); if (dounlink) unlink(fss.fss_bstore); if (fd = 0) Index: src/sbin/fsck_ffs/main.c diff -u src/sbin/fsck_ffs/main.c:1.75 src/sbin/fsck_ffs/main.c:1.76 --- src/sbin/fsck_ffs/main.c:1.75 Thu Jan 7 01:39:56 2010 +++ src/sbin/fsck_ffs/main.c Sun Apr 11 08:23:51 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.75 2010/01/07 01:39:56 christos Exp $ */ +/* $NetBSD: main.c,v 1.76 2010/04/11 08:23:51 hannken Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = @(#)main.c 8.6 (Berkeley) 5/14/95; #else -__RCSID($NetBSD: main.c,v 1.75 2010/01/07 01:39:56 christos Exp $); +__RCSID($NetBSD: main.c,v 1.76 2010/04/11 08:23:51 hannken Exp $); #endif #endif /* not lint */ @@ -76,7 +76,6 @@ static int argtoi(int, const char *, const char *, int); static int checkfilesys(const char *, const char *, int); static void usage(void); -static char *get_snap_device(char *); int main(int argc, char *argv[]) @@ -223,23 +222,17 @@ pfatal(Can't check %s\n, *argv); if (snap_backup || snap_internal) { - char *mpt; char *snap_dev; int snapfd; -
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Tue Apr 13 07:58:55 UTC 2010 Modified Files: src/sys/dev: fss.c Log Message: fss_softc_free: don't detach a disk that is not attached. Disk is attached only if the backing store thread is running. Resolves PR #43153: fss error branch error To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.67 src/sys/dev/fss.c:1.68 --- src/sys/dev/fss.c:1.67 Mon Apr 12 22:29:11 2010 +++ src/sys/dev/fss.c Tue Apr 13 07:58:54 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.67 2010/04/12 22:29:11 pooka Exp $ */ +/* $NetBSD: fss.c,v 1.68 2010/04/13 07:58:54 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.67 2010/04/12 22:29:11 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.68 2010/04/13 07:58:54 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -473,9 +473,9 @@ while (sc-sc_bs_lwp != NULL) kpause(fssdetach, false, 1, sc-sc_slock); mutex_exit(sc-sc_slock); - } - disk_detach(sc-sc_dkdev); + disk_detach(sc-sc_dkdev); + } if (sc-sc_copied != NULL) kmem_free(sc-sc_copied, howmany(sc-sc_clcount, NBBY));
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Tue Apr 13 09:27:59 UTC 2010 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: Add fstrans transactions to ufs_close(), ufs_getattr(), ufs_chmod() and ufs_chown(). These functions change file system state. To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/sys/ufs/ufs/ufs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.181 src/sys/ufs/ufs/ufs_vnops.c:1.182 --- src/sys/ufs/ufs/ufs_vnops.c:1.181 Mon Mar 29 13:11:34 2010 +++ src/sys/ufs/ufs/ufs_vnops.c Tue Apr 13 09:27:58 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.181 2010/03/29 13:11:34 pooka Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.182 2010/04/13 09:27:58 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.181 2010/03/29 13:11:34 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.182 2010/04/13 09:27:58 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -267,8 +267,10 @@ vp = ap-a_vp; ip = VTOI(vp); + fstrans_start(vp-v_mount, FSTRANS_SHARED); if (vp-v_usecount 1) UFS_ITIMES(vp, NULL, NULL, NULL); + fstrans_done(vp-v_mount); return (0); } @@ -371,6 +373,7 @@ vp = ap-a_vp; ip = VTOI(vp); vap = ap-a_vap; + fstrans_start(vp-v_mount, FSTRANS_SHARED); UFS_ITIMES(vp, NULL, NULL, NULL); /* @@ -420,6 +423,7 @@ vap-va_blocksize = vp-v_mount-mnt_stat.f_iosize; vap-va_type = vp-v_type; vap-va_filerev = ip-i_modrev; + fstrans_done(vp-v_mount); return (0); } @@ -671,11 +675,13 @@ if (error) return (error); + fstrans_start(vp-v_mount, FSTRANS_SHARED); ip-i_mode = ~ALLPERMS; ip-i_mode |= (mode ALLPERMS); ip-i_flag |= IN_CHANGE; DIP_ASSIGN(ip, mode, ip-i_mode); UFS_WAPBL_UPDATE(vp, NULL, NULL, 0); + fstrans_done(vp-v_mount); return (0); } @@ -706,6 +712,7 @@ if (error) return (error); + fstrans_start(vp-v_mount, FSTRANS_SHARED); #ifdef QUOTA ogid = ip-i_gid; ouid = ip-i_uid; @@ -730,11 +737,13 @@ DIP_ASSIGN(ip, uid, ouid); (void) chkdq(ip, change, cred, FORCE); (void) chkiq(ip, 1, cred, FORCE); + fstrans_done(vp-v_mount); return (error); good: #endif /* QUOTA */ ip-i_flag |= IN_CHANGE; UFS_WAPBL_UPDATE(vp, NULL, NULL, 0); + fstrans_done(vp-v_mount); return (0); }
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: hannken Date: Fri Jan 20 18:47:04 UTC 2012 Modified Files: src/sys/arch/x86/include: i82489reg.h Log Message: Revert revision 1.4 and change LAPIC_LEVEL_ASSERT / _MASK back to 0x4000. According to Intel 64 and IA-32 Architectures Software Developer's Manual Vol. 3, May 2011, Order Number: 325384-039US, Section 10.6.1: LEVEL_ASSERT is bit #14, bit #13 is reserved. With this change NetBSD now boots multiple processors under CentOS 6.2/kvm. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/include/i82489reg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/i82489reg.h diff -u src/sys/arch/x86/include/i82489reg.h:1.10 src/sys/arch/x86/include/i82489reg.h:1.11 --- src/sys/arch/x86/include/i82489reg.h:1.10 Mon Nov 15 11:58:09 2010 +++ src/sys/arch/x86/include/i82489reg.h Fri Jan 20 18:47:04 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: i82489reg.h,v 1.10 2010/11/15 11:58:09 cegger Exp $ */ +/* $NetBSD: i82489reg.h,v 1.11 2012/01/20 18:47:04 hannken Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -92,8 +92,8 @@ # define LAPIC_DLSTAT_BUSY 0x1000 # define LAPIC_DLSTAT_IDLE 0x -# define LAPIC_LEVEL_MASK 0x2000 -# define LAPIC_LEVEL_ASSERT 0x2000 +# define LAPIC_LEVEL_MASK 0x4000 +# define LAPIC_LEVEL_ASSERT 0x4000 # define LAPIC_LEVEL_DEASSERT 0x # define LAPIC_TRIGGER_MASK 0x8000
CVS commit: src/sys/arch/i386/conf
Module Name:src Committed By: hannken Date: Sun Jan 29 18:29:12 UTC 2012 Modified Files: src/sys/arch/i386/conf: INSTALL_FLOPPY Log Message: Add virtio driver to INSTALL_FLOPPY. Requested by Matthias Scheler t...@netbsd.org for particular cases like http://mail-index.netbsd.org/netbsd-users/2011/09/13/msg009128.html To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/i386/conf/INSTALL_FLOPPY Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/conf/INSTALL_FLOPPY diff -u src/sys/arch/i386/conf/INSTALL_FLOPPY:1.14 src/sys/arch/i386/conf/INSTALL_FLOPPY:1.15 --- src/sys/arch/i386/conf/INSTALL_FLOPPY:1.14 Tue Nov 22 21:25:20 2011 +++ src/sys/arch/i386/conf/INSTALL_FLOPPY Sun Jan 29 18:29:11 2012 @@ -1,4 +1,4 @@ -# $NetBSD: INSTALL_FLOPPY,v 1.14 2011/11/22 21:25:20 tls Exp $ +# $NetBSD: INSTALL_FLOPPY,v 1.15 2012/01/29 18:29:11 hannken Exp $ # # INSTALL - Installation kernel. # @@ -740,6 +740,11 @@ url* at uhub? port ? # Realtek RTL8150L # Planetconnect Satellite receiver driver. #satlink0 at isa? port 0x300 drq 1 +# Virtio devices +virtio* at pci? dev ? function ? # Virtio PCI device +viomb* at virtio? # Virtio memory balloon device +ld* at virtio? # Virtio disk device +vioif* at virtio? # Virtio network device # Pull in optional local configuration cinclude arch/i386/conf/INSTALL.local
CVS commit: src/sys/nfs
Module Name:src Committed By: hannken Date: Mon Aug 12 17:46:38 UTC 2013 Modified Files: src/sys/nfs: nfs_bio.c Log Message: Function nfs_vinvalbuf() ignores errors from vinvalbuf() and therefore delayed write errors may get lost. Change nfs_vinvalbuf() to keep errors from vinvalbuf() for fsync() or close(). Presented on tech-kern@ Fix for PR kern/47980 (NFS over-quota not detected if utimes() called before fsync()/close()) To generate a diff of this commit: cvs rdiff -u -r1.188 -r1.189 src/sys/nfs/nfs_bio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/nfs/nfs_bio.c diff -u src/sys/nfs/nfs_bio.c:1.188 src/sys/nfs/nfs_bio.c:1.189 --- src/sys/nfs/nfs_bio.c:1.188 Tue Sep 27 01:07:38 2011 +++ src/sys/nfs/nfs_bio.c Mon Aug 12 17:46:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_bio.c,v 1.188 2011/09/27 01:07:38 christos Exp $ */ +/* $NetBSD: nfs_bio.c,v 1.189 2013/08/12 17:46:38 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.188 2011/09/27 01:07:38 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.189 2013/08/12 17:46:38 hannken Exp $); #ifdef _KERNEL_OPT #include opt_nfs.h @@ -614,7 +614,7 @@ nfs_vinvalbuf(struct vnode *vp, int flag { struct nfsnode *np = VTONFS(vp); struct nfsmount *nmp = VFSTONFS(vp-v_mount); - int error = 0, slptimeo; + int error = 0, allerror = 0, slptimeo; bool catch; if ((nmp-nm_flag NFSMNT_INT) == 0) @@ -647,6 +647,8 @@ nfs_vinvalbuf(struct vnode *vp, int flag mutex_exit(vp-v_interlock); error = vinvalbuf(vp, flags, cred, l, catch, 0); while (error) { + if (allerror == 0) + allerror = error; if (intrflg nfs_sigintr(nmp, NULL, l)) { error = EINTR; break; @@ -654,6 +656,13 @@ nfs_vinvalbuf(struct vnode *vp, int flag error = vinvalbuf(vp, flags, cred, l, 0, slptimeo); } mutex_enter(vp-v_interlock); + if (allerror != 0) { + /* + * Keep error from vinvalbuf so fsync/close will know. + */ + np-n_error = allerror; + np-n_flag |= NWRITEERR; + } if (error == 0) np-n_flag = ~NMODIFIED; np-n_flag = ~NFLUSHINPROG;
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Aug 30 12:58:22 UTC 2013 Modified Files: src/sys/kern: vfs_mount.c Log Message: Dounmount() violates the locking protocol for member v_mountedhere. A vnode lock is required to access or modify this field. Lock/unlock the vnode when clearing v_mountedhere. Reviewed by: David Holland dholl...@netbsd.org Should fix PR #48135 (Bad locking for umount) To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.19 src/sys/kern/vfs_mount.c:1.20 --- src/sys/kern/vfs_mount.c:1.19 Sun Apr 28 21:34:31 2013 +++ src/sys/kern/vfs_mount.c Fri Aug 30 12:58:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.19 2013/04/28 21:34:31 mlelstv Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.20 2013/08/30 12:58:22 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_mount.c,v 1.19 2013/04/28 21:34:31 mlelstv Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_mount.c,v 1.20 2013/08/30 12:58:22 hannken Exp $); #include sys/param.h #include sys/kernel.h @@ -878,9 +878,12 @@ dounmount(struct mount *mp, int flags, s mp-mnt_iflag |= IMNT_GONE; mutex_exit(mp-mnt_unmounting); - mutex_enter(mountlist_lock); - if ((coveredvp = mp-mnt_vnodecovered) != NULLVP) + if ((coveredvp = mp-mnt_vnodecovered) != NULLVP) { + vn_lock(coveredvp, LK_EXCLUSIVE | LK_RETRY); coveredvp-v_mountedhere = NULL; + VOP_UNLOCK(coveredvp); + } + mutex_enter(mountlist_lock); CIRCLEQ_REMOVE(mountlist, mp, mnt_list); mutex_exit(mountlist_lock); if (TAILQ_FIRST(mp-mnt_vnodelist) != NULL)
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Mon Sep 16 12:36:54 UTC 2013 Modified Files: src/sys/ufs/ffs: ffs_vfsops.c Log Message: Function ffs_reload() works on a read-only mount, so remove the call to ffs_snapshot_mount() as it would panic later with already on list when remounting read-write. Should fix PR kern/48211 (Unclean shutdown with active snapshot causes panic during reboot) To generate a diff of this commit: cvs rdiff -u -r1.287 -r1.288 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.287 src/sys/ufs/ffs/ffs_vfsops.c:1.288 --- src/sys/ufs/ffs/ffs_vfsops.c:1.287 Sun Aug 11 04:36:17 2013 +++ src/sys/ufs/ffs/ffs_vfsops.c Mon Sep 16 12:36:54 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.287 2013/08/11 04:36:17 dholland Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.288 2013/09/16 12:36:54 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_vfsops.c,v 1.287 2013/08/11 04:36:17 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_vfsops.c,v 1.288 2013/09/16 12:36:54 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -803,8 +803,6 @@ ffs_reload(struct mount *mp, kauth_cred_ space = (char *)space + bsize; brelse(bp, 0); } - if (fs-fs_snapinum[0] != 0) - ffs_snapshot_mount(mp); /* * We no longer know anything about clusters per cylinder group. */
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Mon Sep 30 15:24:14 UTC 2013 Modified Files: src/sys/kern: vfs_vnode.c src/sys/sys: vnode.h Log Message: Remove VI_INACTPEND. Last consumer was vcount() which got removed 2010-01-08. Reviewed by: David Holland dholl...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.237 -r1.238 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.20 src/sys/kern/vfs_vnode.c:1.21 --- src/sys/kern/vfs_vnode.c:1.20 Sat Sep 21 19:51:33 2013 +++ src/sys/kern/vfs_vnode.c Mon Sep 30 15:24:14 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.20 2013/09/21 19:51:33 dholland Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.21 2013/09/30 15:24:14 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -126,7 +126,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.20 2013/09/21 19:51:33 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.21 2013/09/30 15:24:14 hannken Exp $); #include sys/param.h #include sys/kernel.h @@ -744,9 +744,7 @@ retry: * clean it here. We donate it our last reference. */ KASSERT(mutex_owned(vp-v_interlock)); - KASSERT((vp-v_iflag VI_INACTPEND) == 0); vp-v_iflag = ~VI_INACTNOW; - vp-v_iflag |= VI_INACTPEND; mutex_enter(vrele_lock); TAILQ_INSERT_TAIL(vrele_list, vp, v_freelist); if (++vrele_pending (desiredvnodes 8)) @@ -894,8 +892,6 @@ vrele_thread(void *cookie) * and look for more work. */ mutex_enter(vp-v_interlock); - KASSERT((vp-v_iflag VI_INACTPEND) != 0); - vp-v_iflag = ~VI_INACTPEND; vrelel(vp, 0); } } Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.237 src/sys/sys/vnode.h:1.238 --- src/sys/sys/vnode.h:1.237 Sun Nov 18 18:39:24 2012 +++ src/sys/sys/vnode.h Mon Sep 30 15:24:14 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.237 2012/11/18 18:39:24 pooka Exp $ */ +/* $NetBSD: vnode.h,v 1.238 2013/09/30 15:24:14 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -122,7 +122,7 @@ TAILQ_HEAD(vnodelst, vnode); * lock. Field markings and the corresponding locks: * * : stable, reference to the vnode is required - * f vnode_free_list_lock, or vrele_lock if VI_INACTPEND + * f vnode_free_list_lock, or vrele_lock for vrele_list * i v_interlock * m mntvnode_lock * n namecache_lock @@ -205,7 +205,6 @@ typedef struct vnode vnode_t; #define VI_LAYER 0x0002 /* vnode is on a layer filesystem */ #define VI_LOCKSHARE 0x0004 /* v_interlock is shared */ #define VI_CLEAN 0x0008 /* has been reclaimed */ -#define VI_INACTPEND 0x0010 /* inactivation is pending */ #define VI_INACTREDO 0x0020 /* need to redo VOP_INACTIVE() */ #define VI_INACTNOW 0x0080 /* VOP_INACTIVE() in progress */ @@ -217,7 +216,7 @@ typedef struct vnode vnode_t; #define VNODE_FLAGBITS \ \20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP \ \13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER \ -\22LAYER\24CLEAN\25INACTPEND\26INACTREDO \ +\22LAYER\24CLEAN\26INACTREDO \ \30INACTNOW\31DIROP #define VSIZENOTSET ((voff_t)-1)
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Mon Sep 30 18:58:00 UTC 2013 Modified Files: src/sys/fs/adosfs: advfsops.c src/sys/fs/cd9660: cd9660_vfsops.c src/sys/fs/filecorefs: filecore_vfsops.c src/sys/fs/msdosfs: msdosfs_vfsops.c src/sys/fs/nilfs: nilfs_vfsops.c src/sys/fs/ntfs: ntfs_vfsops.c src/sys/fs/udf: udf_vfsops.c src/sys/kern: vfs_bio.c vfs_mount.c vfs_subr.c vfs_trans.c src/sys/miscfs/specfs: spec_vnops.c specdev.h src/sys/sys: param.h wapbl.h src/sys/ufs/chfs: chfs_vfsops.c src/sys/ufs/ext2fs: ext2fs_vfsops.c src/sys/ufs/ffs: ffs_alloc.c ffs_snapshot.c ffs_vfsops.c src/sys/ufs/lfs: lfs_vfsops.c Log Message: Replace macro v_specmountpoint with two functions spec_node_getmountedfs() and spec_node_setmountedfs() to manage the file system mounted on a device. Assert the device is a block device. Welcome to 6.99.24 Discussed on tech-kern@ some time ago. Reviewed by: David Holland dholl...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/fs/adosfs/advfsops.c cvs rdiff -u -r1.78 -r1.79 src/sys/fs/cd9660/cd9660_vfsops.c cvs rdiff -u -r1.70 -r1.71 src/sys/fs/filecorefs/filecore_vfsops.c cvs rdiff -u -r1.101 -r1.102 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.10 -r1.11 src/sys/fs/nilfs/nilfs_vfsops.c cvs rdiff -u -r1.87 -r1.88 src/sys/fs/ntfs/ntfs_vfsops.c cvs rdiff -u -r1.63 -r1.64 src/sys/fs/udf/udf_vfsops.c cvs rdiff -u -r1.246 -r1.247 src/sys/kern/vfs_bio.c cvs rdiff -u -r1.20 -r1.21 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.437 -r1.438 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.26 -r1.27 src/sys/kern/vfs_trans.c cvs rdiff -u -r1.140 -r1.141 src/sys/miscfs/specfs/spec_vnops.c cvs rdiff -u -r1.41 -r1.42 src/sys/miscfs/specfs/specdev.h cvs rdiff -u -r1.432 -r1.433 src/sys/sys/param.h cvs rdiff -u -r1.14 -r1.15 src/sys/sys/wapbl.h cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/chfs/chfs_vfsops.c cvs rdiff -u -r1.172 -r1.173 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.139 -r1.140 src/sys/ufs/ffs/ffs_alloc.c cvs rdiff -u -r1.128 -r1.129 src/sys/ufs/ffs/ffs_snapshot.c cvs rdiff -u -r1.288 -r1.289 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.313 -r1.314 src/sys/ufs/lfs/lfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/adosfs/advfsops.c diff -u src/sys/fs/adosfs/advfsops.c:1.66 src/sys/fs/adosfs/advfsops.c:1.67 --- src/sys/fs/adosfs/advfsops.c:1.66 Thu Dec 20 08:03:41 2012 +++ src/sys/fs/adosfs/advfsops.c Mon Sep 30 18:57:59 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: advfsops.c,v 1.66 2012/12/20 08:03:41 hannken Exp $ */ +/* $NetBSD: advfsops.c,v 1.67 2013/09/30 18:57:59 hannken Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: advfsops.c,v 1.66 2012/12/20 08:03:41 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: advfsops.c,v 1.67 2013/09/30 18:57:59 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -319,7 +319,7 @@ adosfs_unmount(struct mount *mp, int mnt return (error); amp = VFSTOADOSFS(mp); if (amp-devvp-v_type != VBAD) - amp-devvp-v_specmountpoint = NULL; + spec_node_setmountedfs(amp-devvp, NULL); vn_lock(amp-devvp, LK_EXCLUSIVE | LK_RETRY); error = VOP_CLOSE(amp-devvp, FREAD, NOCRED); vput(amp-devvp); Index: src/sys/fs/cd9660/cd9660_vfsops.c diff -u src/sys/fs/cd9660/cd9660_vfsops.c:1.78 src/sys/fs/cd9660/cd9660_vfsops.c:1.79 --- src/sys/fs/cd9660/cd9660_vfsops.c:1.78 Sun Jun 23 07:28:36 2013 +++ src/sys/fs/cd9660/cd9660_vfsops.c Mon Sep 30 18:57:59 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_vfsops.c,v 1.78 2013/06/23 07:28:36 dholland Exp $ */ +/* $NetBSD: cd9660_vfsops.c,v 1.79 2013/09/30 18:57:59 hannken Exp $ */ /*- * Copyright (c) 1994 @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: cd9660_vfsops.c,v 1.78 2013/06/23 07:28:36 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: cd9660_vfsops.c,v 1.79 2013/09/30 18:57:59 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -523,7 +523,7 @@ iso_mountfs(struct vnode *devvp, struct supbp = NULL; } - devvp-v_specmountpoint = mp; + spec_node_setmountedfs(devvp, mp); return 0; out: @@ -568,7 +568,7 @@ cd9660_unmount(struct mount *mp, int mnt isomp = VFSTOISOFS(mp); if (isomp-im_devvp-v_type != VBAD) - isomp-im_devvp-v_specmountpoint = NULL; + spec_node_setmountedfs(isomp-im_devvp, NULL); vn_lock(isomp-im_devvp, LK_EXCLUSIVE | LK_RETRY); error = VOP_CLOSE(isomp-im_devvp, FREAD, NOCRED); Index: src/sys/fs/filecorefs/filecore_vfsops.c diff -u src/sys/fs/filecorefs/filecore_vfsops.c:1.70 src/sys/fs/filecorefs/filecore_vfsops.c:1.71 --- src/sys/fs/filecorefs/filecore_vfsops.c:1.70 Thu Dec 20 08:03:42 2012 +++ src/sys/fs/filecorefs/filecore_vfsops.c Mon Sep 30 18:57:59 2013 @@ -1,4 +1,4 @@ -/*
CVS commit: src/sys/ufs
Module Name:src Committed By: hannken Date: Fri Mar 16 08:39:54 UTC 2012 Modified Files: src/sys/ufs/ext2fs: ext2fs_lookup.c src/sys/ufs/ufs: ufs_lookup.c Log Message: Fix last commit that broke lookup for dot with op DELETE. Reviewed by: David Holland dholl...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/ufs/ext2fs/ext2fs_lookup.c cvs rdiff -u -r1.112 -r1.113 src/sys/ufs/ufs/ufs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ext2fs/ext2fs_lookup.c diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.68 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.69 --- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.68 Tue Mar 13 18:41:03 2012 +++ src/sys/ufs/ext2fs/ext2fs_lookup.c Fri Mar 16 08:39:54 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_lookup.c,v 1.68 2012/03/13 18:41:03 elad Exp $ */ +/* $NetBSD: ext2fs_lookup.c,v 1.69 2012/03/16 08:39:54 hannken Exp $ */ /* * Modified for NetBSD 1.2E @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ext2fs_lookup.c,v 1.68 2012/03/13 18:41:03 elad Exp $); +__KERNEL_RCSID(0, $NetBSD: ext2fs_lookup.c,v 1.69 2012/03/16 08:39:54 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -586,18 +586,26 @@ found: results-ulr_count = 0; else results-ulr_count = results-ulr_offset - prevoff; - if (flags ISDOTDOT) - VOP_UNLOCK(vdp); /* race to get the inode */ - error = VFS_VGET(vdp-v_mount, foundino, tdp); - if (flags ISDOTDOT) - vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); - if (error) - return (error); + if (dp-i_number == foundino) { + vref(vdp); + tdp = vdp; + } else { + if (flags ISDOTDOT) +VOP_UNLOCK(vdp); /* race to get the inode */ + error = VFS_VGET(vdp-v_mount, foundino, tdp); + if (flags ISDOTDOT) +vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); + if (error) +return (error); + } /* * Write access to directory required to delete files. */ if ((error = VOP_ACCESS(vdp, VWRITE, cred)) != 0) { - vput(tdp); + if (dp-i_number == foundino) +vrele(tdp); + else +vput(tdp); return (error); } /* @@ -611,15 +619,13 @@ found: tdp, vdp, genfs_can_sticky(cred, dp-i_uid, VTOI(tdp)-i_uid)); if (error) { -vput(tdp); +if (dp-i_number == foundino) + vrele(tdp); +else + vput(tdp); return (EPERM); } } - if (dp-i_number == foundino) { - vref(vdp); - *vpp = vdp; - return (0); - } *vpp = tdp; return (0); } Index: src/sys/ufs/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.112 src/sys/ufs/ufs/ufs_lookup.c:1.113 --- src/sys/ufs/ufs/ufs_lookup.c:1.112 Tue Mar 13 18:41:14 2012 +++ src/sys/ufs/ufs/ufs_lookup.c Fri Mar 16 08:39:54 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.112 2012/03/13 18:41:14 elad Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.112 2012/03/13 18:41:14 elad Exp $); +__KERNEL_RCSID(0, $NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $); #ifdef _KERNEL_OPT #include opt_ffs.h @@ -532,19 +532,27 @@ found: results-ulr_count = 0; else results-ulr_count = results-ulr_offset - prevoff; - if (flags ISDOTDOT) - VOP_UNLOCK(vdp); /* race to get the inode */ - error = VFS_VGET(vdp-v_mount, foundino, tdp); - if (flags ISDOTDOT) - vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); - if (error) - goto out; + if (dp-i_number == foundino) { + vref(vdp); + tdp = vdp; + } else { + if (flags ISDOTDOT) +VOP_UNLOCK(vdp); /* race to get the inode */ + error = VFS_VGET(vdp-v_mount, foundino, tdp); + if (flags ISDOTDOT) +vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); + if (error) +goto out; + } /* * Write access to directory required to delete files. */ error = VOP_ACCESS(vdp, VWRITE, cred); if (error) { - vput(tdp); + if (dp-i_number == foundino) +vrele(tdp); + else +vput(tdp); goto out; } /* @@ -558,17 +566,14 @@ found: tdp, vdp, genfs_can_sticky(cred, dp-i_uid, VTOI(tdp)-i_uid)); if (error) { -vput(tdp); +if (dp-i_number == foundino) + vrele(tdp); +else + vput(tdp); error = EPERM; goto out; } } - if (dp-i_number == foundino) { - vref(vdp); - *vpp = vdp; - error = 0; - goto out; - } *vpp = tdp; error = 0; goto out;
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: hannken Date: Sat Mar 17 17:58:38 UTC 2012 Modified Files: src/sys/rump/librump/rumpkern: vm.c Log Message: Don't take a mutex we already took 6 lines above. To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/rump/librump/rumpkern/vm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/vm.c diff -u src/sys/rump/librump/rumpkern/vm.c:1.124 src/sys/rump/librump/rumpkern/vm.c:1.125 --- src/sys/rump/librump/rumpkern/vm.c:1.124 Mon Mar 5 13:43:56 2012 +++ src/sys/rump/librump/rumpkern/vm.c Sat Mar 17 17:58:38 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vm.c,v 1.124 2012/03/05 13:43:56 para Exp $ */ +/* $NetBSD: vm.c,v 1.125 2012/03/17 17:58:38 hannken Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -41,7 +41,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vm.c,v 1.124 2012/03/05 13:43:56 para Exp $); +__KERNEL_RCSID(0, $NetBSD: vm.c,v 1.125 2012/03/17 17:58:38 hannken Exp $); #include sys/param.h #include sys/atomic.h @@ -1110,7 +1110,6 @@ uvm_pageout(void *arg) rumpuser_dprintf(pagedaemoness: failed to reclaim memory ... sleeping (deadlock?)\n); cv_timedwait(pdaemoncv, pdaemonmtx, hz); - mutex_enter(pdaemonmtx); } }
CVS commit: src/tests/rump/rumpkern
Module Name:src Committed By: hannken Date: Sat Mar 17 18:00:29 UTC 2012 Modified Files: src/tests/rump/rumpkern: t_vm.c Log Message: Starting with Rev. 1.191 of kern/subr_pool.c a pool has to be inactive for at least 10 seconds before it can be reclaimed. Change the uvmwait test timeout from 10 to 30 seconds so it has a chance to reclaim memory and succeed. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/rump/rumpkern/t_vm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/rump/rumpkern/t_vm.c diff -u src/tests/rump/rumpkern/t_vm.c:1.2 src/tests/rump/rumpkern/t_vm.c:1.3 --- src/tests/rump/rumpkern/t_vm.c:1.2 Mon Jun 14 21:06:09 2010 +++ src/tests/rump/rumpkern/t_vm.c Sat Mar 17 18:00:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_vm.c,v 1.2 2010/06/14 21:06:09 pooka Exp $ */ +/* $NetBSD: t_vm.c,v 1.3 2012/03/17 18:00:28 hannken Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ ATF_TC_HEAD(uvmwait, tc) { atf_tc_set_md_var(tc, descr, Tests that uvm_wait works); - atf_tc_set_md_var(tc, timeout, 10); + atf_tc_set_md_var(tc, timeout, 30); } #define UVMWAIT_LIMIT 1024*1024
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Mon Mar 26 16:28:08 UTC 2012 Modified Files: src/sys/dev: vnd.c vndvar.h Log Message: When backed by a sparse file limit the number of pending requests. Should fix PR #45829: writing to vnd on sparse file blocks on pager_map where the pager_map gets exhausted by requests enqueued on a vnd device and the device worker thread blocks on putpages() needing the map. While here always sync the underlying vnode before calling biodone(). XXX: vnd should be converted to mutex/condvar. To generate a diff of this commit: cvs rdiff -u -r1.219 -r1.220 src/sys/dev/vnd.c cvs rdiff -u -r1.31 -r1.32 src/sys/dev/vndvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.219 src/sys/dev/vnd.c:1.220 --- src/sys/dev/vnd.c:1.219 Fri Oct 14 09:23:30 2011 +++ src/sys/dev/vnd.c Mon Mar 26 16:28:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.219 2011/10/14 09:23:30 hannken Exp $ */ +/* $NetBSD: vnd.c,v 1.220 2012/03/26 16:28:08 hannken Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vnd.c,v 1.219 2011/10/14 09:23:30 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vnd.c,v 1.220 2012/03/26 16:28:08 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_vnd.h @@ -156,6 +156,8 @@ struct vndxfer { #define VNDLABELDEV(dev) \ (MAKEDISKDEV(major((dev)), vndunit((dev)), RAW_PART)) +#define VND_MAXPENDING(vnd) ((vnd)-sc_maxactive * 4) + /* called by main() at boot time */ void vndattach(int); @@ -496,6 +498,13 @@ vndstrategy(struct buf *bp) if (vnddebug VDB_FOLLOW) printf(vndstrategy(%p): unit %d\n, bp, unit); #endif + if ((vnd-sc_flags VNF_USE_VN_RDWR)) { + KASSERT(vnd-sc_pending = 0 + vnd-sc_pending = VND_MAXPENDING(vnd)); + while (vnd-sc_pending == VND_MAXPENDING(vnd)) + tsleep(vnd-sc_pending, PRIBIO, vndpc, 0); + vnd-sc_pending++; + } bufq_put(vnd-sc_tab, bp); wakeup(vnd-sc_tab); splx(s); @@ -587,6 +596,12 @@ vndthread(void *arg) tsleep(vnd-sc_tab, PRIBIO, vndbp, 0); continue; }; + if ((vnd-sc_flags VNF_USE_VN_RDWR)) { + KASSERT(vnd-sc_pending 0 + vnd-sc_pending = VND_MAXPENDING(vnd)); + if (vnd-sc_pending-- == VND_MAXPENDING(vnd)) +wakeup(vnd-sc_pending); + } splx(s); flags = obp-b_flags; #ifdef DEBUG @@ -722,13 +737,9 @@ handle_with_rdwr(struct vnd_softc *vnd, IO_ADV_ENCODE(POSIX_FADV_NOREUSE), vnd-sc_cred, resid, NULL); bp-b_resid = resid; - /* Keep mapped pages below threshold. */ mutex_enter(vp-v_interlock); - if (vp-v_uobj.uo_npages 1024*1024 / PAGE_SIZE) - (void) VOP_PUTPAGES(vp, 0, 0, - PGO_ALLPAGES | PGO_CLEANIT | PGO_FREE | PGO_SYNCIO); - else - mutex_exit(vp-v_interlock); + (void) VOP_PUTPAGES(vp, 0, 0, + PGO_ALLPAGES | PGO_CLEANIT | PGO_FREE | PGO_SYNCIO); /* We need to increase the number of outputs on the vnode if * there was any write to it. */ Index: src/sys/dev/vndvar.h diff -u src/sys/dev/vndvar.h:1.31 src/sys/dev/vndvar.h:1.32 --- src/sys/dev/vndvar.h:1.31 Wed Jun 29 09:12:42 2011 +++ src/sys/dev/vndvar.h Mon Mar 26 16:28:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vndvar.h,v 1.31 2011/06/29 09:12:42 hannken Exp $ */ +/* $NetBSD: vndvar.h,v 1.32 2012/03/26 16:28:08 hannken Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -113,6 +113,7 @@ struct vnd_softc { kauth_cred_t sc_cred; /* credentials */ int sc_maxactive; /* max # of active requests */ struct bufq_state *sc_tab; /* transfer queue */ + int sc_pending; /* number of pending transfers */ int sc_active; /* number of active transfers */ struct disk sc_dkdev; /* generic disk device info */ struct vndgeom sc_geom; /* virtual geometry */
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Thu Apr 5 07:26:37 UTC 2012 Modified Files: src/sys/kern: vfs_vnops.c Log Message: Fix vn_lock() to return an invalid (dead, clean) vnode only if the caller requested it by setting LK_RETRY. Should fix PR #46221: Kernel panic in NFS server code To generate a diff of this commit: cvs rdiff -u -r1.183 -r1.184 src/sys/kern/vfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnops.c diff -u src/sys/kern/vfs_vnops.c:1.183 src/sys/kern/vfs_vnops.c:1.184 --- src/sys/kern/vfs_vnops.c:1.183 Fri Oct 14 09:23:31 2011 +++ src/sys/kern/vfs_vnops.c Thu Apr 5 07:26:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnops.c,v 1.183 2011/10/14 09:23:31 hannken Exp $ */ +/* $NetBSD: vfs_vnops.c,v 1.184 2012/04/05 07:26:36 hannken Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_vnops.c,v 1.183 2011/10/14 09:23:31 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_vnops.c,v 1.184 2012/04/05 07:26:36 hannken Exp $); #include veriexec.h @@ -805,6 +805,15 @@ vn_lock(struct vnode *vp, int flags) } else { mutex_exit(vp-v_interlock); error = VOP_LOCK(vp, (flags ~LK_RETRY)); + if (error == 0 (flags LK_RETRY) == 0) { +mutex_enter(vp-v_interlock); +if ((vp-v_iflag VI_CLEAN)) { + mutex_exit(vp-v_interlock); + VOP_UNLOCK(vp); + return ENOENT; +} +mutex_exit(vp-v_interlock); + } if (error == 0 || error == EDEADLK || error == EBUSY) return (error); }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Mon Apr 9 11:10:07 UTC 2012 Modified Files: src/sys/fs/msdosfs: msdosfs_fat.c Log Message: pcbmap(): We cannot use bread() here as for the pagedaemon getblk() may fail leading to a panic in bread(). Replace bread() with getblk() / VOP_STRATEGY() and return an error if getblk() fails. Fixes PR#46282: 6.0_BETA crash: msdosfs_bmap - pcbmap - bread - bio_doread This is an interim solution for easy pullup. The final solution is be to change bread() to not return a buffer on error. As we have to change all callers of bread() this will not qualify for a pullup. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/fs/msdosfs/msdosfs_fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_fat.c diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.19 src/sys/fs/msdosfs/msdosfs_fat.c:1.20 --- src/sys/fs/msdosfs/msdosfs_fat.c:1.19 Tue Jan 26 20:25:52 2010 +++ src/sys/fs/msdosfs/msdosfs_fat.c Mon Apr 9 11:10:06 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_fat.c,v 1.19 2010/01/26 20:25:52 joerg Exp $ */ +/* $NetBSD: msdosfs_fat.c,v 1.20 2012/04/09 11:10:06 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.19 2010/01/26 20:25:52 joerg Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_fat.c,v 1.20 2012/04/09 11:10:06 hannken Exp $); /* * kernel include files. @@ -254,11 +254,26 @@ pcbmap(struct denode *dep, u_long findcn if (bn != bp_bn) { if (bp) brelse(bp, 0); - error = bread(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize, - NOCRED, 0, bp); - if (error) { -brelse(bp, 0); -return (error); + bp = getblk(pmp-pm_devvp, de_bn2kb(pmp, bn), bsize, + 0, 0); + if (bp == NULL) { +/* + * getblk() above returns NULL only iff we are + * pagedaemon. See the implementation of getblk + * for detail. + */ +return ENOMEM; + } + if (!ISSET(bp-b_oflags, (BO_DONE | BO_DELWRI))) { +SET(bp-b_flags, B_READ); +BIO_SETPRIO(bp, BPRIO_TIMECRITICAL); +VOP_STRATEGY(pmp-pm_devvp, bp); +curlwp-l_ru.ru_inblock++; +error = biowait(bp); +if (error) { + brelse(bp, 0); + return error; +} } bp_bn = bn; }
CVS commit: src/usr.sbin/fssconfig
Module Name:src Committed By: hannken Date: Mon Jun 11 15:25:14 UTC 2012 Modified Files: src/usr.sbin/fssconfig: fssconfig.8 Log Message: File system snapshots are no longer experimental. Forgot to chang this man page in Nov 2011. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/fssconfig/fssconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fssconfig/fssconfig.8 diff -u src/usr.sbin/fssconfig/fssconfig.8:1.7 src/usr.sbin/fssconfig/fssconfig.8:1.8 --- src/usr.sbin/fssconfig/fssconfig.8:1.7 Wed Apr 30 13:11:02 2008 +++ src/usr.sbin/fssconfig/fssconfig.8 Mon Jun 11 15:25:14 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: fssconfig.8,v 1.7 2008/04/30 13:11:02 martin Exp $ */ +.\ $NetBSD: fssconfig.8,v 1.8 2012/06/11 15:25:14 hannken Exp $ */ .\ .\ .\ Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd January 31, 2005 +.Dd June 11, 2012 .Dt FSSCONFIG 8 .Os .Sh NAME @@ -161,9 +161,3 @@ The .Nm command appeared in .Nx 2.0 . -.Sh BUGS -The -.Xr fss 4 -driver is -.Em experimental . -Be sure you have a backup before you use it.
CVS commit: src/sys/compat/netbsd32
Module Name:src Committed By: hannken Date: Tue Jan 15 17:14:11 UTC 2013 Modified Files: src/sys/compat/netbsd32: netbsd32_execve.c Log Message: netbsd32_posix_spawn_fa_alloc: use the right length for path allocation. This error lead to memory pool corruption when freeing kmem with wrong size. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/compat/netbsd32/netbsd32_execve.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/netbsd32/netbsd32_execve.c diff -u src/sys/compat/netbsd32/netbsd32_execve.c:1.36 src/sys/compat/netbsd32/netbsd32_execve.c:1.37 --- src/sys/compat/netbsd32/netbsd32_execve.c:1.36 Wed May 2 23:33:11 2012 +++ src/sys/compat/netbsd32/netbsd32_execve.c Tue Jan 15 17:14:11 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_execve.c,v 1.36 2012/05/02 23:33:11 rmind Exp $ */ +/* $NetBSD: netbsd32_execve.c,v 1.37 2013/01/15 17:14:11 hannken Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -28,7 +28,7 @@ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: netbsd32_execve.c,v 1.36 2012/05/02 23:33:11 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: netbsd32_execve.c,v 1.37 2013/01/15 17:14:11 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -141,7 +141,7 @@ netbsd32_posix_spawn_fa_alloc(struct pos MAXPATHLEN, slen); if (error) goto out; - fae-fae_path = kmem_alloc(fal, KM_SLEEP); + fae-fae_path = kmem_alloc(slen, KM_SLEEP); memcpy(fae-fae_path, pbuf, slen); fae-fae_oflag = f32-fae_oflag; fae-fae_mode = f32-fae_mode;
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Mon Jan 21 09:14:01 UTC 2013 Modified Files: src/sys/kern: vfs_trans.c Log Message: Replace the rwlock based implementation with passive serialization from pserialize(9) and mutex / condvar. The fast paths (fstrans_start/fstrans_done on a file system not suspended or suspending and fscow_run with no change pending) now run without locks or other atomic operations. Suspension and cow handler insertion and removal is done with mutex / condvars. The API remains unchanged. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.25 src/sys/kern/vfs_trans.c:1.26 --- src/sys/kern/vfs_trans.c:1.25 Tue May 12 11:42:12 2009 +++ src/sys/kern/vfs_trans.c Mon Jan 21 09:14:01 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.25 2009/05/12 11:42:12 yamt Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.26 2013/01/21 09:14:01 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_trans.c,v 1.25 2009/05/12 11:42:12 yamt Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_trans.c,v 1.26 2013/01/21 09:14:01 hannken Exp $); /* * File system transaction operations. @@ -38,16 +38,13 @@ __KERNEL_RCSID(0, $NetBSD: vfs_trans.c, #include opt_ddb.h -#if defined(DDB) -#define _LWP_API_PRIVATE /* Need _lwp_getspecific_by_lwp() */ -#endif - #include sys/param.h #include sys/systm.h +#include sys/atomic.h #include sys/buf.h #include sys/kmem.h #include sys/mount.h -#include sys/rwlock.h +#include sys/pserialize.h #include sys/vnode.h #define _FSTRANS_API_PRIVATE #include sys/fstrans.h @@ -57,34 +54,47 @@ __KERNEL_RCSID(0, $NetBSD: vfs_trans.c, #include miscfs/syncfs/syncfs.h struct fscow_handler { - SLIST_ENTRY(fscow_handler) ch_list; + LIST_ENTRY(fscow_handler) ch_list; int (*ch_func)(void *, struct buf *, bool); void *ch_arg; }; struct fstrans_lwp_info { struct fstrans_lwp_info *fli_succ; + struct lwp *fli_self; struct mount *fli_mount; int fli_trans_cnt; int fli_cow_cnt; enum fstrans_lock_type fli_lock_type; + LIST_ENTRY(fstrans_lwp_info) fli_list; }; struct fstrans_mount_info { enum fstrans_state fmi_state; - krwlock_t fmi_shared_lock; - krwlock_t fmi_lazy_lock; - krwlock_t fmi_cow_lock; - SLIST_HEAD(, fscow_handler) fmi_cow_handler; + unsigned int fmi_ref_cnt; + bool fmi_cow_change; + LIST_HEAD(, fscow_handler) fmi_cow_handler; }; -static specificdata_key_t lwp_data_key; +static specificdata_key_t lwp_data_key; /* Our specific data key. */ static kmutex_t vfs_suspend_lock; /* Serialize suspensions. */ -static pool_cache_t fstrans_cache; +static kmutex_t fstrans_lock; /* Fstrans big lock. */ +static kcondvar_t fstrans_state_cv; /* Fstrans or cow state changed. */ +static kcondvar_t fstrans_count_cv; /* Fstrans or cow count changed. */ +static pserialize_t fstrans_psz; /* Pserialize state. */ +static LIST_HEAD(fstrans_lwp_head, fstrans_lwp_info) fstrans_fli_head; + /* List of all fstrans_lwp_info. */ +static pool_cache_t fstrans_cache; /* Pool of struct fstrans_lwp_info. */ static void fstrans_lwp_dtor(void *); -static struct fstrans_lwp_info *fstrans_get_lwp_info(struct mount *); +static void fstrans_mount_dtor(struct mount *); +static struct fstrans_lwp_info *fstrans_get_lwp_info(struct mount *, bool); +static bool grant_lock(const enum fstrans_state, const enum fstrans_lock_type); +static bool state_change_done(const struct mount *); +static bool cow_state_change_done(const struct mount *); +static void cow_change_enter(const struct mount *); +static void cow_change_done(const struct mount *); /* - * Initialize + * Initialize. */ void fstrans_init(void) @@ -95,120 +105,183 @@ fstrans_init(void) KASSERT(error == 0); mutex_init(vfs_suspend_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(fstrans_lock, MUTEX_DEFAULT, IPL_NONE); + cv_init(fstrans_state_cv, fstchg); + cv_init(fstrans_count_cv, fstcnt); + fstrans_psz = pserialize_create(); + LIST_INIT(fstrans_fli_head); fstrans_cache = pool_cache_init(sizeof(struct fstrans_lwp_info), 0, 0, 0, fstrans, NULL, IPL_NONE, NULL, NULL, NULL); } /* - * Deallocate lwp state + * Deallocate lwp state. */ static void fstrans_lwp_dtor(void *arg) { struct fstrans_lwp_info *fli, *fli_next; + mutex_enter(fstrans_lock); for (fli = arg; fli; fli = fli_next) { KASSERT(fli-fli_trans_cnt == 0); KASSERT(fli-fli_cow_cnt == 0); + if (fli-fli_mount != NULL) + fstrans_mount_dtor(fli-fli_mount); fli_next = fli-fli_succ; + LIST_REMOVE(fli, fli_list); pool_cache_put(fstrans_cache, fli); } + mutex_exit(fstrans_lock); +} + +/* + * Dereference mount state. + */ +static void +fstrans_mount_dtor(struct mount *mp) +{ + struct fstrans_mount_info
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: hannken Date: Fri Jan 25 17:12:33 UTC 2013 Modified Files: src/sys/arch/sparc64/sparc64: pmap.c Log Message: Update the DEBUG section at the tail of pmap_clear_modify(). Nothing prevents page modification after the modify bit was cleared but before the DEBUG section checks pmap_is_modified(), so remove this check. For the same reason modified and changed may differ, so only check modified implies changed here. Ok: Matthew Green m...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.279 -r1.280 src/sys/arch/sparc64/sparc64/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/sparc64/pmap.c diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.279 src/sys/arch/sparc64/sparc64/pmap.c:1.280 --- src/sys/arch/sparc64/sparc64/pmap.c:1.279 Thu Jan 3 09:40:55 2013 +++ src/sys/arch/sparc64/sparc64/pmap.c Fri Jan 25 17:12:33 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.279 2013/01/03 09:40:55 martin Exp $ */ +/* $NetBSD: pmap.c,v 1.280 2013/01/25 17:12:33 hannken Exp $ */ /* * * Copyright (C) 1996-1999 Eduardo Horvath. @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.279 2013/01/03 09:40:55 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.280 2013/01/25 17:12:33 hannken Exp $); #undef NO_VCACHE /* Don't forget the locked TLB in dostart */ #define HWREF @@ -2577,17 +2577,13 @@ pmap_clear_modify(struct vm_page *pg) pv_check(); mutex_exit(pmap_lock); #ifdef DEBUG - if (pmap_is_modified(pg)) { - printf(pmap_clear_modify(): %p still modified!\n, pg); - Debugger(); - } DPRINTF(PDB_CHANGEPROT|PDB_REF, (pmap_clear_modify: pg %p %s\n, pg, (changed ? was modified : was not modified))); - if (modified != changed) { + if (modified modified != changed) { printf(pmap_clear_modify: modified %d changed %d\n, modified, changed); Debugger(); - } else return (modified); + } #endif return (changed); }
CVS commit: src/tests/fs
Module Name:src Committed By: hannken Date: Wed Feb 6 09:05:01 UTC 2013 Modified Files: src/tests/fs/common: snapshot.c src/tests/fs/ffs: t_snapshot.c t_snapshot_log.c t_snapshot_v2.c src/tests/fs/msdosfs: t_snapshot.c Log Message: Test taking a snapshot from a stressed file system. Checks snapshot meta data only with fsck. OK: Antti Kantee po...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/fs/common/snapshot.c cvs rdiff -u -r1.5 -r1.6 src/tests/fs/ffs/t_snapshot.c cvs rdiff -u -r1.1 -r1.2 src/tests/fs/ffs/t_snapshot_log.c \ src/tests/fs/ffs/t_snapshot_v2.c cvs rdiff -u -r1.1 -r1.2 src/tests/fs/msdosfs/t_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/common/snapshot.c diff -u src/tests/fs/common/snapshot.c:1.6 src/tests/fs/common/snapshot.c:1.7 --- src/tests/fs/common/snapshot.c:1.6 Sat Feb 12 18:13:46 2011 +++ src/tests/fs/common/snapshot.c Wed Feb 6 09:05:01 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: snapshot.c,v 1.6 2011/02/12 18:13:46 bouyer Exp $ */ +/* $NetBSD: snapshot.c,v 1.7 2013/02/06 09:05:01 hannken Exp $ */ #include sys/types.h #include sys/ioctl.h @@ -8,6 +8,7 @@ #include atf-c.h #include fcntl.h +#include pthread.h #include stdio.h #include stdlib.h #include string.h @@ -114,8 +115,114 @@ ATF_TC_CLEANUP(snapshot, tc) unlink(IMGNAME); } +ATF_TC_WITH_CLEANUP(snapshotstress); +ATF_TC_HEAD(snapshotstress, tc) +{ + + atf_tc_set_md_var(tc, descr, snapshot on active file system); +} + +#define NACTIVITY 4 + +static bool activity_stop = false; +static pid_t wrkpid; + +static void * +fs_activity(void *arg) +{ + int di, fi; + char *prefix = arg, path[128]; + + rump_pub_lwproc_newlwp(wrkpid); + + RL(rump_sys_mkdir(prefix, 0777)); + while (! activity_stop) { + for (di = 0; di 5; di++) { + snprintf(path, sizeof(path), %s/d%d, prefix, di); + RL(rump_sys_mkdir(path, 0777)); + for (fi = 0; fi 5; fi++) { +snprintf(path, sizeof(path), %s/d%d/f%d, +prefix, di, fi); +makefile(path); + } + } + for (di = 0; di 5; di++) { + for (fi = 0; fi 5; fi++) { +snprintf(path, sizeof(path), %s/d%d/f%d, +prefix, di, fi); +RL(rump_sys_unlink(path)); + } + snprintf(path, sizeof(path), %s/d%d, prefix, di); + RL(rump_sys_rmdir(path)); + } + } + RL(rump_sys_rmdir(prefix)); + + rump_pub_lwproc_releaselwp(); + + return NULL; +} + +ATF_TC_BODY(snapshotstress, tc) +{ + pthread_t at[NACTIVITY]; + struct fss_set fss; + char prefix[NACTIVITY][128]; + int i, fssfd; + + if (system(NEWFS) == -1) + atf_tc_fail_errno(cannot create file system); + /* Force SMP so the stress makes sense. */ + RL(setenv(RUMP_NCPU, 4, 1)); + RZ(rump_init()); + /* Prepare for fsck to use the RUMP /dev/fss0. */ + RL(rump_init_server(unix://commsock)); + RL(setenv(LD_PRELOAD, /usr/lib/librumphijack.so, 1)); + RL(setenv(RUMP_SERVER, unix://commsock, 1)); + RL(setenv(RUMPHIJACK, blanket=/dev/rfss0, 1)); + begin(); + + RL(rump_sys_mkdir(/mnt, 0777)); + + rump_pub_etfs_register(/diskdev, IMGNAME, RUMP_ETFS_BLK); + + mount_diskfs(/diskdev, /mnt); + + /* Start file system activity. */ + RL(wrkpid = rump_sys_getpid()); + for (i = 0; i NACTIVITY; i++) { + snprintf(prefix[i], sizeof(prefix[i]), /mnt/a%d, i); + RL(pthread_create(at[i], NULL, fs_activity, prefix[i])); + sleep(1); + } + + fssfd = rump_sys_open(/dev/rfss0, O_RDWR); + if (fssfd == -1) + atf_tc_fail_errno(cannot open fss); + makefile(BAKNAME); + memset(fss, 0, sizeof(fss)); + fss.fss_mount = __UNCONST(/mnt); + fss.fss_bstore = __UNCONST(BAKNAME); + fss.fss_csize = 0; + if (rump_sys_ioctl(fssfd, FSSIOCSET, fss) == -1) + atf_tc_fail_errno(create snapshot); + + activity_stop = true; + for (i = 0; i NACTIVITY; i++) + RL(pthread_join(at[i], NULL)); + + RL(system(FSCK /dev/rfss0)); +} + +ATF_TC_CLEANUP(snapshotstress, tc) +{ + + unlink(IMGNAME); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, snapshot); + ATF_TP_ADD_TC(tp, snapshotstress); return 0; } Index: src/tests/fs/ffs/t_snapshot.c diff -u src/tests/fs/ffs/t_snapshot.c:1.5 src/tests/fs/ffs/t_snapshot.c:1.6 --- src/tests/fs/ffs/t_snapshot.c:1.5 Fri Nov 5 11:31:15 2010 +++ src/tests/fs/ffs/t_snapshot.c Wed Feb 6 09:05:01 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_snapshot.c,v 1.5 2010/11/05 11:31:15 pooka Exp $ */ +/* $NetBSD: t_snapshot.c,v 1.6 2013/02/06 09:05:01 hannken Exp $ */ #include sys/types.h #include sys/mount.h @@ -19,6 +19,7 @@ #define IMGNAME ffs.img #define NEWFS newfs -F -s 1 IMGNAME +#define FSCK fsck_ffs -fn -F #define BAKNAME /mnt/le_snapp static void Index: src/tests/fs/ffs/t_snapshot_log.c diff -u src/tests/fs/ffs/t_snapshot_log.c:1.1 src/tests/fs/ffs/t_snapshot_log.c:1.2 --- src/tests/fs/ffs/t_snapshot_log.c:1.1 Fri Nov 5 11:32:09 2010 +++ src/tests/fs/ffs/t_snapshot_log.c Wed Feb 6 09:05:01 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_snapshot_log.c,v 1.1
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Wed Feb 6 09:29:46 UTC 2013 Modified Files: src/sys/dev: fss.c Log Message: Take fss_device_lock first when closing a fss device. Fixes PR kern/47514 (Multiple dump -X triggers kernel panic in fss_ioctl) To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.83 src/sys/dev/fss.c:1.84 --- src/sys/dev/fss.c:1.83 Sat Jul 28 16:14:17 2012 +++ src/sys/dev/fss.c Wed Feb 6 09:29:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.84 2013/02/06 09:29:46 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.84 2013/02/06 09:29:46 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -223,11 +223,13 @@ fss_close(dev_t dev, int flags, int mode mflag = (mode == S_IFCHR ? FSS_CDEV_OPEN : FSS_BDEV_OPEN); error = 0; + mutex_enter(fss_device_lock); restart: mutex_enter(sc-sc_slock); if ((sc-sc_flags (FSS_CDEV_OPEN|FSS_BDEV_OPEN)) != mflag) { sc-sc_flags = ~mflag; mutex_exit(sc-sc_slock); + mutex_exit(fss_device_lock); return 0; } if ((sc-sc_flags FSS_ACTIVE) != 0 @@ -239,12 +241,9 @@ restart: } if ((sc-sc_flags FSS_ACTIVE) != 0) { mutex_exit(sc-sc_slock); + mutex_exit(fss_device_lock); return error; } - if (! mutex_tryenter(fss_device_lock)) { - mutex_exit(sc-sc_slock); - goto restart; - } KASSERT((sc-sc_flags FSS_ACTIVE) == 0); KASSERT((sc-sc_flags (FSS_CDEV_OPEN|FSS_BDEV_OPEN)) == mflag);
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Wed Feb 6 09:33:17 UTC 2013 Modified Files: src/sys/dev: fss.c Log Message: Lookup the block device mounted on from the specfs_hash table. This doesn't belong here but makes it possible to pullup. Fixes PR kern/47020 (fss(4) panic) To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.84 src/sys/dev/fss.c:1.85 --- src/sys/dev/fss.c:1.84 Wed Feb 6 09:29:46 2013 +++ src/sys/dev/fss.c Wed Feb 6 09:33:16 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.84 2013/02/06 09:29:46 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.85 2013/02/06 09:33:16 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.84 2013/02/06 09:29:46 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.85 2013/02/06 09:33:16 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -620,7 +620,7 @@ static int fss_create_files(struct fss_softc *sc, struct fss_set *fss, off_t *bsize, struct lwp *l) { - int error, bits, fsbsize; + int i, error, bits, fsbsize; uint64_t numsec; unsigned int secsize; struct timespec ts; @@ -691,25 +691,31 @@ fss_create_files(struct fss_softc *sc, s vrele(vp); /* - * Get the block device it is mounted on. + * Get the block device it is mounted on and its size. */ - error = namei_simple_kernel(sc-sc_mount-mnt_stat.f_mntfromname, -NSM_FOLLOW_NOEMULROOT, vp); - if (error != 0) - return error; - - if (vp-v_type != VBLK) { - vrele(vp); + mutex_enter(device_lock); + for (i = 0; i SPECHSZ; i++) { + for (vp = specfs_hash[i]; vp; vp = vp-v_specnext) { + if (vp-v_type == VBLK + vp == vp-v_specnode-sn_dev-sd_bdevvp + vp-v_specmountpoint == sc-sc_mount) +break; + } + if (vp != NULL) + break; + } + if (vp == NULL) { + mutex_exit(device_lock); return EINVAL; } - + mutex_enter(vp-v_interlock); + mutex_exit(device_lock); + error = vget(vp, 0); + if (error) + return error; sc-sc_bdev = vp-v_rdev; - /* - * Get the block device size. - */ - error = getdisksize(vp, numsec, secsize); vrele(vp); if (error)
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Wed Feb 13 14:03:49 UTC 2013 Modified Files: src/sys/dev: fss.c src/sys/kern: vfs_mount.c vfs_subr.c vfs_vnode.c src/sys/miscfs/specfs: spec_vnops.c specdev.h src/sys/sys: param.h Log Message: Make the spec_node table implementation private to spec_vnops.c. To retrieve a spec_node, two new lookup functions (by device or by mount) are implemented. Both return a referenced vnode, for an opened block device the opened vnode is returned so further diagnostic checks vp == ... sd_bdevvp will not fire. Otherwise any vnode matching the criteria gets returned. No objections on tech-kern. Welcome to 6.99.17 To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/dev/fss.c cvs rdiff -u -r1.16 -r1.17 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.435 -r1.436 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.18 -r1.19 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.136 -r1.137 src/sys/miscfs/specfs/spec_vnops.c cvs rdiff -u -r1.39 -r1.40 src/sys/miscfs/specfs/specdev.h cvs rdiff -u -r1.424 -r1.425 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.85 src/sys/dev/fss.c:1.86 --- src/sys/dev/fss.c:1.85 Wed Feb 6 09:33:16 2013 +++ src/sys/dev/fss.c Wed Feb 13 14:03:48 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.85 2013/02/06 09:33:16 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.86 2013/02/13 14:03:48 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.85 2013/02/06 09:33:16 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.86 2013/02/13 14:03:48 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -620,7 +620,7 @@ static int fss_create_files(struct fss_softc *sc, struct fss_set *fss, off_t *bsize, struct lwp *l) { - int i, error, bits, fsbsize; + int error, bits, fsbsize; uint64_t numsec; unsigned int secsize; struct timespec ts; @@ -694,24 +694,7 @@ fss_create_files(struct fss_softc *sc, s * Get the block device it is mounted on and its size. */ - mutex_enter(device_lock); - for (i = 0; i SPECHSZ; i++) { - for (vp = specfs_hash[i]; vp; vp = vp-v_specnext) { - if (vp-v_type == VBLK - vp == vp-v_specnode-sn_dev-sd_bdevvp - vp-v_specmountpoint == sc-sc_mount) -break; - } - if (vp != NULL) - break; - } - if (vp == NULL) { - mutex_exit(device_lock); - return EINVAL; - } - mutex_enter(vp-v_interlock); - mutex_exit(device_lock); - error = vget(vp, 0); + error = spec_node_lookup_by_mount(sc-sc_mount, vp); if (error) return error; sc-sc_bdev = vp-v_rdev; Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.16 src/sys/kern/vfs_mount.c:1.17 --- src/sys/kern/vfs_mount.c:1.16 Fri Dec 14 18:39:48 2012 +++ src/sys/kern/vfs_mount.c Wed Feb 13 14:03:48 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.16 2012/12/14 18:39:48 pooka Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.17 2013/02/13 14:03:48 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_mount.c,v 1.16 2012/12/14 18:39:48 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_mount.c,v 1.17 2013/02/13 14:03:48 hannken Exp $); #include sys/param.h #include sys/kernel.h @@ -1252,19 +1252,14 @@ vfs_mountedon(vnode_t *vp) if (vp-v_type != VBLK) return ENOTBLK; if (vp-v_specmountpoint != NULL) - return (EBUSY); - mutex_enter(device_lock); - for (vq = specfs_hash[SPECHASH(vp-v_rdev)]; vq != NULL; - vq = vq-v_specnext) { - if (vq-v_type != vp-v_type || vq-v_rdev != vp-v_rdev) - continue; - if (vq-v_specmountpoint != NULL) { + return EBUSY; + if (spec_node_lookup_by_dev(vp-v_type, vp-v_rdev, vq) == 0) { + if (vq-v_specmountpoint != NULL) error = EBUSY; - break; - } + vrele(vq); } - mutex_exit(device_lock); - return (error); + + return error; } /* Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.435 src/sys/kern/vfs_subr.c:1.436 --- src/sys/kern/vfs_subr.c:1.435 Sat May 12 18:42:08 2012 +++ src/sys/kern/vfs_subr.c Wed Feb 13 14:03:48 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.435 2012/05/12 18:42:08 chs Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.436 2013/02/13 14:03:48 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_subr.c,v 1.435 2012/05/12 18:42:08 chs Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_subr.c,v 1.436 2013/02/13 14:03:48 hannken Exp $); #include opt_ddb.h #include opt_compat_netbsd.h @@ -513,23 +513,8 @@ getdevvp(dev_t dev, vnode_t **vpp, enum int vfinddev(dev_t dev, enum vtype type, vnode_t **vpp) { - vnode_t *vp; - mutex_enter(device_lock); - for (vp =
CVS commit: src/sys/miscfs
Module Name:src Committed By: hannken Date: Sun Oct 16 12:26:16 UTC 2011 Modified Files: src/sys/miscfs/fdesc: fdesc_vnops.c src/sys/miscfs/procfs: procfs_map.c Log Message: VOP_GETATTR() needs a shared lock at least. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/miscfs/fdesc/fdesc_vnops.c cvs rdiff -u -r1.40 -r1.41 src/sys/miscfs/procfs/procfs_map.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/fdesc/fdesc_vnops.c diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.113 src/sys/miscfs/fdesc/fdesc_vnops.c:1.114 --- src/sys/miscfs/fdesc/fdesc_vnops.c:1.113 Sun Jun 12 03:35:58 2011 +++ src/sys/miscfs/fdesc/fdesc_vnops.c Sun Oct 16 12:26:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fdesc_vnops.c,v 1.113 2011/06/12 03:35:58 rmind Exp $ */ +/* $NetBSD: fdesc_vnops.c,v 1.114 2011/10/16 12:26:16 hannken Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fdesc_vnops.c,v 1.113 2011/06/12 03:35:58 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: fdesc_vnops.c,v 1.114 2011/10/16 12:26:16 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -446,7 +446,9 @@ fdesc_attr(int fd, struct vattr *vap, ka switch (fp-f_type) { case DTYPE_VNODE: + vn_lock((struct vnode *) fp-f_data, LK_SHARED | LK_RETRY); error = VOP_GETATTR((struct vnode *) fp-f_data, vap, cred); + VOP_UNLOCK((struct vnode *) fp-f_data); if (error == 0 vap-va_type == VDIR) { /* * directories can cause loops in the namespace, Index: src/sys/miscfs/procfs/procfs_map.c diff -u src/sys/miscfs/procfs/procfs_map.c:1.40 src/sys/miscfs/procfs/procfs_map.c:1.41 --- src/sys/miscfs/procfs/procfs_map.c:1.40 Tue Jul 26 13:18:55 2011 +++ src/sys/miscfs/procfs/procfs_map.c Sun Oct 16 12:26:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_map.c,v 1.40 2011/07/26 13:18:55 yamt Exp $ */ +/* $NetBSD: procfs_map.c,v 1.41 2011/10/16 12:26:16 hannken Exp $ */ /* * Copyright (c) 1993 @@ -76,7 +76,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: procfs_map.c,v 1.40 2011/07/26 13:18:55 yamt Exp $); +__KERNEL_RCSID(0, $NetBSD: procfs_map.c,v 1.41 2011/10/16 12:26:16 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -162,7 +162,9 @@ again: if (UVM_ET_ISOBJ(entry) UVM_OBJ_IS_VNODE(entry-object.uvm_obj)) { vp = (struct vnode *)entry-object.uvm_obj; +vn_lock(vp, LK_SHARED | LK_RETRY); error = VOP_GETATTR(vp, va, curl-l_cred); +VOP_UNLOCK(vp); if (error == 0 vp != pfs-pfs_vnode) { fileid = va.va_fileid; dev = va.va_fsid;
CVS commit: src/sys/fs/nilfs
Module Name:src Committed By: hannken Date: Sun Oct 16 12:41:46 UTC 2011 Modified Files: src/sys/fs/nilfs: nilfs_vnops.c Log Message: VOP_GETATTR() needs a shared lock at least. While here fix a typo (fvp - tvp). To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/fs/nilfs/nilfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/nilfs/nilfs_vnops.c diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.14 src/sys/fs/nilfs/nilfs_vnops.c:1.15 --- src/sys/fs/nilfs/nilfs_vnops.c:1.14 Tue Sep 27 01:34:41 2011 +++ src/sys/fs/nilfs/nilfs_vnops.c Sun Oct 16 12:41:45 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nilfs_vnops.c,v 1.14 2011/09/27 01:34:41 christos Exp $ */ +/* $NetBSD: nilfs_vnops.c,v 1.15 2011/10/16 12:41:45 hannken Exp $ */ /* * Copyright (c) 2008, 2009 Reinoud Zandijk @@ -28,7 +28,7 @@ #include sys/cdefs.h #ifndef lint -__KERNEL_RCSID(0, $NetBSD: nilfs_vnops.c,v 1.14 2011/09/27 01:34:41 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: nilfs_vnops.c,v 1.15 2011/10/16 12:41:45 hannken Exp $); #endif /* not lint */ @@ -1330,13 +1330,15 @@ nilfs_rename(void *v) } /* get info about the node to be moved */ + vn_lock(fvp, LK_SHARED | LK_RETRY); error = VOP_GETATTR(fvp, fvap, FSCRED); + VOP_UNLOCK(fvp); KASSERT(error == 0); /* check when to delete the old already existing entry */ if (tvp) { /* get info about the node to be moved to */ - error = VOP_GETATTR(fvp, tvap, FSCRED); + error = VOP_GETATTR(tvp, tvap, FSCRED); KASSERT(error == 0); /* if both dirs, make sure the destination is empty */
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Tue Oct 18 09:22:53 UTC 2011 Modified Files: src/sys/fs/union: union_subr.c union_vnops.c Log Message: VOP_GETATTR() needs a shared lock at least. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.46 -r1.47 src/sys/fs/union/union_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.50 src/sys/fs/union/union_subr.c:1.51 --- src/sys/fs/union/union_subr.c:1.50 Tue Aug 23 07:39:37 2011 +++ src/sys/fs/union/union_subr.c Tue Oct 18 09:22:53 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.50 2011/08/23 07:39:37 hannken Exp $ */ +/* $NetBSD: union_subr.c,v 1.51 2011/10/18 09:22:53 hannken Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.50 2011/08/23 07:39:37 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.51 2011/10/18 09:22:53 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -472,9 +472,13 @@ loop: if (uppervp != NULLVP) if (VOP_GETATTR(uppervp, va, FSCRED) == 0) uppersz = va.va_size; - if (lowervp != NULLVP) - if (VOP_GETATTR(lowervp, va, FSCRED) == 0) + if (lowervp != NULLVP) { + vn_lock(lowervp, LK_SHARED | LK_RETRY); + error = VOP_GETATTR(lowervp, va, FSCRED); + VOP_UNLOCK(lowervp); + if (error == 0) lowersz = va.va_size; + } hash = UNION_HASH(uppervp, lowervp); /* @@ -1213,18 +1217,16 @@ union_readdirhook(struct vnode **vpp, st if (vp-v_op != union_vnodeop_p) return (0); - if ((lvp = union_dircache(vp, l)) == NULLVP) - return (0); - /* * If the directory is opaque, * then don't show lower entries */ error = VOP_GETATTR(vp, va, fp-f_cred); - if (error || (va.va_flags OPAQUE)) { - vput(lvp); - return (error); - } + if (error || (va.va_flags OPAQUE)) + return error; + + if ((lvp = union_dircache(vp, l)) == NULLVP) + return (0); error = VOP_OPEN(lvp, FREAD, fp-f_cred); if (error) { Index: src/sys/fs/union/union_vnops.c diff -u src/sys/fs/union/union_vnops.c:1.46 src/sys/fs/union/union_vnops.c:1.47 --- src/sys/fs/union/union_vnops.c:1.46 Tue Aug 23 07:39:37 2011 +++ src/sys/fs/union/union_vnops.c Tue Oct 18 09:22:53 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vnops.c,v 1.46 2011/08/23 07:39:37 hannken Exp $ */ +/* $NetBSD: union_vnops.c,v 1.47 2011/10/18 09:22:53 hannken Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995 @@ -72,7 +72,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_vnops.c,v 1.46 2011/08/23 07:39:37 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: union_vnops.c,v 1.47 2011/10/18 09:22:53 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -830,14 +830,6 @@ union_getattr(void *v) vp = un-un_uppervp; if (vp != NULLVP) { - /* - * It's not clear whether VOP_GETATTR is to be - * called with the vnode locked or not. stat() calls - * it with (vp) locked, and fstat calls it with - * (vp) unlocked. - * In the mean time, compensate here by checking - * the union_node's lock flag. - */ if (un-un_flags UN_LOCKED) FIXUP(un); @@ -858,7 +850,11 @@ union_getattr(void *v) } if (vp != NULLVP) { + if (vp == un-un_lowervp) + vn_lock(vp, LK_SHARED | LK_RETRY); error = VOP_GETATTR(vp, vap, ap-a_cred); + if (vp == un-un_lowervp) + VOP_UNLOCK(vp); if (error) return (error); union_newsize(ap-a_vp, VNOVAL, vap-va_size);
CVS commit: src/sys/fs/udf
Module Name:src Committed By: hannken Date: Tue Oct 18 20:20:30 UTC 2011 Modified Files: src/sys/fs/udf: udf_vnops.c Log Message: VOP_GETATTR() needs a shared lock at least. While here fix a typo (fvp - tvp). To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/fs/udf/udf_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/udf/udf_vnops.c diff -u src/sys/fs/udf/udf_vnops.c:1.67 src/sys/fs/udf/udf_vnops.c:1.68 --- src/sys/fs/udf/udf_vnops.c:1.67 Tue Sep 27 01:33:30 2011 +++ src/sys/fs/udf/udf_vnops.c Tue Oct 18 20:20:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_vnops.c,v 1.67 2011/09/27 01:33:30 christos Exp $ */ +/* $NetBSD: udf_vnops.c,v 1.68 2011/10/18 20:20:29 hannken Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -32,7 +32,7 @@ #include sys/cdefs.h #ifndef lint -__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.67 2011/09/27 01:33:30 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.68 2011/10/18 20:20:29 hannken Exp $); #endif /* not lint */ @@ -1978,13 +1978,15 @@ udf_rename(void *v) } /* get info about the node to be moved */ + vn_lock(fvp, LK_SHARED | LK_RETRY); error = VOP_GETATTR(fvp, fvap, FSCRED); + VOP_UNLOCK(fvp); KASSERT(error == 0); /* check when to delete the old already existing entry */ if (tvp) { /* get info about the node to be moved to */ - error = VOP_GETATTR(fvp, tvap, FSCRED); + error = VOP_GETATTR(tvp, tvap, FSCRED); KASSERT(error == 0); /* if both dirs, make sure the destination is empty */
CVS commit: src/sys/fs/smbfs
Module Name:src Committed By: hannken Date: Sun Oct 23 08:42:06 UTC 2011 Modified Files: src/sys/fs/smbfs: smbfs_kq.c Log Message: VOP_GETATTR() needs a shared lock at least. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/fs/smbfs/smbfs_kq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/smbfs/smbfs_kq.c diff -u src/sys/fs/smbfs/smbfs_kq.c:1.23 src/sys/fs/smbfs/smbfs_kq.c:1.24 --- src/sys/fs/smbfs/smbfs_kq.c:1.23 Sun Jun 12 03:35:54 2011 +++ src/sys/fs/smbfs/smbfs_kq.c Sun Oct 23 08:42:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: smbfs_kq.c,v 1.23 2011/06/12 03:35:54 rmind Exp $ */ +/* $NetBSD: smbfs_kq.c,v 1.24 2011/10/23 08:42:06 hannken Exp $ */ /*- * Copyright (c) 2003, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: smbfs_kq.c,v 1.23 2011/06/12 03:35:54 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: smbfs_kq.c,v 1.24 2011/10/23 08:42:06 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -149,7 +149,9 @@ smbfs_kqpoll(void *arg) /* save v_size, smbfs_getattr() updates it */ osize = ke-vp-v_size; + vn_lock(ke-vp, LK_SHARED | LK_RETRY); error = VOP_GETATTR(ke-vp, attr, l-l_cred); + VOP_UNLOCK(ke-vp); if (error) { /* relock and proceed with next */ mutex_enter(smbkq_lock); @@ -458,7 +460,9 @@ smbfs_kqfilter(void *v) * held. This is likely cheap due to attrcache, so do it now. */ memset(attr, 0, sizeof(attr)); + vn_lock(vp, LK_SHARED | LK_RETRY); (void) VOP_GETATTR(vp, attr, l-l_cred); + VOP_UNLOCK(vp); /* ensure the handler is running */ /* XXX this is unreliable. */
CVS commit: src/sys/nfs
Module Name:src Committed By: hannken Date: Mon Oct 24 11:43:31 UTC 2011 Modified Files: src/sys/nfs: nfs_kq.c nfs_vfsops.c Log Message: VOP_GETATTR() needs a shared lock at least. As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize the attrributes to zero -- nfs_kqfilter() does the same. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/nfs/nfs_kq.c cvs rdiff -u -r1.219 -r1.220 src/sys/nfs/nfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/nfs/nfs_kq.c diff -u src/sys/nfs/nfs_kq.c:1.24 src/sys/nfs/nfs_kq.c:1.25 --- src/sys/nfs/nfs_kq.c:1.24 Sun Jun 12 03:35:59 2011 +++ src/sys/nfs/nfs_kq.c Mon Oct 24 11:43:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_kq.c,v 1.24 2011/06/12 03:35:59 rmind Exp $ */ +/* $NetBSD: nfs_kq.c,v 1.25 2011/10/24 11:43:30 hannken Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: nfs_kq.c,v 1.24 2011/06/12 03:35:59 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: nfs_kq.c,v 1.25 2011/10/24 11:43:30 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -138,7 +138,10 @@ nfs_kqpoll(void *arg) /* save v_size, nfs_getattr() updates it */ osize = ke-vp-v_size; + memset(attr, 0, sizeof(attr)); + vn_lock(ke-vp, LK_SHARED | LK_RETRY); (void) VOP_GETATTR(ke-vp, attr, l-l_cred); + VOP_UNLOCK(ke-vp); /* following is a bit fragile, but about best * we can get */ @@ -318,7 +321,9 @@ nfs_kqfilter(void *v) * held. This is likely cheap due to attrcache, so do it now. */ memset(attr, 0, sizeof(attr)); + vn_lock(vp, LK_SHARED | LK_RETRY); (void) VOP_GETATTR(vp, attr, l-l_cred); + VOP_UNLOCK(vp); mutex_enter(nfskq_lock); Index: src/sys/nfs/nfs_vfsops.c diff -u src/sys/nfs/nfs_vfsops.c:1.219 src/sys/nfs/nfs_vfsops.c:1.220 --- src/sys/nfs/nfs_vfsops.c:1.219 Fri Oct 7 09:35:06 2011 +++ src/sys/nfs/nfs_vfsops.c Mon Oct 24 11:43:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_vfsops.c,v 1.219 2011/10/07 09:35:06 hannken Exp $ */ +/* $NetBSD: nfs_vfsops.c,v 1.220 2011/10/24 11:43:30 hannken Exp $ */ /* * Copyright (c) 1989, 1993, 1995 @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.219 2011/10/07 09:35:06 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.220 2011/10/24 11:43:30 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_nfs.h @@ -387,7 +387,9 @@ nfs_mountroot(void) vfs_unbusy(mp, false, NULL); /* Get root attributes (for the time). */ + vn_lock(vp, LK_SHARED | LK_RETRY); error = VOP_GETATTR(vp, attr, l-l_cred); + VOP_UNLOCK(vp); if (error) panic(nfs_mountroot: getattr for root); n = attr.va_atime.tv_sec;
CVS commit: src/sys/nfs
Module Name:src Committed By: hannken Date: Sun Oct 30 12:00:28 UTC 2011 Modified Files: src/sys/nfs: nfs_serv.c Log Message: VOP_GETATTR() needs a shared lock at least. To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.161 src/sys/nfs/nfs_serv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/nfs/nfs_serv.c diff -u src/sys/nfs/nfs_serv.c:1.160 src/sys/nfs/nfs_serv.c:1.161 --- src/sys/nfs/nfs_serv.c:1.160 Mon Aug 8 16:04:07 2011 +++ src/sys/nfs/nfs_serv.c Sun Oct 30 12:00:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_serv.c,v 1.160 2011/08/08 16:04:07 dholland Exp $ */ +/* $NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -55,7 +55,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.160 2011/08/08 16:04:07 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -454,8 +454,11 @@ nfsrv_lookup(struct nfsrv_descript *nfsd } if (dirp) { - if (v3) + if (v3) { + vn_lock(dirp, LK_SHARED | LK_RETRY); dirattr_ret = VOP_GETATTR(dirp, dirattr, cred); + VOP_UNLOCK(dirp); + } vrele(dirp); } @@ -1582,7 +1585,9 @@ nfsrv_create(struct nfsrv_descript *nfsd error = EEXIST; } if (dirp) { + vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, diraft, cred); + VOP_UNLOCK(dirp); } } if (dirp) { @@ -1741,7 +1746,9 @@ out: vput(vp); } if (dirp) { + vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, diraft, cred); + VOP_UNLOCK(dirp); vrele(dirp); dirp = NULL; } @@ -1810,8 +1817,12 @@ nfsrv_remove(struct nfsrv_descript *nfsd nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(nd, nsfh, len, slp, nam, md, dpos, dirp, lwp, (nfsd-nd_flag ND_KERBAUTH), false); - if (dirp v3) { + if (error == 0 dirp v3) { + if (nd.ni_dvp == nd.ni_vp) + vn_lock(dirp, LK_SHARED | LK_RETRY); dirfor_ret = VOP_GETATTR(dirp, dirfor, cred); + if (nd.ni_dvp == nd.ni_vp) + VOP_UNLOCK(dirp); } if (!error) { vp = nd.ni_vp; @@ -1845,7 +1856,9 @@ out: } if (dirp) { if (v3) { + vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, diraft, cred); + VOP_UNLOCK(dirp); } vrele(dirp); } @@ -1902,8 +1915,12 @@ nfsrv_rename(struct nfsrv_descript *nfsd fromnd.ni_cnd.cn_flags = LOCKPARENT | INRENAME; error = nfs_namei(fromnd, fnsfh, len, slp, nam, md, dpos, fdirp, lwp, (nfsd-nd_flag ND_KERBAUTH), false); - if (fdirp v3) { + if (error == 0 fdirp v3) { + if (fromnd.ni_dvp == fromnd.ni_vp) + vn_lock(fdirp, LK_SHARED | LK_RETRY); fdirfor_ret = VOP_GETATTR(fdirp, fdirfor, cred); + if (fromnd.ni_dvp == fromnd.ni_vp) + VOP_UNLOCK(fdirp); } if (error) { nfsm_reply(2 * NFSX_WCCDATA(v3)); @@ -2070,14 +2087,18 @@ out: out1: if (fdirp) { if (v3) { + vn_lock(fdirp, LK_SHARED | LK_RETRY); fdiraft_ret = VOP_GETATTR(fdirp, fdiraft, cred); + VOP_UNLOCK(fdirp); } vrele(fdirp); fdirp = NULL; } if (tdirp) { if (v3) { + vn_lock(tdirp, LK_SHARED | LK_RETRY); tdiraft_ret = VOP_GETATTR(tdirp, tdiraft, cred); + VOP_UNLOCK(tdirp); } vrele(tdirp); tdirp = NULL; @@ -2192,11 +2213,16 @@ out: vrele(nd.ni_vp); } out1: - if (v3) + if (v3) { + vn_lock(vp, LK_SHARED | LK_RETRY); getret = VOP_GETATTR(vp, at, cred); + VOP_UNLOCK(vp); + } if (dirp) { if (v3) { + vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, diraft, cred); + VOP_UNLOCK(dirp); } vrele(dirp); } @@ -2315,7 +2341,9 @@ out: free(pathcp, M_TEMP); if (dirp) { if (v3) { + vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, diraft, cred); + VOP_UNLOCK(dirp); } vrele(dirp); dirp = NULL; @@ -2436,7 +2464,9 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, out: if (dirp) { if (v3) { + vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, diraft, cred); + VOP_UNLOCK(dirp); } vrele(dirp); dirp = NULL; @@ -2559,7 +2589,9 @@ out: } if (dirp) { if (v3) { + vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, diraft, cred); + VOP_UNLOCK(dirp); } vrele(dirp); }
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: hannken Date: Sun Oct 30 13:24:13 UTC 2011 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: Add a comment that pn_sizemtx should be useless as VOP_GETATTR now needs a shared lock at least. To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.161 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.160 src/sys/fs/puffs/puffs_vnops.c:1.161 --- src/sys/fs/puffs/puffs_vnops.c:1.160 Wed Oct 19 01:39:29 2011 +++ src/sys/fs/puffs/puffs_vnops.c Sun Oct 30 13:24:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.160 2011/10/19 01:39:29 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.161 2011/10/30 13:24:13 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.160 2011/10/19 01:39:29 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.161 2011/10/30 13:24:13 hannken Exp $); #include sys/param.h #include sys/buf.h @@ -848,6 +848,9 @@ puffs_vnop_getattr(void *v) * data is replaced by zeroes). This can be removed if * we decide one day that VOP_GETATTR must operate on * a locked vnode. + * + * XXX Should be useless now that VOP_GETATTR has been + * fixed to always require a shared lock at least. */ mutex_enter(pn-pn_sizemtx);
CVS commit: src/sys/dev/pci
Module Name:src Committed By: hannken Date: Wed Nov 2 14:34:09 UTC 2011 Modified Files: src/sys/dev/pci: ld_virtio.c Log Message: Make sure we allocate enough segments for the request dma maps. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/ld_virtio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ld_virtio.c diff -u src/sys/dev/pci/ld_virtio.c:1.1 src/sys/dev/pci/ld_virtio.c:1.2 --- src/sys/dev/pci/ld_virtio.c:1.1 Sun Oct 30 12:12:21 2011 +++ src/sys/dev/pci/ld_virtio.c Wed Nov 2 14:34:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_virtio.c,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ +/* $NetBSD: ld_virtio.c,v 1.2 2011/11/02 14:34:09 hannken Exp $ */ /* * Copyright (c) 2010 Minoura Makoto. @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ld_virtio.c,v 1.1 2011/10/30 12:12:21 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: ld_virtio.c,v 1.2 2011/11/02 14:34:09 hannken Exp $); #include rnd.h @@ -194,7 +194,8 @@ ld_virtio_alloc_reqs(struct ld_virtio_so } r = bus_dmamap_create(sc-sc_virtio-sc_dmat, ld-sc_maxxfer, - ld-sc_maxxfer / NBPG, ld-sc_maxxfer, + (ld-sc_maxxfer / NBPG) + 1, + ld-sc_maxxfer, 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, vr-vr_payload);
CVS commit: src
Module Name:src Committed By: hannken Date: Sat Nov 5 09:22:44 UTC 2011 Modified Files: src/distrib/sets/lists/man: mi src/share/man/man4: Makefile ld.4 Added Files: src/share/man/man4: virtio.4 Log Message: Document virtio(4). To generate a diff of this commit: cvs rdiff -u -r1.1351 -r1.1352 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.572 -r1.573 src/share/man/man4/Makefile cvs rdiff -u -r1.18 -r1.19 src/share/man/man4/ld.4 cvs rdiff -u -r0 -r1.1 src/share/man/man4/virtio.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/man/mi diff -u src/distrib/sets/lists/man/mi:1.1351 src/distrib/sets/lists/man/mi:1.1352 --- src/distrib/sets/lists/man/mi:1.1351 Thu Oct 27 22:12:24 2011 +++ src/distrib/sets/lists/man/mi Sat Nov 5 09:22:43 2011 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1351 2011/10/27 22:12:24 rkujawa Exp $ +# $NetBSD: mi,v 1.1352 2011/11/05 09:22:43 hannken Exp $ # # Note: don't delete entries from here - mark them as obsolete instead. # @@ -1786,6 +1786,7 @@ ./usr/share/man/cat4/video.0 man-sys-catman .cat ./usr/share/man/cat4/vinum.0 man-obsolete obsolete ./usr/share/man/cat4/virt.0 man-sys-catman .cat +./usr/share/man/cat4/virtio.0 man-sys-catman .cat ./usr/share/man/cat4/vlan.0 man-sys-catman .cat ./usr/share/man/cat4/vmmon.0 man-sys-catman .cat ./usr/share/man/cat4/vmnet.0 man-sys-catman .cat @@ -4544,6 +4545,7 @@ ./usr/share/man/html4/viaide.html man-sys-htmlman html ./usr/share/man/html4/video.html man-sys-htmlman html ./usr/share/man/html4/virt.html man-sys-htmlman html +./usr/share/man/html4/virtio.html man-sys-htmlman html ./usr/share/man/html4/vlan.html man-sys-htmlman html ./usr/share/man/html4/vmmon.html man-sys-htmlman html ./usr/share/man/html4/vmnet.html man-sys-htmlman html @@ -7237,6 +7239,7 @@ ./usr/share/man/man4/video.4 man-sys-man .man ./usr/share/man/man4/vinum.4 man-obsolete obsolete ./usr/share/man/man4/virt.4 man-sys-man .man +./usr/share/man/man4/virtio.4 man-sys-man .man ./usr/share/man/man4/vlan.4 man-sys-man .man ./usr/share/man/man4/vmmon.4 man-sys-man .man ./usr/share/man/man4/vmnet.4 man-sys-man .man Index: src/share/man/man4/Makefile diff -u src/share/man/man4/Makefile:1.572 src/share/man/man4/Makefile:1.573 --- src/share/man/man4/Makefile:1.572 Tue Oct 18 10:19:12 2011 +++ src/share/man/man4/Makefile Sat Nov 5 09:22:44 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.572 2011/10/18 10:19:12 wiz Exp $ +# $NetBSD: Makefile,v 1.573 2011/11/05 09:22:44 hannken Exp $ # @(#)Makefile 8.1 (Berkeley) 6/18/93 MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \ @@ -60,8 +60,8 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 a ti.4 tl.4 tlp.4 tlphy.4 \ tp.4 tr.4 tra.4 trm.4 tty.4 tun.4 tqphy.4 twa.4 twe.4 txp.4 \ uark.4 ubsec.4 udp.4 uep.4 ug.4 uha.4 uk.4 ukphy.4 unix.4 userconf.4 \ - vald.4 veriexec.4 vga.4 vge.4 viaide.4 video.4 virt.4 vlan.4 vmmon.4 \ - vmnet.4 vnd.4 vr.4 vte.4 \ + vald.4 veriexec.4 vga.4 vge.4 viaide.4 video.4 virt.4 virtio.4 vlan.4 \ + vmmon.4 vmnet.4 vnd.4 vr.4 vte.4 \ wapbl.4 wb.4 wbsio.4 wd.4 wdc.4 wi.4 wm.4 wpi.4 \ wscons.4 wsdisplay.4 wsfont.4 wskbd.4 wsmouse.4 wsmux.4 \ xbox.4 xge.4 \ Index: src/share/man/man4/ld.4 diff -u src/share/man/man4/ld.4:1.18 src/share/man/man4/ld.4:1.19 --- src/share/man/man4/ld.4:1.18 Wed Apr 22 07:19:50 2009 +++ src/share/man/man4/ld.4 Sat Nov 5 09:22:44 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: ld.4,v 1.18 2009/04/22 07:19:50 wiz Exp $ +.\ $NetBSD: ld.4,v 1.19 2011/11/05 09:22:44 hannken Exp $ .\ .\ Copyright (c) 2000 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -27,7 +27,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd April 22, 2009 +.Dd November 5, 2011 .Dt LD 4 .Os .Sh NAME @@ -36,6 +36,7 @@ .Sh SYNOPSIS .Cd ld* at aac? unit ? .Cd ld* at amr? unit ? +.Cd ld* at ataraid? vendtype ? unit ? .Cd ld* at cac? unit ? .Cd ld* at icp? unit ? .Cd ld* at iop? tid ? @@ -43,7 +44,7 @@ .Cd ld* at sdmmc? .Cd ld* at twa? unit ? .Cd ld* at twe? unit ? -.Cd ld* at ataraid? vendtype ? unit ? +.Cd ld* at virtio? .Sh DESCRIPTION The .Nm @@ -72,7 +73,8 @@ partition .Xr mlx 4 , .Xr sdmmc 4 , .Xr twa 4 , -.Xr twe 4 +.Xr twe 4 , +.Xr virtio 4 .Sh HISTORY The .Nm Added files: Index: src/share/man/man4/virtio.4 diff -u /dev/null src/share/man/man4/virtio.4:1.1 --- /dev/null Sat Nov 5 09:22:44 2011 +++ src/share/man/man4/virtio.4 Sat Nov 5 09:22:44 2011 @@ -0,0 +1,63 @@ +.\ $NetBSD: virtio.4,v 1.1 2011/11/05 09:22:44 hannken Exp $ +.\ +.\ Copyright (c) 2011 The NetBSD Foundation, Inc. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Mon Nov 7 08:44:16 UTC 2011 Modified Files: src/sys/kern: bufq_priocscan.c Log Message: Move an assertion to the right place. Ok: YAMAMOTO Takashi y...@netbsd.org Fixes PR #45578 (kernel crash with BUFQ_PRIOCSCAN) To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/kern/bufq_priocscan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/bufq_priocscan.c diff -u src/sys/kern/bufq_priocscan.c:1.15 src/sys/kern/bufq_priocscan.c:1.16 --- src/sys/kern/bufq_priocscan.c:1.15 Wed Nov 2 15:14:49 2011 +++ src/sys/kern/bufq_priocscan.c Mon Nov 7 08:44:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: bufq_priocscan.c,v 1.15 2011/11/02 15:14:49 yamt Exp $ */ +/* $NetBSD: bufq_priocscan.c,v 1.16 2011/11/07 08:44:16 hannken Exp $ */ /*- * Copyright (c)2004,2005,2006,2008,2009 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: bufq_priocscan.c,v 1.15 2011/11/02 15:14:49 yamt Exp $); +__KERNEL_RCSID(0, $NetBSD: bufq_priocscan.c,v 1.16 2011/11/07 08:44:16 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -297,8 +297,8 @@ bufq_priocscan_get(struct bufq_state *bu * * XXX account only by number of requests. is it good enough? */ - KASSERT(pq-q_burst 0); if (remove) { + KASSERT(pq-q_burst 0); pq-q_burst--; } }
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: hannken Date: Mon Nov 14 16:04:30 UTC 2011 Modified Files: src/sys/arch/xen/xen: xbdback_xenbus.c Log Message: Bring back sys/disklabel.h for DISKUNIT and DISKPART. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/arch/xen/xen/xbdback_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xbdback_xenbus.c diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.49 src/sys/arch/xen/xen/xbdback_xenbus.c:1.50 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.49 Sun Nov 13 23:02:06 2011 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Mon Nov 14 16:04:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.49 2011/11/13 23:02:06 christos Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.50 2011/11/14 16:04:29 hannken Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: xbdback_xenbus.c,v 1.49 2011/11/13 23:02:06 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: xbdback_xenbus.c,v 1.50 2011/11/14 16:04:29 hannken Exp $); #include sys/types.h #include sys/param.h @@ -38,6 +38,7 @@ __KERNEL_RCSID(0, $NetBSD: xbdback_xenb #include sys/conf.h #include sys/disk.h #include sys/device.h +#include sys/disklabel.h #include sys/fcntl.h #include sys/vnode.h #include sys/kauth.h
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Mon Nov 14 18:35:15 UTC 2011 Modified Files: src/sys/fs/adosfs: advfsops.c src/sys/fs/cd9660: cd9660_vfsops.c src/sys/fs/filecorefs: filecore_vfsops.c src/sys/fs/hfs: hfs_subr.c src/sys/fs/msdosfs: msdosfs_vfsops.c src/sys/fs/nilfs: nilfs_vfsops.c src/sys/fs/ntfs: ntfs_vfsops.c src/sys/fs/udf: udf_vfsops.c src/sys/ufs/ext2fs: ext2fs_vfsops.c src/sys/ufs/ffs: ffs_vfsops.c src/sys/ufs/lfs: lfs_vfsops.c Log Message: VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount() implementations need more review. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/fs/adosfs/advfsops.c cvs rdiff -u -r1.73 -r1.74 src/sys/fs/cd9660/cd9660_vfsops.c cvs rdiff -u -r1.67 -r1.68 src/sys/fs/filecorefs/filecore_vfsops.c cvs rdiff -u -r1.16 -r1.17 src/sys/fs/hfs/hfs_subr.c cvs rdiff -u -r1.92 -r1.93 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.7 -r1.8 src/sys/fs/nilfs/nilfs_vfsops.c cvs rdiff -u -r1.86 -r1.87 src/sys/fs/ntfs/ntfs_vfsops.c cvs rdiff -u -r1.61 -r1.62 src/sys/fs/udf/udf_vfsops.c cvs rdiff -u -r1.161 -r1.162 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.270 -r1.271 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.290 -r1.291 src/sys/ufs/lfs/lfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/adosfs/advfsops.c diff -u src/sys/fs/adosfs/advfsops.c:1.62 src/sys/fs/adosfs/advfsops.c:1.63 --- src/sys/fs/adosfs/advfsops.c:1.62 Sun Jun 12 03:35:52 2011 +++ src/sys/fs/adosfs/advfsops.c Mon Nov 14 18:35:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: advfsops.c,v 1.62 2011/06/12 03:35:52 rmind Exp $ */ +/* $NetBSD: advfsops.c,v 1.63 2011/11/14 18:35:12 hannken Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: advfsops.c,v 1.62 2011/06/12 03:35:52 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: advfsops.c,v 1.63 2011/11/14 18:35:12 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -176,9 +176,13 @@ adosfs_mountfs(struct vnode *devvp, stru /* * open blkdev and read root block */ - if ((error = VOP_OPEN(devvp, FREAD, NOCRED)) != 0) + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); + if ((error = VOP_OPEN(devvp, FREAD, NOCRED)) != 0) { + VOP_UNLOCK(devvp); return (error); + } error = VOP_IOCTL(devvp, DIOCGDINFO, dl, FREAD, NOCRED); + VOP_UNLOCK(devvp); if (error) goto fail; Index: src/sys/fs/cd9660/cd9660_vfsops.c diff -u src/sys/fs/cd9660/cd9660_vfsops.c:1.73 src/sys/fs/cd9660/cd9660_vfsops.c:1.74 --- src/sys/fs/cd9660/cd9660_vfsops.c:1.73 Tue Sep 27 01:01:43 2011 +++ src/sys/fs/cd9660/cd9660_vfsops.c Mon Nov 14 18:35:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_vfsops.c,v 1.73 2011/09/27 01:01:43 christos Exp $ */ +/* $NetBSD: cd9660_vfsops.c,v 1.74 2011/11/14 18:35:12 hannken Exp $ */ /*- * Copyright (c) 1994 @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: cd9660_vfsops.c,v 1.73 2011/09/27 01:01:43 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: cd9660_vfsops.c,v 1.74 2011/11/14 18:35:12 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -271,7 +271,9 @@ cd9660_mount(struct mount *mp, const cha return (error); } if ((mp-mnt_flag MNT_UPDATE) == 0) { + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(devvp, FREAD, FSCRED); + VOP_UNLOCK(devvp); if (error) goto fail; error = iso_mountfs(devvp, mp, l, args); Index: src/sys/fs/filecorefs/filecore_vfsops.c diff -u src/sys/fs/filecorefs/filecore_vfsops.c:1.67 src/sys/fs/filecorefs/filecore_vfsops.c:1.68 --- src/sys/fs/filecorefs/filecore_vfsops.c:1.67 Sun Jun 12 03:35:52 2011 +++ src/sys/fs/filecorefs/filecore_vfsops.c Mon Nov 14 18:35:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: filecore_vfsops.c,v 1.67 2011/06/12 03:35:52 rmind Exp $ */ +/* $NetBSD: filecore_vfsops.c,v 1.68 2011/11/14 18:35:13 hannken Exp $ */ /*- * Copyright (c) 1994 The Regents of the University of California. @@ -66,7 +66,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: filecore_vfsops.c,v 1.67 2011/06/12 03:35:52 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: filecore_vfsops.c,v 1.68 2011/11/14 18:35:13 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_compat_netbsd.h @@ -326,7 +326,9 @@ filecore_mountfs(struct vnode *devvp, st if ((error = vinvalbuf(devvp, V_SAVE, l-l_cred, l, 0, 0)) != 0) return (error); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED); + VOP_UNLOCK(devvp); if (error) return error; Index: src/sys/fs/hfs/hfs_subr.c diff -u src/sys/fs/hfs/hfs_subr.c:1.16 src/sys/fs/hfs/hfs_subr.c:1.17 --- src/sys/fs/hfs/hfs_subr.c:1.16 Sun Nov 13 23:03:55 2011 +++ src/sys/fs/hfs/hfs_subr.c Mon Nov 14 18:35:13 2011 @@ -1,4 +1,4 @@ -/*
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Mon Nov 14 18:38:14 UTC 2011 Modified Files: src/sys/fs/union: union_subr.c Log Message: Remove a needless vnode lock/unlock dance. This is a leftover from the removal of VOP_LEASE(). Function union_removed_upper() always works on unlocked upper vnodes so remove the test-and-unlock and add an assertion. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/fs/union/union_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.51 src/sys/fs/union/union_subr.c:1.52 --- src/sys/fs/union/union_subr.c:1.51 Tue Oct 18 09:22:53 2011 +++ src/sys/fs/union/union_subr.c Mon Nov 14 18:38:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.51 2011/10/18 09:22:53 hannken Exp $ */ +/* $NetBSD: union_subr.c,v 1.52 2011/11/14 18:38:13 hannken Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.51 2011/10/18 09:22:53 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.52 2011/11/14 18:38:13 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -638,11 +638,6 @@ union_copyfile(struct vnode *fvp, struct uio.uio_offset = 0; UIO_SETUP_SYSSPACE(uio); - VOP_UNLOCK(fvp); /* XXX */ - vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY); /* XXX */ - VOP_UNLOCK(tvp); /* XXX */ - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); /* XXX */ - tbuf = malloc(MAXBSIZE, M_TEMP, M_WAITOK); /* ugly loop follows... */ @@ -961,6 +956,7 @@ union_removed_upper(struct union_node *u { int hash; + KASSERT((un-un_flags UN_ULOCK) == 0); #if 1 /* * We do not set the uppervp to NULLVP here, because lowervp @@ -984,11 +980,6 @@ union_removed_upper(struct union_node *u LIST_REMOVE(un, un_cache); } mutex_exit(unheadlock[hash]); - - if (un-un_flags UN_ULOCK) { - un-un_flags = ~UN_ULOCK; - VOP_UNLOCK(un-un_uppervp); - } } #if 0
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Mon Nov 14 18:42:57 UTC 2011 Modified Files: src/sys/fs/union: union_vnops.c Log Message: VOP_ABORTOP() has no specific lock requirements so there is no need to force locked vnodes here. It should be impossible to come here with a nil upper node. Relock the directory vnode after copyup. A locked union node with an unlocked upper vnode can no longer exist so make FIXUP() an assertion. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/fs/union/union_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_vnops.c diff -u src/sys/fs/union/union_vnops.c:1.47 src/sys/fs/union/union_vnops.c:1.48 --- src/sys/fs/union/union_vnops.c:1.47 Tue Oct 18 09:22:53 2011 +++ src/sys/fs/union/union_vnops.c Mon Nov 14 18:42:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vnops.c,v 1.47 2011/10/18 09:22:53 hannken Exp $ */ +/* $NetBSD: union_vnops.c,v 1.48 2011/11/14 18:42:57 hannken Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995 @@ -72,7 +72,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_vnops.c,v 1.47 2011/10/18 09:22:53 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: union_vnops.c,v 1.48 2011/11/14 18:42:57 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -134,7 +134,6 @@ int union_getpages(void *); int union_putpages(void *); int union_kqfilter(void *); -static void union_fixup(struct union_node *); static int union_lookup1(struct vnode *, struct vnode **, struct vnode **, struct componentname *); @@ -190,23 +189,12 @@ const struct vnodeopv_entry_desc union_v const struct vnodeopv_desc union_vnodeop_opv_desc = { union_vnodeop_p, union_vnodeop_entries }; -#define FIXUP(un) { \ - if (((un)-un_flags UN_ULOCK) == 0) { \ - union_fixup(un); \ - } \ -} +#define FIXUP(un) \ + KASSERT(((un)-un_flags UN_ULOCK) == UN_ULOCK) #define NODE_IS_SPECIAL(vp) \ ((vp)-v_type == VBLK || (vp)-v_type == VCHR || \ (vp)-v_type == VSOCK || (vp)-v_type == VFIFO) -static void -union_fixup(struct union_node *un) -{ - - vn_lock(un-un_uppervp, LK_EXCLUSIVE | LK_RETRY); - un-un_flags |= UN_ULOCK; -} - static int union_lookup1(struct vnode *udvp, struct vnode **dvpp, struct vnode **vpp, struct componentname *cnp) @@ -1248,6 +1236,9 @@ union_link(void *v) } error = union_copyup(un, 1, cnp-cn_cred, curlwp); if (dun-un_uppervp == un-un_dirvp) { +vn_lock(dun-un_uppervp, +LK_EXCLUSIVE | LK_RETRY); +dun-un_flags |= UN_ULOCK; /* * During copyup, we dropped the lock on the * dir and invalidated any saved namei lookup @@ -1583,24 +1574,11 @@ union_abortop(void *v) struct vnode *a_dvp; struct componentname *a_cnp; } */ *ap = v; - int error; - struct vnode *vp = OTHERVP(ap-a_dvp); - struct union_node *un = VTOUNION(ap-a_dvp); - int islocked = un-un_flags UN_LOCKED; - int dolock = (vp == LOWERVP(ap-a_dvp)); - if (islocked) { - if (dolock) - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - else - FIXUP(VTOUNION(ap-a_dvp)); - } - ap-a_dvp = vp; - error = VCALL(vp, VOFFSET(vop_abortop), ap); - if (islocked dolock) - VOP_UNLOCK(vp); + KASSERT(UPPERVP(ap-a_dvp) != NULL); - return (error); + ap-a_dvp = UPPERVP(ap-a_dvp); + return VCALL(ap-a_dvp, VOFFSET(vop_abortop), ap); } int
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sun Nov 20 10:32:33 UTC 2011 Modified Files: src/sys/kern: kern_verifiedexec.c Log Message: Fix locking against self in veriexec_fp_calc(). To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/kern/kern_verifiedexec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_verifiedexec.c diff -u src/sys/kern/kern_verifiedexec.c:1.127 src/sys/kern/kern_verifiedexec.c:1.128 --- src/sys/kern/kern_verifiedexec.c:1.127 Fri Oct 14 09:23:31 2011 +++ src/sys/kern/kern_verifiedexec.c Sun Nov 20 10:32:33 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_verifiedexec.c,v 1.127 2011/10/14 09:23:31 hannken Exp $ */ +/* $NetBSD: kern_verifiedexec.c,v 1.128 2011/11/20 10:32:33 hannken Exp $ */ /*- * Copyright (c) 2005, 2006 Elad Efrat e...@netbsd.org @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: kern_verifiedexec.c,v 1.127 2011/10/14 09:23:31 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: kern_verifiedexec.c,v 1.128 2011/11/20 10:32:33 hannken Exp $); #include opt_veriexec.h @@ -411,9 +411,11 @@ veriexec_fp_calc(struct lwp *l, struct v size_t resid, npages; int error, do_perpage, pagen; - vn_lock(vp, LK_SHARED | LK_RETRY); + if (lock_state == VERIEXEC_UNLOCKED) + vn_lock(vp, LK_SHARED | LK_RETRY); error = VOP_GETATTR(vp, va, l-l_cred); - VOP_UNLOCK(vp); + if (lock_state == VERIEXEC_UNLOCKED) + VOP_UNLOCK(vp); if (error) return (error);
CVS commit: src/sys/nfs
Module Name:src Committed By: hannken Date: Mon Nov 21 09:08:00 UTC 2011 Modified Files: src/sys/nfs: nfs_serv.c Log Message: nfsrv_lookup(): Defer the postopattr lookup on dirp until the child node is unlocked. Ok: YAMAMOTO Takashi y...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 src/sys/nfs/nfs_serv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/nfs/nfs_serv.c diff -u src/sys/nfs/nfs_serv.c:1.161 src/sys/nfs/nfs_serv.c:1.162 --- src/sys/nfs/nfs_serv.c:1.161 Sun Oct 30 12:00:27 2011 +++ src/sys/nfs/nfs_serv.c Mon Nov 21 09:07:59 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $ */ +/* $NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -55,7 +55,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -453,15 +453,6 @@ nfsrv_lookup(struct nfsrv_descript *nfsd } } - if (dirp) { - if (v3) { - vn_lock(dirp, LK_SHARED | LK_RETRY); - dirattr_ret = VOP_GETATTR(dirp, dirattr, cred); - VOP_UNLOCK(dirp); - } - vrele(dirp); - } - if (error) { if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); @@ -469,6 +460,14 @@ nfsrv_lookup(struct nfsrv_descript *nfsd if (ipb != NULL) { pathbuf_destroy(ipb); } + if (dirp) { + if (v3) { +vn_lock(dirp, LK_SHARED | LK_RETRY); +dirattr_ret = VOP_GETATTR(dirp, dirattr, cred); +vput(dirp); + } else +vrele(dirp); + } nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(dirattr_ret, dirattr); return (0); @@ -484,6 +483,14 @@ nfsrv_lookup(struct nfsrv_descript *nfsd if (!error) error = VOP_GETATTR(vp, va, cred); vput(vp); + if (dirp) { + if (v3) { + vn_lock(dirp, LK_SHARED | LK_RETRY); + dirattr_ret = VOP_GETATTR(dirp, dirattr, cred); + vput(dirp); + } else + vrele(dirp); + } nfsm_reply(NFSX_SRVFH(nsfh, v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); if (error) {
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Mon Nov 21 10:46:57 UTC 2011 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: Add missing fstrans_done(). Should fix PR #45635 (KASSERT fli-fli_trans_cnt == 0 failed) To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.78 src/sys/fs/msdosfs/msdosfs_vnops.c:1.79 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.78 Wed Jul 20 11:52:00 2011 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Mon Nov 21 10:46:56 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.78 2011/07/20 11:52:00 hannken Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.79 2011/11/21 10:46:56 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.78 2011/07/20 11:52:00 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.79 2011/11/21 10:46:56 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -499,8 +499,10 @@ msdosfs_read(void *v) lbn = de_cluster(pmp, uio-uio_offset); on = uio-uio_offset pmp-pm_crbomask; n = MIN(pmp-pm_bpcluster - on, uio-uio_resid); - if (uio-uio_offset = dep-de_FileSize) + if (uio-uio_offset = dep-de_FileSize) { + fstrans_done(vp-v_mount); return (0); + } /* file size (and hence diff) may be up to 4GB */ diff = dep-de_FileSize - uio-uio_offset; if (diff n)
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Mon Nov 21 18:29:23 UTC 2011 Modified Files: src/sys/fs/union: union.h union_subr.c union_vfsops.c union_vnops.c Log Message: Replace flag based union node locking with generic vnode lock, support shared and nowait locks and protect un_uppervp and un_*sz with mutex. Mark file system MPSAFE. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/fs/union/union.h cvs rdiff -u -r1.52 -r1.53 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.64 -r1.65 src/sys/fs/union/union_vfsops.c cvs rdiff -u -r1.48 -r1.49 src/sys/fs/union/union_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union.h diff -u src/sys/fs/union/union.h:1.21 src/sys/fs/union/union.h:1.22 --- src/sys/fs/union/union.h:1.21 Tue Aug 23 07:39:37 2011 +++ src/sys/fs/union/union.h Mon Nov 21 18:29:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union.h,v 1.21 2011/08/23 07:39:37 hannken Exp $ */ +/* $NetBSD: union.h,v 1.22 2011/11/21 18:29:22 hannken Exp $ */ /* * Copyright (c) 1994 The Regents of the University of California. @@ -105,28 +105,36 @@ struct union_mount { #define UN_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) /* - * A cache of vnode references + * A cache of vnode references. + * Lock requirements are: + * + * : stable + * c unheadlock[hash] + * l un_lock + * m un_lock or vnode lock to read, un_lock and + * exclusive vnode lock to write + * v vnode lock to read, exclusive vnode lock to write + * + * Lock order is vnode then un_lock. */ struct union_node { - LIST_ENTRY(union_node) un_cache; /* Hash chain */ - struct vnode *un_vnode; /* Back pointer */ - struct vnode *un_uppervp; /* overlaying object */ - struct vnode *un_lowervp; /* underlying object */ - struct vnode *un_dirvp; /* Parent dir of uppervp */ - struct vnode *un_pvp; /* Parent vnode */ - char *un_path; /* saved component name */ - int un_hash; /* saved un_path hash value */ - int un_openl; /* # of opens on lowervp */ - unsigned int un_flags; - struct vnode **un_dircache; /* cached union stack */ - off_t un_uppersz; /* size of upper object */ - off_t un_lowersz; /* size of lower object */ - lwp_t *un_lwp; /* DIAGNOSTIC only */ + kmutex_t un_lock; + LIST_ENTRY(union_node) un_cache; /* c: Hash chain */ + struct vnode *un_vnode; /* :: Back pointer */ + struct vnode *un_uppervp; /* m: overlaying object */ + struct vnode *un_lowervp; /* v: underlying object */ + struct vnode *un_dirvp; /* v: Parent dir of uppervp */ + struct vnode *un_pvp; /* v: Parent vnode */ + char *un_path; /* v: saved component name */ + int un_hash; /* v: saved un_path hash */ + int un_openl; /* v: # of opens on lowervp */ + unsigned int un_flags; /* v: node flags */ + unsigned int un_cflags; /* c: cache flags */ + struct vnode **un_dircache; /* v: cached union stack */ + off_t un_uppersz; /* l: size of upper object */ + off_t un_lowersz; /* l: size of lower object */ }; -#define UN_WANTED 0x01 -#define UN_LOCKED 0x02 -#define UN_ULOCK 0x04 /* Upper node is locked */ #define UN_KLOCK 0x08 /* Keep upper node locked on vput */ #define UN_CACHED 0x10 /* In union cache */ @@ -162,6 +170,7 @@ int union_readdirhook(struct vnode **, s #define LOWERVP(vp) (VTOUNION(vp)-un_lowervp) #define UPPERVP(vp) (VTOUNION(vp)-un_uppervp) #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp)) +#define LOCKVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : (vp)) extern int (**union_vnodeop_p)(void *); Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.52 src/sys/fs/union/union_subr.c:1.53 --- src/sys/fs/union/union_subr.c:1.52 Mon Nov 14 18:38:13 2011 +++ src/sys/fs/union/union_subr.c Mon Nov 21 18:29:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.52 2011/11/14 18:38:13 hannken Exp $ */ +/* $NetBSD: union_subr.c,v 1.53 2011/11/21 18:29:22 hannken Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.52 2011/11/14 18:38:13 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.53 2011/11/21 18:29:22 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -93,6 +93,7 @@ __KERNEL_RCSID(0, $NetBSD: union_subr.c #include uvm/uvm_extern.h #include fs/union/union.h +#include miscfs/genfs/genfs.h #include miscfs/specfs/specdev.h /* must be power of two, otherwise change UNION_HASH() */ @@ -145,7 +146,9 @@ union_updatevp(struct union_node *un, st int nhash = UNION_HASH(uppervp, lowervp); int docache = (lowervp != NULLVP || uppervp != NULLVP); int lhash, uhash; + bool un_unlock; + KASSERT(VOP_ISLOCKED(UNIONTOV(un)) == LK_EXCLUSIVE); /* * Ensure locking is ordered from lower to higher * to avoid deadlocks. @@ -164,8 +167,8 @@ union_updatevp(struct union_node *un, st mutex_enter(unheadlock[uhash]); if
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Wed Nov 23 19:39:11 UTC 2011 Modified Files: src/sys/fs/union: union.h union_subr.c union_vfsops.c Log Message: Use hashinit() / hashdone() to create the union node hash list. Cleanup the hash lookup in union_allocvp(). Needs more work as there is still a possible deadlock between union_allocvp() and vclean(). To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/fs/union/union.h cvs rdiff -u -r1.53 -r1.54 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.65 -r1.66 src/sys/fs/union/union_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union.h diff -u src/sys/fs/union/union.h:1.22 src/sys/fs/union/union.h:1.23 --- src/sys/fs/union/union.h:1.22 Mon Nov 21 18:29:22 2011 +++ src/sys/fs/union/union.h Wed Nov 23 19:39:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union.h,v 1.22 2011/11/21 18:29:22 hannken Exp $ */ +/* $NetBSD: union.h,v 1.23 2011/11/23 19:39:11 hannken Exp $ */ /* * Copyright (c) 1994 The Regents of the University of California. @@ -175,6 +175,7 @@ int union_readdirhook(struct vnode **, s extern int (**union_vnodeop_p)(void *); void union_init(void); +void union_reinit(void); void union_done(void); int union_freevp(struct vnode *); Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.53 src/sys/fs/union/union_subr.c:1.54 --- src/sys/fs/union/union_subr.c:1.53 Mon Nov 21 18:29:22 2011 +++ src/sys/fs/union/union_subr.c Wed Nov 23 19:39:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.53 2011/11/21 18:29:22 hannken Exp $ */ +/* $NetBSD: union_subr.c,v 1.54 2011/11/23 19:39:11 hannken Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.53 2011/11/21 18:29:22 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.54 2011/11/23 19:39:11 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -96,15 +96,13 @@ __KERNEL_RCSID(0, $NetBSD: union_subr.c #include miscfs/genfs/genfs.h #include miscfs/specfs/specdev.h -/* must be power of two, otherwise change UNION_HASH() */ -#define NHASH 32 - -/* unsigned int ... */ +static LIST_HEAD(uhashhead, union_node) *uhashtbl; +static u_long uhash_mask; /* size of hash table - 1 */ #define UNION_HASH(u, l) \ - (unsigned long) (u)) + ((unsigned long) l)) 8) (NHASH-1)) + u_long) (u) + (u_long) (l)) 8) uhash_mask) +#define NOHASH ((u_long)-1) -static LIST_HEAD(unhead, union_node) unhead[NHASH]; -static kmutex_t unheadlock[NHASH]; +static kmutex_t uhash_lock; void union_updatevp(struct union_node *, struct vnode *, struct vnode *); static int union_do_lookup(struct vnode *, struct componentname *, kauth_cred_t,const char *, u_long); @@ -115,12 +113,34 @@ struct vnode *union_dircache(struct vnod void union_init(void) { + + mutex_init(uhash_lock, MUTEX_DEFAULT, IPL_NONE); + uhashtbl = hashinit(desiredvnodes, HASH_LIST, true, uhash_mask); +} + +void +union_reinit(void) +{ + struct union_node *un; + struct uhashhead *oldhash, *hash; + u_long oldmask, mask, val; int i; - for (i = 0; i NHASH; i++) { - LIST_INIT(unhead[i]); - mutex_init(unheadlock[i], MUTEX_DEFAULT, IPL_NONE); + hash = hashinit(desiredvnodes, HASH_LIST, true, mask); + mutex_enter(uhash_lock); + oldhash = uhashtbl; + oldmask = uhash_mask; + uhashtbl = hash; + uhash_mask = mask; + for (i = 0; i = oldmask; i++) { + while ((un = LIST_FIRST(oldhash[i])) != NULL) { + LIST_REMOVE(un, un_cache); + val = UNION_HASH(un-un_uppervp, un-un_lowervp); + LIST_INSERT_HEAD(hash[val], un, un_cache); + } } + mutex_exit(uhash_lock); + hashdone(oldhash, HASH_LIST, oldmask); } /* @@ -129,10 +149,9 @@ union_init(void) void union_done(void) { - int i; - for (i = 0; i NHASH; i++) - mutex_destroy(unheadlock[i]); + hashdone(uhashtbl, HASH_LIST, uhash_mask); + mutex_destroy(uhash_lock); /* Make sure to unset the readdir hook. */ vn_union_readdir_hook = NULL; @@ -145,37 +164,19 @@ union_updatevp(struct union_node *un, st int ohash = UNION_HASH(un-un_uppervp, un-un_lowervp); int nhash = UNION_HASH(uppervp, lowervp); int docache = (lowervp != NULLVP || uppervp != NULLVP); - int lhash, uhash; bool un_unlock; KASSERT(VOP_ISLOCKED(UNIONTOV(un)) == LK_EXCLUSIVE); - /* - * Ensure locking is ordered from lower to higher - * to avoid deadlocks. - */ - if (nhash ohash) { - lhash = nhash; - uhash = ohash; - } else { - lhash = ohash; - uhash = nhash; - } - - if (lhash != uhash) - mutex_enter(unheadlock[lhash]); - mutex_enter(unheadlock[uhash]); + mutex_enter(uhash_lock); - if (ohash != nhash || !docache) { + if (!docache || ohash != nhash) { if (un-un_cflags UN_CACHED) { un-un_cflags = ~UN_CACHED; LIST_REMOVE(un, un_cache); } } - if (ohash != nhash) - mutex_exit(unheadlock[ohash]); - if (un-un_lowervp != lowervp) {
CVS commit: src/sys/dev/pci
Module Name:src Committed By: hannken Date: Wed Nov 23 19:40:42 UTC 2011 Modified Files: src/sys/dev/pci: ld_virtio.c Log Message: According to Virtio PCI Card Specification v0.9.2 DRAFT there is no feature named VIRTIO_BLK_F_SECTOR_MAX so remove it. Linux seems to use this feature bit as VIRTIO_BLK_F_TOPOLOGY. Use VIRTIO_BLK_F_BLK_SIZE * VIRTIO_BLK_F_SEG_MAX as the drivers maxxfer and reorder so sc_secsize gets set before use. As maxxfer may not be a multiple of page size add one more segment to the dma maps. Tested on Linux 3.1.1 host by Guillaume Lasmayous. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/ld_virtio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ld_virtio.c diff -u src/sys/dev/pci/ld_virtio.c:1.2 src/sys/dev/pci/ld_virtio.c:1.3 --- src/sys/dev/pci/ld_virtio.c:1.2 Wed Nov 2 14:34:09 2011 +++ src/sys/dev/pci/ld_virtio.c Wed Nov 23 19:40:42 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_virtio.c,v 1.2 2011/11/02 14:34:09 hannken Exp $ */ +/* $NetBSD: ld_virtio.c,v 1.3 2011/11/23 19:40:42 hannken Exp $ */ /* * Copyright (c) 2010 Minoura Makoto. @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ld_virtio.c,v 1.2 2011/11/02 14:34:09 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: ld_virtio.c,v 1.3 2011/11/23 19:40:42 hannken Exp $); #include rnd.h @@ -61,7 +61,6 @@ __KERNEL_RCSID(0, $NetBSD: ld_virtio.c, #define VIRTIO_BLK_CONFIG_GEOMETRY_H 18 /* 8bit */ #define VIRTIO_BLK_CONFIG_GEOMETRY_S 19 /* 8bit */ #define VIRTIO_BLK_CONFIG_BLK_SIZE 20 /* 32bit */ -#define VIRTIO_BLK_CONFIG_SECTORS_MAX 24 /* 32bit */ /* Feature bits */ #define VIRTIO_BLK_F_BARRIER (10) @@ -72,7 +71,6 @@ __KERNEL_RCSID(0, $NetBSD: ld_virtio.c, #define VIRTIO_BLK_F_BLK_SIZE (16) #define VIRTIO_BLK_F_SCSI (17) #define VIRTIO_BLK_F_FLUSH (19) -#define VIRTIO_BLK_F_SECTOR_MAX (110) /* Command */ #define VIRTIO_BLK_T_IN 0 @@ -194,7 +192,7 @@ ld_virtio_alloc_reqs(struct ld_virtio_so } r = bus_dmamap_create(sc-sc_virtio-sc_dmat, ld-sc_maxxfer, - (ld-sc_maxxfer / NBPG) + 1, + (ld-sc_maxxfer / NBPG) + 2, ld-sc_maxxfer, 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, @@ -262,17 +260,21 @@ ld_virtio_attach(device_t parent, device VIRTIO_BLK_F_SEG_MAX | VIRTIO_BLK_F_GEOMETRY | VIRTIO_BLK_F_RO | - VIRTIO_BLK_F_BLK_SIZE | - VIRTIO_BLK_F_SECTOR_MAX)); + VIRTIO_BLK_F_BLK_SIZE)); if (features VIRTIO_BLK_F_RO) sc-sc_readonly = 1; else sc-sc_readonly = 0; + ld-sc_secsize = 512; + if (features VIRTIO_BLK_F_BLK_SIZE) { + ld-sc_secsize = virtio_read_device_config_4(vsc, + VIRTIO_BLK_CONFIG_BLK_SIZE); + } maxxfersize = MAXPHYS; - if (features VIRTIO_BLK_F_SECTOR_MAX) { + if (features VIRTIO_BLK_F_SEG_MAX) { maxxfersize = virtio_read_device_config_4(vsc, - VIRTIO_BLK_CONFIG_SECTORS_MAX) + VIRTIO_BLK_CONFIG_SEG_MAX) * ld-sc_secsize; if (maxxfersize MAXPHYS) maxxfersize = MAXPHYS; @@ -289,11 +291,6 @@ ld_virtio_attach(device_t parent, device ld-sc_dv = self; ld-sc_secperunit = virtio_read_device_config_8(vsc, VIRTIO_BLK_CONFIG_CAPACITY); - ld-sc_secsize = 512; - if (features VIRTIO_BLK_F_BLK_SIZE) { - ld-sc_secsize = virtio_read_device_config_4(vsc, - VIRTIO_BLK_CONFIG_BLK_SIZE); - } ld-sc_maxxfer = maxxfersize; if (features VIRTIO_BLK_F_GEOMETRY) { ld-sc_ncylinders = virtio_read_device_config_2(vsc,
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Fri Nov 25 11:19:10 UTC 2011 Modified Files: src/sys/fs/union: union_subr.c Log Message: When union_allocvp() finds a node being cleaned out and the caller holds a lock, ignore the node and continue. To allow the cleaning to succeed the current threadmust make progress. For a brief time the cache may contain more than one vnode referring to a lower node. Don't unlock the hash mutex if getnewvnode fails -- we don't hold it. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/fs/union/union_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.54 src/sys/fs/union/union_subr.c:1.55 --- src/sys/fs/union/union_subr.c:1.54 Wed Nov 23 19:39:11 2011 +++ src/sys/fs/union/union_subr.c Fri Nov 25 11:19:10 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.54 2011/11/23 19:39:11 hannken Exp $ */ +/* $NetBSD: union_subr.c,v 1.55 2011/11/25 11:19:10 hannken Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.54 2011/11/23 19:39:11 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: union_subr.c,v 1.55 2011/11/25 11:19:10 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -404,6 +404,18 @@ loop: lflag = LK_EXCLUSIVE; vp = UNIONTOV(un); mutex_enter(vp-v_interlock); + /* + * If this node being cleaned out and our caller + * holds a lock, then ignore it and continue. To + * allow the cleaning to succeed the current thread + * must make progress. For a brief time the cache + * may contain more than one vnode referring to + * a lower node. + */ + if ((vp-v_iflag VI_XLOCK) != 0 lflag == 0) { +mutex_exit(vp-v_interlock); +continue; + } mutex_exit(uhash_lock); if (vget(vp, lflag)) goto loop; @@ -484,7 +496,7 @@ found: if (lowervp) vrele(lowervp); - goto out; + return error; } if (docache) { @@ -493,6 +505,17 @@ found: if (un1-un_lowervp == lowervp un1-un_uppervp == uppervp UNIONTOV(un1)-v_mount == mp) { +vp = UNIONTOV(un1); +mutex_enter(vp-v_interlock); +/* + * Ignore nodes being cleaned out. + * See the cache lookup above. + */ +if ((vp-v_iflag VI_XLOCK) != 0) { + mutex_exit(vp-v_interlock); + continue; +} +mutex_exit(vp-v_interlock); /* * Another thread beat us, push back freshly * allocated vnode and retry. @@ -569,7 +592,6 @@ found: if (xlowervp) vrele(xlowervp); -out: if (docache) mutex_exit(uhash_lock);
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Mon Dec 5 11:12:11 UTC 2011 Modified Files: src/sys/fs/union: union_vfsops.c Log Message: The union file system is as stable as other layered file systems so no longer print a warning to the console. Gnats is waiting ... To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/fs/union/union_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_vfsops.c diff -u src/sys/fs/union/union_vfsops.c:1.66 src/sys/fs/union/union_vfsops.c:1.67 --- src/sys/fs/union/union_vfsops.c:1.66 Wed Nov 23 19:39:11 2011 +++ src/sys/fs/union/union_vfsops.c Mon Dec 5 11:12:10 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vfsops.c,v 1.66 2011/11/23 19:39:11 hannken Exp $ */ +/* $NetBSD: union_vfsops.c,v 1.67 2011/12/05 11:12:10 hannken Exp $ */ /* * Copyright (c) 1994 The Regents of the University of California. @@ -77,7 +77,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_vfsops.c,v 1.66 2011/11/23 19:39:11 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: union_vfsops.c,v 1.67 2011/12/05 11:12:10 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -101,9 +101,6 @@ MODULE(MODULE_CLASS_VFS, union, NULL); VFS_PROTOS(union); static struct sysctllog *union_sysctl_log; -static const char *warn_user = -WARNING: the union file system is experimental\n -WARNING: it can cause crashes and file system corruption\n; /* * Mount union filesystem @@ -151,11 +148,6 @@ union_mount(struct mount *mp, const char goto bad; } - if (warn_user != NULL) { - printf(%s, warn_user); - warn_user = NULL; - } - lowerrootvp = mp-mnt_vnodecovered; vref(lowerrootvp);
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Tue Dec 20 16:49:37 UTC 2011 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Move the diagnostic check for a missing VOP_CLOSE() to the top of vrelel(). As long as we hold the vnode interlock there is no chance for this vnode to gain new references. Fixes false alarms observed by Thor Lancelot Simon and reported on tech-kern. Ok: David Holland dholl...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.14 src/sys/kern/vfs_vnode.c:1.15 --- src/sys/kern/vfs_vnode.c:1.14 Fri Oct 7 09:35:06 2011 +++ src/sys/kern/vfs_vnode.c Tue Dec 20 16:49:37 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.14 2011/10/07 09:35:06 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.15 2011/12/20 16:49:37 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -120,7 +120,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.14 2011/10/07 09:35:06 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.15 2011/12/20 16:49:37 hannken Exp $); #include sys/param.h #include sys/kernel.h @@ -637,6 +637,13 @@ vrelel(vnode_t *vp, int flags) KASSERT((vp-v_iflag VI_XLOCK) == 0); +#ifdef DIAGNOSTIC + if ((vp-v_type == VBLK || vp-v_type == VCHR) + vp-v_specnode != NULL vp-v_specnode-sn_opencnt != 0) { + vprint(vrelel: missing VOP_CLOSE(), vp); + } +#endif + /* * If not clean, deactivate the vnode, but preserve * our reference across the call to VOP_INACTIVE(). @@ -706,13 +713,6 @@ retry: return; } -#ifdef DIAGNOSTIC - if ((vp-v_type == VBLK || vp-v_type == VCHR) - vp-v_specnode != NULL vp-v_specnode-sn_opencnt != 0) { - vprint(vrelel: missing VOP_CLOSE(), vp); - } -#endif - /* * The vnode can gain another reference while being * deactivated. If VOP_INACTIVE() indicates that
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Sat Jul 28 15:12:42 UTC 2012 Modified Files: src/sys/dev: fss.c Log Message: Use `getdisksize()' to get the size of the mounted-on block device. Should work for disks without partition table (wedges) now. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.81 src/sys/dev/fss.c:1.82 --- src/sys/dev/fss.c:1.81 Wed Nov 30 09:51:18 2011 +++ src/sys/dev/fss.c Sat Jul 28 15:12:42 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.81 2011/11/30 09:51:18 bouyer Exp $ */ +/* $NetBSD: fss.c,v 1.82 2012/07/28 15:12:42 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.81 2011/11/30 09:51:18 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.82 2012/07/28 15:12:42 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -622,8 +622,9 @@ fss_create_files(struct fss_softc *sc, s off_t *bsize, struct lwp *l) { int error, bits, fsbsize; + uint64_t numsec; + unsigned int secsize; struct timespec ts; - struct partinfo dpart; /* nd - nd2 to reduce mistakes while updating only some namei calls */ struct pathbuf *pb2; struct nameidata nd2; @@ -711,11 +712,11 @@ fss_create_files(struct fss_softc *sc, s * Get the block device size. */ - error = bdev_ioctl(sc-sc_bdev, DIOCGPART, dpart, FREAD, l); + error = getdisksize(vp, numsec, secsize); if (error) return error; - *bsize = (off_t)dpart.disklab-d_secsize*dpart.part-p_size; + *bsize = (off_t)numsec*secsize; /* * Get the backing store
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Sat Jul 28 16:14:18 UTC 2012 Modified Files: src/sys/dev: fss.c Log Message: Minor fix to previous -- release vnode after last use, not before. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.82 src/sys/dev/fss.c:1.83 --- src/sys/dev/fss.c:1.82 Sat Jul 28 15:12:42 2012 +++ src/sys/dev/fss.c Sat Jul 28 16:14:17 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.82 2012/07/28 15:12:42 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.82 2012/07/28 15:12:42 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -706,13 +706,13 @@ fss_create_files(struct fss_softc *sc, s } sc-sc_bdev = vp-v_rdev; - vrele(vp); /* * Get the block device size. */ error = getdisksize(vp, numsec, secsize); + vrele(vp); if (error) return error;
CVS commit: src
Module Name:src Committed By: hannken Date: Fri Nov 5 10:02:53 UTC 2010 Modified Files: src/sbin/dump: dump.8 src/share/man/man4: fss.4 Log Message: File system snapshots are no longer experimental. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sbin/dump/dump.8 cvs rdiff -u -r1.13 -r1.14 src/share/man/man4/fss.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/dump/dump.8 diff -u src/sbin/dump/dump.8:1.61 src/sbin/dump/dump.8:1.62 --- src/sbin/dump/dump.8:1.61 Fri May 14 05:04:58 2010 +++ src/sbin/dump/dump.8 Fri Nov 5 10:02:53 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: dump.8,v 1.61 2010/05/14 05:04:58 jruoho Exp $ +.\ $NetBSD: dump.8,v 1.62 2010/11/05 10:02:53 hannken Exp $ .\ .\ Copyright (c) 1980, 1991, 1993 .\ Regents of the University of California. @@ -30,7 +30,7 @@ .\ .\ @(#)dump.8 8.3 (Berkeley) 5/1/95 .\ -.Dd May 14, 2010 +.Dd November 5, 2010 .Dt DUMP 8 .Os .Sh NAME @@ -307,9 +307,6 @@ See .Xr fss 4 for more details. -Snapshot support is -.Em experimental . -Be sure you have a backup before you use it. .It Fl X Similar to .Fl x Index: src/share/man/man4/fss.4 diff -u src/share/man/man4/fss.4:1.13 src/share/man/man4/fss.4:1.14 --- src/share/man/man4/fss.4:1.13 Mon Mar 22 18:58:31 2010 +++ src/share/man/man4/fss.4 Fri Nov 5 10:02:53 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: fss.4,v 1.13 2010/03/22 18:58:31 joerg Exp $ */ +.\ $NetBSD: fss.4,v 1.14 2010/11/05 10:02:53 hannken Exp $ */ .\ .\ .\ Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd September 21, 2008 +.Dd November 5, 2010 .Dt FSS 4 .Os .Sh NAME @@ -148,7 +148,3 @@ .Nm device appeared in .Nx 2.0 . -.Sh BUGS -This driver is -.Em experimental . -Be sure you have a backup before you use it.
CVS commit: src/share/man/man4
Module Name:src Committed By: hannken Date: Fri Nov 5 10:04:25 UTC 2010 Modified Files: src/share/man/man4: wapbl.4 Log Message: File system snapshots work with wapbl. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/share/man/man4/wapbl.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/wapbl.4 diff -u src/share/man/man4/wapbl.4:1.12 src/share/man/man4/wapbl.4:1.13 --- src/share/man/man4/wapbl.4:1.12 Mon Nov 23 16:41:26 2009 +++ src/share/man/man4/wapbl.4 Fri Nov 5 10:04:25 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: wapbl.4,v 1.12 2009/11/23 16:41:26 pooka Exp $ +.\ $NetBSD: wapbl.4,v 1.13 2010/11/05 10:04:25 hannken Exp $ .\ .\ Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -24,7 +24,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd November 23, 2009 +.Dd November 5, 2010 .Dt WAPBL 4 .Os .Sh NAME @@ -193,9 +193,7 @@ .Xr fsync 2 often. .Pp -File system snapshots -.Pq Xr fss 4 -and quotas do not yet work with +Quotas do not yet work with .Nm . .Pp In-file system log allocation should be done on a relatively quiet
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Tue Nov 9 16:30:26 UTC 2010 Modified Files: src/sys/kern: vfs_wapbl.c Log Message: Wapbl_register_deallocation(): the taken reader lock is not sufficient to protect wl_dealloc* members. Take the mutex here and change the lock requirements of these fields to writer lock or mutex. This error lead to file system corruption and freeing free block panics. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/kern/vfs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_wapbl.c diff -u src/sys/kern/vfs_wapbl.c:1.37 src/sys/kern/vfs_wapbl.c:1.38 --- src/sys/kern/vfs_wapbl.c:1.37 Fri Sep 10 10:14:55 2010 +++ src/sys/kern/vfs_wapbl.c Tue Nov 9 16:30:26 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_wapbl.c,v 1.37 2010/09/10 10:14:55 drochner Exp $ */ +/* $NetBSD: vfs_wapbl.c,v 1.38 2010/11/09 16:30:26 hannken Exp $ */ /*- * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #define WAPBL_INTERNAL #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_wapbl.c,v 1.37 2010/09/10 10:14:55 drochner Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_wapbl.c,v 1.38 2010/11/09 16:30:26 hannken Exp $); #include sys/param.h #include sys/bitops.h @@ -104,6 +104,7 @@ * r = read-only after init * l = rwlock held * m = mutex held + * lm = rwlock held writing or mutex held * u = unlocked access ok * b = bufcache_lock held */ @@ -173,9 +174,9 @@ size_t wl_unsynced_bufbytes; /* Byte count of unsynced buffers */ #endif - daddr_t *wl_deallocblks;/* l: address of block */ - int *wl_dealloclens; /* l: size of block */ - int wl_dealloccnt; /* l: total count */ + daddr_t *wl_deallocblks;/* lm: address of block */ + int *wl_dealloclens; /* lm: size of block */ + int wl_dealloccnt; /* lm: total count */ int wl_dealloclim; /* l: max count */ /* hashtable of inode numbers for allocated but unlinked inodes */ @@ -1672,6 +1673,7 @@ wapbl_jlock_assert(wl); + mutex_enter(wl-wl_mtx); /* XXX should eventually instead tie this into resource estimation */ /* * XXX this panic needs locking/mutex analysis and the @@ -1686,6 +1688,7 @@ wl-wl_dealloccnt++; WAPBL_PRINTF(WAPBL_PRINT_ALLOC, (wapbl_register_deallocation: blk=%PRId64 len=%d\n, blk, len)); + mutex_exit(wl-wl_mtx); } //
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Tue Nov 9 16:31:48 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Genfs_getpages(): Break a deadlock where one thread runs VOP_GETPAGES(), has busy pages and wants the wapbl lock as reader from wapbl_begin(), another thread has the wapbl lock as reader and waits for a page from the first thread. Now a third thread calls wapbl_flush() and wants the wapbl lock as writer. Move the wapbl_begin() up to a point where genfs_getpages() has no busy pages yet. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.41 src/sys/miscfs/genfs/genfs_io.c:1.42 --- src/sys/miscfs/genfs/genfs_io.c:1.41 Wed Nov 3 04:32:50 2010 +++ src/sys/miscfs/genfs/genfs_io.c Tue Nov 9 16:31:48 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.41 2010/11/03 04:32:50 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.42 2010/11/09 16:31:48 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.41 2010/11/03 04:32:50 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.42 2010/11/09 16:31:48 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -129,10 +129,11 @@ kauth_cred_t const cred = curlwp-l_cred; /* XXXUBC curlwp */ const bool async = (flags PGO_SYNCIO) == 0; const bool memwrite = (ap-a_access_type VM_PROT_WRITE) != 0; - bool has_trans = false; const bool overwrite = (flags PGO_OVERWRITE) != 0; const bool blockalloc = memwrite (flags PGO_NOBLOCKALLOC) == 0; const bool glocked = (flags PGO_GLOCKHELD) != 0; + const bool need_wapbl = blockalloc vp-v_mount-mnt_wapbl; + bool has_trans_wapbl = false; UVMHIST_FUNC(genfs_getpages); UVMHIST_CALLED(ubchist); UVMHIST_LOG(ubchist, vp %p off 0x%x/%x count %d, @@ -294,9 +295,20 @@ UVMHIST_LOG(ubchist, ridx %d npages %d startoff %ld endoff %ld, ridx, npages, startoffset, endoffset); - if (!has_trans) { + if (!has_trans_wapbl) { fstrans_start(vp-v_mount, FSTRANS_SHARED); - has_trans = true; + /* + * XXX: This assumes that we come here only via + * the mmio path + */ + if (need_wapbl) { + error = WAPBL_BEGIN(vp-v_mount); + if (error) { +fstrans_done(vp-v_mount); +goto out_err_free; + } + } + has_trans_wapbl = true; } /* @@ -621,22 +633,8 @@ */ if (!error sawhole blockalloc) { - /* - * XXX: This assumes that we come here only via - * the mmio path - */ - if (vp-v_mount-mnt_wapbl) { - error = WAPBL_BEGIN(vp-v_mount); - } - - if (!error) { - error = GOP_ALLOC(vp, startoffset, - npages PAGE_SHIFT, 0, cred); - if (vp-v_mount-mnt_wapbl) { -WAPBL_END(vp-v_mount); - } - } - + error = GOP_ALLOC(vp, startoffset, + npages PAGE_SHIFT, 0, cred); UVMHIST_LOG(ubchist, gop_alloc off 0x%x/0x%x - %d, startoffset, npages PAGE_SHIFT, error,0); if (!error) { @@ -738,8 +736,11 @@ if (pgs != NULL pgs != pgs_onstack) kmem_free(pgs, pgs_size); out_err: - if (has_trans) + if (has_trans_wapbl) { + if (need_wapbl) + WAPBL_END(vp-v_mount); fstrans_done(vp-v_mount); + } return error; }
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Thu Nov 11 11:07:07 UTC 2010 Modified Files: src/sys/dev: md.c src/sys/kern: kern_subr.c Log Message: Change md(4) to: - create md devices on first open and destroy on last close. - add enough disk label support to make DIOCGDINFO and DIOCGPART work. - add disk_busy()/disk_unbusy() instrumentation. Ok: David Young dyo...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/dev/md.c cvs rdiff -u -r1.207 -r1.208 src/sys/kern/kern_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/md.c diff -u src/sys/dev/md.c:1.62 src/sys/dev/md.c:1.63 --- src/sys/dev/md.c:1.62 Thu Jan 21 02:14:42 2010 +++ src/sys/dev/md.c Thu Nov 11 11:07:06 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.62 2010/01/21 02:14:42 dyoung Exp $ */ +/* $NetBSD: md.c,v 1.63 2010/11/11 11:07:06 hannken Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -40,10 +40,9 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: md.c,v 1.62 2010/01/21 02:14:42 dyoung Exp $); +__KERNEL_RCSID(0, $NetBSD: md.c,v 1.63 2010/11/11 11:07:06 hannken Exp $); #include opt_md.h -#include opt_tftproot.h #include sys/param.h #include sys/kernel.h @@ -78,6 +77,7 @@ /* autoconfig stuff... */ struct md_softc { + device_t sc_dev; /* Self. */ struct disk sc_dkdev; /* hook for generic disk handling */ struct md_conf sc_md; struct bufq_state *sc_buflist; @@ -115,43 +115,23 @@ CFATTACH_DECL3_NEW(md, sizeof(struct md_softc), 0, md_attach, md_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN); +static kmutex_t md_device_lock; /* Protect unit creation / deletion. */ extern size_t md_root_size; +static void md_set_disklabel(struct md_softc *); + /* * This is called if we are configured as a pseudo-device */ void mdattach(int n) { - int i; - cfdata_t cf; -#ifdef TFTPROOT - /* - * Attachement of md0 must be done after md_root_setconf(), - * because the RAMdisk is not loaded yet. - */ - if (md_root_size == 0) - return; -#endif - if (config_cfattach_attach(md, md_ca)) { - printf(md: cfattach_attach failed\n); + mutex_init(md_device_lock, MUTEX_DEFAULT, IPL_NONE); + if (config_cfattach_attach(md_cd.cd_name, md_ca)) { + aprint_error(%s: cfattach_attach failed\n, md_cd.cd_name); return; } - - /* XXX: Are we supposed to provide a default? */ - if (n = 1) - n = 1; - - /* Attach as if by autoconfig. */ - for (i = 0; i n; i++) { - cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); - cf-cf_name = md; - cf-cf_atname = md; - cf-cf_unit = i; - cf-cf_fstate = FSTATE_NOTFOUND; - (void)config_attach_pseudo(cf); - } } static void @@ -159,6 +139,7 @@ { struct md_softc *sc = device_private(self); + sc-sc_dev = self; bufq_alloc(sc-sc_buflist, fcfs, 0); /* XXX - Could accept aux info here to set the config. */ @@ -177,6 +158,9 @@ disk_init(sc-sc_dkdev, device_xname(self), mddkdriver); disk_attach(sc-sc_dkdev); + if (sc-sc_type != MD_UNCONFIGURED) + md_set_disklabel(sc); + if (!pmf_device_register(self, NULL, NULL)) aprint_error_dev(self, couldn't establish power handler\n); } @@ -240,13 +224,29 @@ int unit; int part = DISKPART(dev); int pmask = 1 part; + cfdata_t cf; struct md_softc *sc; struct disk *dk; + mutex_enter(md_device_lock); unit = MD_UNIT(dev); sc = device_lookup_private(md_cd, unit); - if (sc == NULL) - return ENXIO; + if (sc == NULL) { + if (part != RAW_PART) { + mutex_exit(md_device_lock); + return ENXIO; + } + cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); + cf-cf_name = md_cd.cd_name; + cf-cf_atname = md_cd.cd_name; + cf-cf_unit = unit; + cf-cf_fstate = FSTATE_STAR; + sc = device_private(config_attach_pseudo(cf)); + if (sc == NULL) { + mutex_exit(md_device_lock); + return ENOMEM; + } + } dk = sc-sc_dkdev; @@ -265,8 +265,10 @@ * This is a normal, slave device, so * enforce initialized. */ - if (sc-sc_type == MD_UNCONFIGURED) + if (sc-sc_type == MD_UNCONFIGURED) { + mutex_exit(md_device_lock); return ENXIO; + } ok: /* XXX duplicates code in dk_open(). Call dk_open(), instead? */ @@ -284,6 +286,7 @@ dk-dk_openmask = dk-dk_copenmask | dk-dk_bopenmask; mutex_exit(dk-dk_openlock); + mutex_exit(md_device_lock); return 0; } @@ -292,6 +295,8 @@ { int part = DISKPART(dev); int pmask = 1 part; + int error; + cfdata_t cf; struct md_softc *sc; struct disk *dk; @@ -314,7 +319,14 @@ dk-dk_openmask = dk-dk_copenmask | dk-dk_bopenmask; mutex_exit(dk-dk_openlock); - return 0; + + mutex_enter(md_device_lock); + cf = device_cfdata(sc-sc_dev); + error = config_detach(sc-sc_dev, DETACH_QUIET); + if (! error) + free(cf, M_DEVBUF); + mutex_exit(md_device_lock); + return error; } static int @@ -353,6 +365,7 @@ struct md_softc *sc; void * addr; size_t off, xfer; + bool is_read; sc =
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Tue Nov 23 09:30:43 UTC 2010 Modified Files: src/sys/dev: md.c Log Message: Make md(4) mp-safe. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/md.c diff -u src/sys/dev/md.c:1.64 src/sys/dev/md.c:1.65 --- src/sys/dev/md.c:1.64 Mon Nov 22 21:10:10 2010 +++ src/sys/dev/md.c Tue Nov 23 09:30:43 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.64 2010/11/22 21:10:10 pooka Exp $ */ +/* $NetBSD: md.c,v 1.65 2010/11/23 09:30:43 hannken Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -40,7 +40,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: md.c,v 1.64 2010/11/22 21:10:10 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: md.c,v 1.65 2010/11/23 09:30:43 hannken Exp $); #ifdef _KERNEL_OPT #include opt_md.h @@ -84,6 +84,8 @@ device_t sc_dev; /* Self. */ struct disk sc_dkdev; /* hook for generic disk handling */ struct md_conf sc_md; + kmutex_t sc_lock; /* Protect self. */ + kcondvar_t sc_cv; /* Signal work. */ struct bufq_state *sc_buflist; }; /* shorthand for fields in sc_md: */ @@ -105,7 +107,7 @@ static dev_type_size(mdsize); const struct bdevsw md_bdevsw = { - mdopen, mdclose, mdstrategy, mdioctl, nodump, mdsize, D_DISK + mdopen, mdclose, mdstrategy, mdioctl, nodump, mdsize, D_DISK | D_MPSAFE }; const struct cdevsw md_cdevsw = { @@ -144,6 +146,8 @@ struct md_softc *sc = device_private(self); sc-sc_dev = self; + mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_NONE); + cv_init(sc-sc_cv, mdidle); bufq_alloc(sc-sc_buflist, fcfs, 0); /* XXX - Could accept aux info here to set the config. */ @@ -190,6 +194,8 @@ disk_detach(sc-sc_dkdev); disk_destroy(sc-sc_dkdev); bufq_free(sc-sc_buflist); + mutex_destroy(sc-sc_lock); + cv_destroy(sc-sc_cv); return 0; } @@ -211,15 +217,20 @@ mdsize(dev_t dev) { struct md_softc *sc; + int res; sc = device_lookup_private(md_cd, MD_UNIT(dev)); if (sc == NULL) return 0; + mutex_enter(sc-sc_lock); if (sc-sc_type == MD_UNCONFIGURED) - return 0; + res = 0; + else + res = sc-sc_size DEV_BSHIFT; + mutex_exit(sc-sc_lock); - return (sc-sc_size DEV_BSHIFT); + return res; } static int @@ -373,6 +384,8 @@ sc = device_lookup_private(md_cd, MD_UNIT(bp-b_dev)); + mutex_enter(sc-sc_lock); + if (sc == NULL || sc-sc_type == MD_UNCONFIGURED) { bp-b_error = ENXIO; goto done; @@ -383,7 +396,8 @@ case MD_UMEM_SERVER: /* Just add this job to the server's queue. */ bufq_put(sc-sc_buflist, bp); - wakeup((void *)sc); + cv_signal(sc-sc_cv); + mutex_exit(sc-sc_lock); /* see md_server_loop() */ /* no biodone in this case */ return; @@ -421,6 +435,8 @@ } done: biodone(bp); + + mutex_exit(sc-sc_lock); } static int @@ -430,15 +446,18 @@ struct md_conf *umd; struct disklabel *lp; struct partinfo *pp; + int error; if ((sc = device_lookup_private(md_cd, MD_UNIT(dev))) == NULL) return ENXIO; + mutex_enter(sc-sc_lock); if (sc-sc_type != MD_UNCONFIGURED) { switch (cmd) { case DIOCGDINFO: lp = (struct disklabel *)data; *lp = *sc-sc_dkdev.dk_label; + mutex_exit(sc-sc_lock); return 0; case DIOCGPART: @@ -446,19 +465,24 @@ pp-disklab = sc-sc_dkdev.dk_label; pp-part = sc-sc_dkdev.dk_label-d_partitions[DISKPART(dev)]; + mutex_exit(sc-sc_lock); return 0; } } /* If this is not the raw partition, punt! */ - if (DISKPART(dev) != RAW_PART) + if (DISKPART(dev) != RAW_PART) { + mutex_exit(sc-sc_lock); return ENOTTY; + } umd = (struct md_conf *)data; + error = EINVAL; switch (cmd) { case MD_GETCONF: *umd = sc-sc_md; - return 0; + error = 0; + break; case MD_SETCONF: /* Can only set it once. */ @@ -466,17 +490,20 @@ break; switch (umd-md_type) { case MD_KMEM_ALLOCATED: - return md_ioctl_kalloc(sc, umd, l); + error = md_ioctl_kalloc(sc, umd, l); + break; #if MEMORY_DISK_SERVER case MD_UMEM_SERVER: - return md_ioctl_server(sc, umd, l); + error = md_ioctl_server(sc, umd, l); + break; #endif /* MEMORY_DISK_SERVER */ default: break; } break; } - return EINVAL; + mutex_exit(sc-sc_lock); + return error; } static void @@ -534,6 +561,8 @@ vaddr_t addr; vsize_t size; + KASSERT(mutex_owned(sc-sc_lock)); + /* Sanity check the size. */ size = umd-md_size; addr = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_WIRED|UVM_KMF_ZERO); @@ -561,6 +590,8 @@ vaddr_t end; int error; + KASSERT(mutex_owned(sc-sc_lock)); + /* Sanity check addr, size. */ end = (vaddr_t) ((char *)umd-md_addr + umd-md_size); @@ -585,8 +616,6 @@ return (error); } -static int md_sleep_pri = PWAIT | PCATCH; - static int md_server_loop(struct md_softc *sc) { @@ -597,15 +626,18 @@ int error; bool is_read; +
CVS commit: src/sys/arch/atari/conf
Module Name:src Committed By: hannken Date: Tue Nov 23 11:16:59 UTC 2010 Modified Files: src/sys/arch/atari/conf: ATARITT FALCON HADES MILAN-ISAIDE MILAN-PCIIDE SMALL030 Log Message: Regen. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/arch/atari/conf/ATARITT cvs rdiff -u -r1.101 -r1.102 src/sys/arch/atari/conf/FALCON cvs rdiff -u -r1.94 -r1.95 src/sys/arch/atari/conf/HADES cvs rdiff -u -r1.71 -r1.72 src/sys/arch/atari/conf/MILAN-ISAIDE cvs rdiff -u -r1.75 -r1.76 src/sys/arch/atari/conf/MILAN-PCIIDE cvs rdiff -u -r1.11 -r1.12 src/sys/arch/atari/conf/SMALL030 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/atari/conf/ATARITT diff -u src/sys/arch/atari/conf/ATARITT:1.104 src/sys/arch/atari/conf/ATARITT:1.105 --- src/sys/arch/atari/conf/ATARITT:1.104 Sat May 8 22:18:23 2010 +++ src/sys/arch/atari/conf/ATARITT Tue Nov 23 11:16:59 2010 @@ -1,11 +1,11 @@ # -# $NetBSD: ATARITT,v 1.104 2010/05/08 22:18:23 mrg Exp $ +# $NetBSD: ATARITT,v 1.105 2010/11/23 11:16:59 hannken Exp $ # # This file was automatically created. Changes will be # lost when running makeconf in this directory. # # Created from: -# NetBSD: GENERIC.in,v 1.90 2010/05/08 22:16:26 mrg Exp $ +# NetBSD: GENERIC.in,v 1.91 2010/11/23 11:13:54 hannken Exp $ include arch/atari/conf/std.atari options INCLUDE_CONFIG_FILE # embed config file in kernel binary maxusers 16 @@ -80,7 +80,7 @@ pseudo-device pppoe # PPP over Ethernet (RFC 2516) pseudo-device pty # pseudo-terminals pseudo-device loop # Loopback network -pseudo-device md 3 # Boot memory disk +pseudo-device md # Boot memory disk pseudo-device putter # for puffs and pud pseudo-device vnd # 3 pseudo disks (see vnconfig) pseudo-device bpfilter # berkeley packet filters Index: src/sys/arch/atari/conf/FALCON diff -u src/sys/arch/atari/conf/FALCON:1.101 src/sys/arch/atari/conf/FALCON:1.102 --- src/sys/arch/atari/conf/FALCON:1.101 Sat May 8 22:18:23 2010 +++ src/sys/arch/atari/conf/FALCON Tue Nov 23 11:16:59 2010 @@ -1,11 +1,11 @@ # -# $NetBSD: FALCON,v 1.101 2010/05/08 22:18:23 mrg Exp $ +# $NetBSD: FALCON,v 1.102 2010/11/23 11:16:59 hannken Exp $ # # This file was automatically created. Changes will be # lost when running makeconf in this directory. # # Created from: -# NetBSD: GENERIC.in,v 1.90 2010/05/08 22:16:26 mrg Exp $ +# NetBSD: GENERIC.in,v 1.91 2010/11/23 11:13:54 hannken Exp $ include arch/atari/conf/std.atari options INCLUDE_CONFIG_FILE # embed config file in kernel binary maxusers 16 @@ -84,7 +84,7 @@ pseudo-device ppp # ppp pseudo-device pty # pseudo-terminals pseudo-device loop # Loopback network -pseudo-device md 3 # Boot memory disk +pseudo-device md # Boot memory disk pseudo-device putter # for puffs and pud pseudo-device vnd # 3 pseudo disks (see vnconfig) pseudo-device bpfilter # berkeley packet filters Index: src/sys/arch/atari/conf/HADES diff -u src/sys/arch/atari/conf/HADES:1.94 src/sys/arch/atari/conf/HADES:1.95 --- src/sys/arch/atari/conf/HADES:1.94 Sat May 8 22:18:23 2010 +++ src/sys/arch/atari/conf/HADES Tue Nov 23 11:16:59 2010 @@ -1,12 +1,12 @@ # -# $NetBSD: HADES,v 1.94 2010/05/08 22:18:23 mrg Exp $ +# $NetBSD: HADES,v 1.95 2010/11/23 11:16:59 hannken Exp $ # # This file was automatically created. Changes will be # lost when running makeconf in this directory. # # Created from: # NetBSD: HADES.in,v 1.11 2010/04/10 01:59:40 tsutsui Exp $ -# NetBSD: GENERIC.in,v 1.90 2010/05/08 22:16:26 mrg Exp $ +# NetBSD: GENERIC.in,v 1.91 2010/11/23 11:13:54 hannken Exp $ include arch/atari/conf/std.hades options INCLUDE_CONFIG_FILE # embed config file in kernel binary maxusers 16 @@ -85,7 +85,7 @@ pseudo-device pppoe # PPP over Ethernet (RFC 2516) pseudo-device pty # pseudo-terminals pseudo-device loop # Loopback network -pseudo-device md 3 # Boot memory disk +pseudo-device md # Boot memory disk pseudo-device putter # for puffs and pud pseudo-device vnd # 3 pseudo disks (see vnconfig) pseudo-device bpfilter # berkeley packet filters Index: src/sys/arch/atari/conf/MILAN-ISAIDE diff -u src/sys/arch/atari/conf/MILAN-ISAIDE:1.71 src/sys/arch/atari/conf/MILAN-ISAIDE:1.72 --- src/sys/arch/atari/conf/MILAN-ISAIDE:1.71 Sat May 8 22:18:23 2010 +++ src/sys/arch/atari/conf/MILAN-ISAIDE Tue Nov 23 11:16:59 2010 @@ -1,12 +1,12 @@ # -# $NetBSD: MILAN-ISAIDE,v 1.71 2010/05/08 22:18:23 mrg Exp $ +# $NetBSD: MILAN-ISAIDE,v 1.72 2010/11/23 11:16:59 hannken Exp $ # # This file was automatically created. Changes will be # lost when running makeconf in this directory. # # Created from: # NetBSD: MILAN.in,v 1.25 2010/04/10 01:59:40 tsutsui Exp $ -# NetBSD: GENERIC.in,v 1.90 2010/05/08 22:16:26 mrg Exp $ +# NetBSD: GENERIC.in,v 1.91 2010/11/23 11:13:54 hannken Exp $ include arch/atari/conf/std.milan options INCLUDE_CONFIG_FILE # embed config file in kernel binary maxusers 16 @@
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Thu Nov 25 08:53:31 UTC 2010 Modified Files: src/sys/dev: md.c Log Message: - Don't detach configured devices on last close. - No kmem allocation and biodone() under lock (from rm...@netbsd.org). To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/md.c diff -u src/sys/dev/md.c:1.65 src/sys/dev/md.c:1.66 --- src/sys/dev/md.c:1.65 Tue Nov 23 09:30:43 2010 +++ src/sys/dev/md.c Thu Nov 25 08:53:30 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.65 2010/11/23 09:30:43 hannken Exp $ */ +/* $NetBSD: md.c,v 1.66 2010/11/25 08:53:30 hannken Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -40,7 +40,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: md.c,v 1.65 2010/11/23 09:30:43 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: md.c,v 1.66 2010/11/25 08:53:30 hannken Exp $); #ifdef _KERNEL_OPT #include opt_md.h @@ -85,7 +85,7 @@ struct disk sc_dkdev; /* hook for generic disk handling */ struct md_conf sc_md; kmutex_t sc_lock; /* Protect self. */ - kcondvar_t sc_cv; /* Signal work. */ + kcondvar_t sc_cv; /* Wait here for work. */ struct bufq_state *sc_buflist; }; /* shorthand for fields in sc_md: */ @@ -146,6 +146,7 @@ struct md_softc *sc = device_private(self); sc-sc_dev = self; + sc-sc_type = MD_UNCONFIGURED; mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_NONE); cv_init(sc-sc_cv, mdidle); bufq_alloc(sc-sc_buflist, fcfs, 0); @@ -181,7 +182,7 @@ rc = 0; mutex_enter(sc-sc_dkdev.dk_openlock); - if (sc-sc_dkdev.dk_openmask == 0) + if (sc-sc_dkdev.dk_openmask == 0 sc-sc_type == MD_UNCONFIGURED) ; /* nothing to do */ else if ((flags DETACH_FORCE) == 0) rc = EBUSY; @@ -433,10 +434,11 @@ bp-b_error = EIO; break; } - done: - biodone(bp); + done: mutex_exit(sc-sc_lock); + + biodone(bp); } static int @@ -561,14 +563,23 @@ vaddr_t addr; vsize_t size; - KASSERT(mutex_owned(sc-sc_lock)); + mutex_exit(sc-sc_lock); /* Sanity check the size. */ size = umd-md_size; addr = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_WIRED|UVM_KMF_ZERO); + + mutex_enter(sc-sc_lock); + if (!addr) return ENOMEM; + /* If another thread beat us to configure this unit: fail. */ + if (sc-sc_type != MD_UNCONFIGURED) { + uvm_km_free(kernel_map, addr, size, UVM_KMF_WIRED); + return EINVAL; + } + /* This unit is now configured. */ sc-sc_addr = (void *)addr; /* kernel space */ sc-sc_size = (size_t)size;
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Sat Oct 17 10:29:30 UTC 2009 Modified Files: src/sys/dev: fss.c Log Message: Remove unneeded vinvalbuf() on backing store as we don't use VOP_BMAP()/VOP_STRATEGY() here. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.64 src/sys/dev/fss.c:1.65 --- src/sys/dev/fss.c:1.64 Tue Oct 13 12:37:19 2009 +++ src/sys/dev/fss.c Sat Oct 17 10:29:29 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.64 2009/10/13 12:37:19 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.65 2009/10/17 10:29:29 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.64 2009/10/13 12:37:19 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: fss.c,v 1.65 2009/10/17 10:29:29 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -705,14 +705,6 @@ sc-sc_bs_bmask = FSS_FSBSIZE(sc)-1; } - /* - * As all IO to from/to the backing store goes through - * VOP_STRATEGY() clean the buffer cache to prevent - * cache incoherencies. - */ - if ((error = vinvalbuf(sc-sc_bs_vp, V_SAVE, l-l_cred, l, 0, 0)) != 0) - return error; - return 0; }
CVS commit: src/sys/fs/udf
Module Name:src Committed By: hannken Date: Fri Oct 4 08:35:08 UTC 2013 Modified Files: src/sys/fs/udf: udf_vnops.c Log Message: Remove a bogus vrecycle() from udf_inactive(). Vrecycle() works on inactive vnodes while VOP_INACTIVE() should never be called on an inactive vnode. Ok: Reinoud Zandijk rein...@netbsd.org To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/fs/udf/udf_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/udf/udf_vnops.c diff -u src/sys/fs/udf/udf_vnops.c:1.85 src/sys/fs/udf/udf_vnops.c:1.86 --- src/sys/fs/udf/udf_vnops.c:1.85 Wed Jul 10 15:10:56 2013 +++ src/sys/fs/udf/udf_vnops.c Fri Oct 4 08:35:08 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_vnops.c,v 1.85 2013/07/10 15:10:56 reinoud Exp $ */ +/* $NetBSD: udf_vnops.c,v 1.86 2013/10/04 08:35:08 hannken Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -32,7 +32,7 @@ #include sys/cdefs.h #ifndef lint -__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.85 2013/07/10 15:10:56 reinoud Exp $); +__KERNEL_RCSID(0, $NetBSD: udf_vnops.c,v 1.86 2013/10/04 08:35:08 hannken Exp $); #endif /* not lint */ @@ -118,7 +118,6 @@ udf_inactive(void *v) *ap-a_recycle = true; udf_delete_node(udf_node); VOP_UNLOCK(vp); - vrecycle(vp, NULL, curlwp); return 0; }
CVS commit: src
Module Name:src Committed By: hannken Date: Tue Oct 29 09:53:51 UTC 2013 Modified Files: src/external/cddl/osnet/sys/sys: vnode.h src/share/man/man9: vnode.9 src/sys/kern: uipc_usrreq.c vfs_cache.c vfs_mount.c vfs_vnode.c src/sys/miscfs/procfs: procfs_subr.c src/sys/sys: param.h vnode.h src/sys/ufs/ext2fs: ext2fs_vfsops.c src/sys/ufs/ffs: ffs_vfsops.c src/sys/ufs/lfs: lfs_segment.c lfs_syscalls.c Log Message: Vnode API cleanup pass 1. - Make these defines and functions private to vfs_vnode.c: VC_MASK, VC_LOCK, DOCLOSE, VI_IANCTREDO and VI_INACTNOW vclean() and vrelel() - Remove the long time unused lwp argument from vrecycle(). - Remove vtryget(), it is responsible for ugly hacks and doesn't look that effective. Presented on tech-kern. Welcome to 6.99.25 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/external/cddl/osnet/sys/sys/vnode.h cvs rdiff -u -r1.56 -r1.57 src/share/man/man9/vnode.9 cvs rdiff -u -r1.147 -r1.148 src/sys/kern/uipc_usrreq.c cvs rdiff -u -r1.91 -r1.92 src/sys/kern/vfs_cache.c cvs rdiff -u -r1.22 -r1.23 src/sys/kern/vfs_mount.c src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.102 -r1.103 src/sys/miscfs/procfs/procfs_subr.c cvs rdiff -u -r1.433 -r1.434 src/sys/sys/param.h cvs rdiff -u -r1.238 -r1.239 src/sys/sys/vnode.h cvs rdiff -u -r1.173 -r1.174 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.289 -r1.290 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.232 -r1.233 src/sys/ufs/lfs/lfs_segment.c cvs rdiff -u -r1.149 -r1.150 src/sys/ufs/lfs/lfs_syscalls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/sys/vnode.h diff -u src/external/cddl/osnet/sys/sys/vnode.h:1.11 src/external/cddl/osnet/sys/sys/vnode.h:1.12 --- src/external/cddl/osnet/sys/sys/vnode.h:1.11 Mon Sep 23 20:44:24 2013 +++ src/external/cddl/osnet/sys/sys/vnode.h Tue Oct 29 09:53:51 2013 @@ -1,5 +1,5 @@ -/* $NetBSD: vnode.h,v 1.11 2013/09/23 20:44:24 christos Exp $ */ +/* $NetBSD: vnode.h,v 1.12 2013/10/29 09:53:51 hannken Exp $ */ /* * CDDL HEADER START @@ -686,7 +686,6 @@ vn_remove(char *fnamep, enum uio_seg seg #define VN_RELE_ASYNC(vp, taskq) vrele_async((vp)) #define vn_exists(a) do { } while(0) -#define vn_reinit(a) vclean((a), 0) /* * Flags for VOP_LOOKUP Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.56 src/share/man/man9/vnode.9:1.57 --- src/share/man/man9/vnode.9:1.56 Wed Feb 8 09:32:47 2012 +++ src/share/man/man9/vnode.9 Tue Oct 29 09:53:51 2013 @@ -1,4 +1,4 @@ -.\ $NetBSD: vnode.9,v 1.56 2012/02/08 09:32:47 wiz Exp $ +.\ $NetBSD: vnode.9,v 1.57 2013/10/29 09:53:51 hannken Exp $ .\ .\ Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -27,7 +27,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd February 8, 2012 +.Dd October 29, 2013 .Dt VNODE 9 .Os .Sh NAME @@ -79,7 +79,7 @@ .Ft void .Fn ungetnewvnode struct vnode *vp .Ft int -.Fn vrecycle struct vnode *vp struct simplelock *inter_lkp struct lwp *l +.Fn vrecycle struct vnode *vp struct simplelock *inter_lkp .Ft void .Fn vgone struct vnode *vp .Ft void @@ -617,7 +617,7 @@ This function is needed for .Xr VFS_VGET 9 which may need to push back a vnode in case of a locking race condition. -.It Fn vrecycle vp inter_lkp l +.It Fn vrecycle vp inter_lkp Recycle the unused vnode .Fa vp to the front of the freelist. Index: src/sys/kern/uipc_usrreq.c diff -u src/sys/kern/uipc_usrreq.c:1.147 src/sys/kern/uipc_usrreq.c:1.148 --- src/sys/kern/uipc_usrreq.c:1.147 Fri Oct 25 19:55:22 2013 +++ src/sys/kern/uipc_usrreq.c Tue Oct 29 09:53:51 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_usrreq.c,v 1.147 2013/10/25 19:55:22 martin Exp $ */ +/* $NetBSD: uipc_usrreq.c,v 1.148 2013/10/29 09:53:51 hannken Exp $ */ /*- * Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: uipc_usrreq.c,v 1.147 2013/10/25 19:55:22 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: uipc_usrreq.c,v 1.148 2013/10/29 09:53:51 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -851,7 +851,8 @@ unp_detach(struct unpcb *unp) /* XXXAD racy */ mutex_enter(vp-v_interlock); vp-v_socket = NULL; - vrelel(vp, 0); + mutex_exit(vp-v_interlock); + vrele(vp); solock(so); unp-unp_vnode = NULL; } Index: src/sys/kern/vfs_cache.c diff -u src/sys/kern/vfs_cache.c:1.91 src/sys/kern/vfs_cache.c:1.92 --- src/sys/kern/vfs_cache.c:1.91 Mon Nov 5 17:27:39 2012 +++ src/sys/kern/vfs_cache.c Tue Oct 29 09:53:51 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_cache.c,v 1.91 2012/11/05 17:27:39 dholland Exp $ */ +/* $NetBSD: vfs_cache.c,v 1.92 2013/10/29 09:53:51 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation,
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Sat Nov 2 10:30:18 UTC 2013 Modified Files: src/sys/fs/msdosfs: msdosfs_vnops.c Log Message: Stop using v_mount of an unreferenced vnode -- save the mount while the vnode has a reference. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.86 src/sys/fs/msdosfs/msdosfs_vnops.c:1.87 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.86 Mon Mar 18 19:35:37 2013 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Sat Nov 2 10:30:18 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.86 2013/03/18 19:35:37 plunky Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.87 2013/11/02 10:30:18 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.86 2013/03/18 19:35:37 plunky Exp $); +__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.87 2013/11/02 10:30:18 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -829,6 +829,7 @@ msdosfs_rename(void *v) struct vnode *tdvp = ap-a_tdvp; struct vnode *fvp = ap-a_fvp; struct vnode *fdvp = ap-a_fdvp; + struct mount *mp = fdvp-v_mount; struct componentname *tcnp = ap-a_tcnp; struct componentname *fcnp = ap-a_fcnp; struct denode *ip, *xp, *dp, *zp; @@ -906,7 +907,7 @@ abortit: } VN_KNOTE(fdvp, NOTE_WRITE); /* XXXLUKEM/XXX: right place? */ - fstrans_start(fdvp-v_mount, FSTRANS_SHARED); + fstrans_start(mp, FSTRANS_SHARED); /* * When the target exists, both the directory * and target vnodes are returned locked. @@ -993,7 +994,7 @@ abortit: * file/directory. */ if ((error = uniqdosname(VTODE(tdvp), tcnp, toname)) != 0) { - fstrans_done(fdvp-v_mount); + fstrans_done(mp); goto abortit; } @@ -1009,7 +1010,7 @@ abortit: VOP_UNLOCK(fdvp); vrele(ap-a_fvp); vrele(tdvp); - fstrans_done(fdvp-v_mount); + fstrans_done(mp); return (error); } if (fvp == NULL) { @@ -1021,7 +1022,7 @@ abortit: vput(fdvp); vrele(ap-a_fvp); vrele(tdvp); - fstrans_done(fdvp-v_mount); + fstrans_done(mp); return 0; } VOP_UNLOCK(fdvp); @@ -1129,7 +1130,7 @@ bad: ip-de_flag = ~DE_RENAME; vrele(fdvp); vrele(fvp); - fstrans_done(fdvp-v_mount); + fstrans_done(mp); return (error); /* XXX: uuuh */ @@ -1291,6 +1292,7 @@ msdosfs_rmdir(void *v) } */ *ap = v; struct vnode *vp = ap-a_vp; struct vnode *dvp = ap-a_dvp; + struct mount *mp = dvp-v_mount; struct componentname *cnp = ap-a_cnp; struct denode *ip, *dp; int error; @@ -1305,7 +1307,7 @@ msdosfs_rmdir(void *v) vput(vp); return (EINVAL); } - fstrans_start(ap-a_dvp-v_mount, FSTRANS_SHARED); + fstrans_start(mp, FSTRANS_SHARED); /* * Verify the directory is empty (and valid). * (Rmdir .. won't be valid since @@ -1347,7 +1349,7 @@ out: if (dvp) vput(dvp); vput(vp); - fstrans_done(ap-a_dvp-v_mount); + fstrans_done(mp); return (error); }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sun Nov 3 08:33:00 UTC 2013 Modified Files: src/sys/kern: vfs_vnode.c Log Message: cleanvnode(): - VC_XLOCK/VC_MASK are not used anymore, remove. - If we get a reference while cleaning, there is no need to retry as these reference and this vnode will disappear soon. - Make sure we run inside a fstrans transaction to prevent deadlocks against vget(). vrecycle(): - don't even try to recycle a vnode currently cleaning. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.23 src/sys/kern/vfs_vnode.c:1.24 --- src/sys/kern/vfs_vnode.c:1.23 Tue Oct 29 09:53:51 2013 +++ src/sys/kern/vfs_vnode.c Sun Nov 3 08:33:00 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.23 2013/10/29 09:53:51 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.24 2013/11/03 08:33:00 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -106,18 +106,8 @@ * from zero, the interlock must be held. To change from a non-zero * value to zero, again the interlock must be held. * - * There is a flag bit, VC_XLOCK, embedded in v_usecount. To raise - * v_usecount, if the VC_XLOCK bit is set in it, the interlock must - * be held. To modify the VC_XLOCK bit, the interlock must be held. - * We always keep the usecount (v_usecount VC_MASK) non-zero while - * the VC_XLOCK bit is set. - * - * Unless the VC_XLOCK bit is set, changing the usecount from a non-zero - * value to a non-zero value can safely be done using atomic operations, - * without the interlock held. - * - * Even if the VC_XLOCK bit is set, decreasing the usecount to a non-zero - * value can be done using atomic operations, without the interlock held. + * Changing the usecount from a non-zero value to a non-zero value can + * safely be done using atomic operations, without the interlock held. * * Note: if VI_CLEAN is set, vnode_t::v_interlock will be released while * mntvnode_lock is still held. @@ -126,7 +116,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.23 2013/10/29 09:53:51 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.24 2013/11/03 08:33:00 hannken Exp $); #define _VFS_VNODE_PRIVATE @@ -148,14 +138,11 @@ __KERNEL_RCSID(0, $NetBSD: vfs_vnode.c, #include sys/systm.h #include sys/vnode.h #include sys/wapbl.h +#include sys/fstrans.h #include uvm/uvm.h #include uvm/uvm_readahead.h -/* v_usecount; see the comment near the top of vfs_vnode.c */ -#define VC_XLOCK 0x8000 -#define VC_MASK 0x7fff - #define DOCLOSE 0x0008 /* vclean: close active files */ /* Flags to vrelel. */ @@ -284,9 +271,10 @@ cleanvnode(void) { vnode_t *vp; vnodelst_t *listhd; + struct mount *mp; KASSERT(mutex_owned(vnode_free_list_lock)); -retry: + listhd = vnode_free_list; try_nextlist: TAILQ_FOREACH(vp, listhd, v_freelist) { @@ -302,9 +290,16 @@ try_nextlist: if (!mutex_tryenter(vp-v_interlock)) continue; - if ((vp-v_iflag VI_XLOCK) == 0) - break; - mutex_exit(vp-v_interlock); + if ((vp-v_iflag VI_XLOCK) != 0) { + mutex_exit(vp-v_interlock); + continue; + } + mp = vp-v_mount; + if (fstrans_start_nowait(mp, FSTRANS_SHARED) != 0) { + mutex_exit(vp-v_interlock); + continue; + } + break; } if (vp == NULL) { @@ -326,37 +321,12 @@ try_nextlist: /* * The vnode is still associated with a file system, so we must * clean it out before freeing it. We need to add a reference - * before doing this. If the vnode gains another reference while - * being cleaned out then we lose - retry. + * before doing this. */ - atomic_add_int(vp-v_usecount, 1 + VC_XLOCK); + vp-v_usecount = 1; vclean(vp, DOCLOSE); - KASSERT(vp-v_usecount = 1 + VC_XLOCK); - atomic_add_int(vp-v_usecount, -VC_XLOCK); - if (vp-v_usecount 1) { - /* - * Don't return to freelist - the holder of the last - * reference will destroy it. - */ - vrelel(vp, 0); /* releases vp-v_interlock */ - mutex_enter(vnode_free_list_lock); - goto retry; - } - - KASSERT((vp-v_iflag VI_CLEAN) == VI_CLEAN); - mutex_exit(vp-v_interlock); - if (vp-v_type == VBLK || vp-v_type == VCHR) { - spec_node_destroy(vp); - } - vp-v_type = VNON; - - KASSERT(vp-v_data == NULL); - KASSERT(vp-v_uobj.uo_npages == 0); - KASSERT(TAILQ_EMPTY(vp-v_uobj.memq)); - KASSERT(vp-v_numoutput == 0); - KASSERT((vp-v_iflag VI_ONWORKLST) == 0); - - vrele(vp); + vrelel(vp, 0); + fstrans_done(mp); return 0; } @@ -604,7 +574,7 @@ vtryrele(vnode_t *vp) if (use == 1) { return false; } - KASSERT((use VC_MASK) 1); + KASSERT(use 1); next = atomic_cas_uint(vp-v_usecount, use, use - 1); if (__predict_true(next == use)) { return true; @@ -990,7 +960,7 @@ vclean(vnode_t *vp, int flags)
CVS commit: src/sys/miscfs/deadfs
Module Name:src Committed By: hannken Date: Thu Nov 7 09:45:53 UTC 2013 Modified Files: src/sys/miscfs/deadfs: dead_vnops.c Log Message: Add missing operations that unlock or dereference their arguments. Stop checking for a vnode state change -- dead vnodes never change state. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/miscfs/deadfs/dead_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/deadfs/dead_vnops.c diff -u src/sys/miscfs/deadfs/dead_vnops.c:1.51 src/sys/miscfs/deadfs/dead_vnops.c:1.52 --- src/sys/miscfs/deadfs/dead_vnops.c:1.51 Sun Jun 12 03:35:57 2011 +++ src/sys/miscfs/deadfs/dead_vnops.c Thu Nov 7 09:45:53 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: dead_vnops.c,v 1.51 2011/06/12 03:35:57 rmind Exp $ */ +/* $NetBSD: dead_vnops.c,v 1.52 2013/11/07 09:45:53 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: dead_vnops.c,v 1.51 2011/06/12 03:35:57 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: dead_vnops.c,v 1.52 2013/11/07 09:45:53 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -48,6 +48,10 @@ __KERNEL_RCSID(0, $NetBSD: dead_vnops.c /* * Prototypes for dead operations on vnodes. */ +#define dead_bwrite genfs_nullop +int dead_lookup(void *); +int dead_create(void *); +int dead_mknod(void *); int dead_open(void *); #define dead_close genfs_nullop int dead_read(void *); @@ -55,28 +59,36 @@ int dead_write(void *); #define dead_fcntl genfs_nullop int dead_ioctl(void *); int dead_poll(void *); +int dead_remove(void *); +int dead_link(void *); +int dead_rename(void *); +int dead_mkdir(void *); +int dead_rmdir(void *); +int dead_symlink(void *); #define dead_fsync genfs_nullop #define dead_seek genfs_nullop -#define dead_inactive genfs_nullop +int dead_inactive(void *); #define dead_reclaim genfs_nullop -int dead_lock(void *); +#define dead_lock genfs_lock #define dead_unlock genfs_unlock int dead_bmap(void *); int dead_strategy(void *); int dead_print(void *); #define dead_islocked genfs_islocked -#define dead_bwrite genfs_nullop #define dead_revoke genfs_nullop int dead_getpages(void *); -#define dead_putpages genfs_null_putpages +int dead_putpages(void *); -int chkvnlock(struct vnode *); int dead_default_error(void *); int (**dead_vnodeop_p)(void *); const struct vnodeopv_entry_desc dead_vnodeop_entries[] = { { vop_default_desc, dead_default_error }, + { vop_bwrite_desc, dead_bwrite }, /* bwrite */ + { vop_lookup_desc, dead_lookup }, /* lookup */ + { vop_create_desc, dead_create }, /* create */ + { vop_mknod_desc, dead_mknod }, /* mknod */ { vop_open_desc, dead_open }, /* open */ { vop_close_desc, dead_close }, /* close */ { vop_read_desc, dead_read }, /* read */ @@ -84,7 +96,12 @@ const struct vnodeopv_entry_desc dead_vn { vop_fcntl_desc, dead_fcntl }, /* fcntl */ { vop_ioctl_desc, dead_ioctl }, /* ioctl */ { vop_poll_desc, dead_poll }, /* poll */ - { vop_revoke_desc, dead_revoke }, /* revoke */ + { vop_remove_desc, dead_remove }, /* remove */ + { vop_link_desc, dead_link }, /* link */ + { vop_rename_desc, dead_rename }, /* rename */ + { vop_mkdir_desc, dead_mkdir }, /* mkdir */ + { vop_rmdir_desc, dead_rmdir }, /* rmdir */ + { vop_symlink_desc, dead_symlink }, /* symlink */ { vop_fsync_desc, dead_fsync }, /* fsync */ { vop_seek_desc, dead_seek }, /* seek */ { vop_inactive_desc, dead_inactive }, /* inactive */ @@ -95,7 +112,7 @@ const struct vnodeopv_entry_desc dead_vn { vop_strategy_desc, dead_strategy }, /* strategy */ { vop_print_desc, dead_print }, /* print */ { vop_islocked_desc, dead_islocked }, /* islocked */ - { vop_bwrite_desc, dead_bwrite }, /* bwrite */ + { vop_revoke_desc, dead_revoke }, /* revoke */ { vop_getpages_desc, dead_getpages }, /* getpages */ { vop_putpages_desc, dead_putpages }, /* putpages */ { NULL, NULL } @@ -103,6 +120,7 @@ const struct vnodeopv_entry_desc dead_vn const struct vnodeopv_desc dead_vnodeop_opv_desc = { dead_vnodeop_p, dead_vnodeop_entries }; +/* ARGSUSED */ int dead_default_error(void *v) { @@ -110,21 +128,78 @@ dead_default_error(void *v) return EBADF; } -/* - * Open always fails as if device did not exist. - */ +/* ARGSUSED */ +int +dead_bmap(void *v) +{ + /* struct vop_bmap_args { + struct vnode *a_vp; + daddr_t a_bn; + struct vnode **a_vpp; + daddr_t *a_bnp; + int *a_runp; + } *ap = v; */ + + return (EIO); +} + +int +dead_lookup(void *v) +{ + struct vop_lookup_args /* { + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + } */ *ap = v; + + *(ap-a_vpp) = NULL; + + return EIO; +} + +int +dead_create(void *v) +{ + struct vop_create_args /* { + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; + } */ *ap = v; + +
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Thu Nov 7 09:48:34 UTC 2013 Modified Files: src/sys/kern: vfs_vnode.c src/sys/sys: vnode.h Log Message: Make vclean static (ride 6.99.2). DOCLOSE is no longer needed -- remove. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.239 -r1.240 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.24 src/sys/kern/vfs_vnode.c:1.25 --- src/sys/kern/vfs_vnode.c:1.24 Sun Nov 3 08:33:00 2013 +++ src/sys/kern/vfs_vnode.c Thu Nov 7 09:48:34 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.24 2013/11/03 08:33:00 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.25 2013/11/07 09:48:34 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -116,7 +116,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.24 2013/11/03 08:33:00 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.25 2013/11/07 09:48:34 hannken Exp $); #define _VFS_VNODE_PRIVATE @@ -143,8 +143,6 @@ __KERNEL_RCSID(0, $NetBSD: vfs_vnode.c, #include uvm/uvm.h #include uvm/uvm_readahead.h -#define DOCLOSE 0x0008 /* vclean: close active files */ - /* Flags to vrelel. */ #define VRELEL_ASYNC_RELE 0x0001 /* Always defer to vrele thread. */ @@ -170,6 +168,7 @@ static int vrele_pending __cacheline_a static int vrele_gen __cacheline_aligned; static int cleanvnode(void); +static void vclean(vnode_t *); static void vrelel(vnode_t *, int); static void vdrain_thread(void *); static void vrele_thread(void *); @@ -324,7 +323,7 @@ try_nextlist: * before doing this. */ vp-v_usecount = 1; - vclean(vp, DOCLOSE); + vclean(vp); vrelel(vp, 0); fstrans_done(mp); @@ -751,7 +750,7 @@ retry: * otherwise just free it. */ if (recycle) { - vclean(vp, DOCLOSE); + vclean(vp); } KASSERT(vp-v_usecount 0); } @@ -928,11 +927,11 @@ holdrelel(vnode_t *vp) * * Must be called with the interlock held, and will return with it held. */ -void -vclean(vnode_t *vp, int flags) +static void +vclean(vnode_t *vp) { lwp_t *l = curlwp; - bool recycle, active, make_anon; + bool recycle, active, doclose; int error; KASSERT(mutex_owned(vp-v_interlock)); @@ -966,10 +965,8 @@ vclean(vnode_t *vp, int flags) mutex_exit(vp-v_interlock); VOP_LOCK(vp, LK_EXCLUSIVE); - make_anon = (active vp-v_type == VBLK + doclose = ! (active vp-v_type == VBLK spec_node_getmountedfs(vp) != NULL); - if (make_anon) - flags = ~DOCLOSE; /* * Clean out any cached data associated with the vnode. @@ -977,11 +974,9 @@ vclean(vnode_t *vp, int flags) * deactivated before being reclaimed. Note that the * VOP_INACTIVE will unlock the vnode. */ - if (flags DOCLOSE) { + if (doclose) { error = vinvalbuf(vp, V_SAVE, NOCRED, l, 0, 0); if (error != 0) { - /* XXX, fix vn_start_write's grab of mp and use that. */ - if (wapbl_vphaswapbl(vp)) WAPBL_DISCARD(wapbl_vptomp(vp)); error = vinvalbuf(vp, 0, NOCRED, l, 0, 0); @@ -1022,23 +1017,22 @@ vclean(vnode_t *vp, int flags) * The vnode isn't clean, but still resides on the mount list. Remove * it. XXX This is a bit dodgy. */ - if (make_anon) + if (! doclose) vfs_insmntque(vp, NULL); /* Done with purge, notify sleepers of the grim news. */ mutex_enter(vp-v_interlock); - if (make_anon) { - vp-v_op = spec_vnodeop_p; - } else { + if (doclose) { vp-v_op = dead_vnodeop_p; + vp-v_vflag |= VV_LOCKSWORK; + vp-v_iflag |= VI_CLEAN; + } else { + vp-v_op = spec_vnodeop_p; + vp-v_vflag = ~VV_LOCKSWORK; } vp-v_tag = VT_NON; KNOTE(vp-v_klist, NOTE_REVOKE); vp-v_iflag = ~VI_XLOCK; - vp-v_vflag = ~VV_LOCKSWORK; - if ((flags DOCLOSE) != 0) { - vp-v_iflag |= VI_CLEAN; - } cv_broadcast(vp-v_cv); KASSERT((vp-v_iflag VI_ONWORKLST) == 0); @@ -1064,7 +1058,7 @@ vrecycle(vnode_t *vp, kmutex_t *inter_lk } vremfree(vp); vp-v_usecount = 1; - vclean(vp, DOCLOSE); + vclean(vp); vrelel(vp, 0); return 1; } @@ -1088,7 +1082,7 @@ vrevoke(vnode_t *vp) return; } else if (vp-v_type != VBLK vp-v_type != VCHR) { atomic_inc_uint(vp-v_usecount); - vclean(vp, DOCLOSE); + vclean(vp); vrelel(vp, 0); return; } else { @@ -1099,7 +1093,7 @@ vrevoke(vnode_t *vp) while (spec_node_lookup_by_dev(type, dev, vq) == 0) { mutex_enter(vq-v_interlock); - vclean(vq, DOCLOSE); + vclean(vq); vrelel(vq, 0); } } @@ -1113,7 +1107,7 @@ vgone(vnode_t *vp) { mutex_enter(vp-v_interlock); - vclean(vp, DOCLOSE); + vclean(vp); vrelel(vp, 0); } Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.239 src/sys/sys/vnode.h:1.240 --- src/sys/sys/vnode.h:1.239 Tue Oct 29 09:53:51 2013 +++ src/sys/sys/vnode.h Thu Nov 7 09:48:34 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.239 2013/10/29
CVS commit: src/usr.sbin/fssconfig
Module Name:src Committed By: hannken Date: Fri Nov 15 09:13:57 UTC 2013 Modified Files: src/usr.sbin/fssconfig: fssconfig.8 Log Message: Describe the differences between file system internal and external snapshots. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/fssconfig/fssconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/fssconfig/fssconfig.8 diff -u src/usr.sbin/fssconfig/fssconfig.8:1.10 src/usr.sbin/fssconfig/fssconfig.8:1.11 --- src/usr.sbin/fssconfig/fssconfig.8:1.10 Tue Mar 5 23:01:06 2013 +++ src/usr.sbin/fssconfig/fssconfig.8 Fri Nov 15 09:13:57 2013 @@ -1,4 +1,4 @@ -.\ $NetBSD: fssconfig.8,v 1.10 2013/03/05 23:01:06 wiz Exp $ */ +.\ $NetBSD: fssconfig.8,v 1.11 2013/11/15 09:13:57 hannken Exp $ */ .\ .\ .\ Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd June 11, 2012 +.Dd November 15, 2013 .Dt FSSCONFIG 8 .Os .Sh NAME @@ -63,6 +63,10 @@ resides on the snapshotted file system a This snapshot is active until .Ar backup is unlinked. +Persistent snapshots save the file system as if it had been unmounted. +Unlinked but open files get removed from the snapshot. +The time to create a persistent snapshot increases with the size of the +file system and decreases with the file system block size. This snapshot mode is only supported for FFS file systems. .Pp Otherwise data written through the @@ -80,6 +84,10 @@ Data is saved to in units of .Ar cluster bytes. +The snapshot is an image in time of the underlying block device. +Unlinked but open files are still present on the snapshot. +The time to create a snapshot is independent of the size of the +file system or the file system block size. .Pp Options indicate an action to be performed: .Bl -tag -width 3n
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Sat Nov 23 13:46:22 UTC 2013 Modified Files: src/sys/kern: vfs_vnode.c src/sys/sys: vnode.h Log Message: Replace VI_INACTNOW and VI_INACTREDO with a new flag VI_CHANGING that gets set while a vnode changes state from active to inactive or from active or inactive to clean and protects vclean(); vrelel() and vrelel() against vget(). Presented on tech-kern. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.240 -r1.241 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.25 src/sys/kern/vfs_vnode.c:1.26 --- src/sys/kern/vfs_vnode.c:1.25 Thu Nov 7 09:48:34 2013 +++ src/sys/kern/vfs_vnode.c Sat Nov 23 13:46:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.25 2013/11/07 09:48:34 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.26 2013/11/23 13:46:22 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -116,7 +116,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.25 2013/11/07 09:48:34 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.26 2013/11/23 13:46:22 hannken Exp $); #define _VFS_VNODE_PRIVATE @@ -145,6 +145,7 @@ __KERNEL_RCSID(0, $NetBSD: vfs_vnode.c, /* Flags to vrelel. */ #define VRELEL_ASYNC_RELE 0x0001 /* Always defer to vrele thread. */ +#define VRELEL_CHANGING_SET 0x0002 /* VI_CHANGING set by caller. */ u_int numvnodes __cacheline_aligned; @@ -323,8 +324,10 @@ try_nextlist: * before doing this. */ vp-v_usecount = 1; + KASSERT((vp-v_iflag VI_CHANGING) == 0); + vp-v_iflag |= VI_CHANGING; vclean(vp); - vrelel(vp, 0); + vrelel(vp, VRELEL_CHANGING_SET); fstrans_done(mp); return 0; @@ -476,10 +479,10 @@ vremfree(vnode_t *vp) * * = Should be called with v_interlock held. * - * If VI_XLOCK is set, the vnode is being eliminated in vgone()/vclean(). + * If VI_CHANGING is set, the vnode may be eliminated in vgone()/vclean(). * In that case, we cannot grab the vnode, so the process is awakened when * the transition is completed, and an error returned to indicate that the - * vnode is no longer usable (e.g. changed to a new file system type). + * vnode is no longer usable. */ int vget(vnode_t *vp, int flags) @@ -502,31 +505,16 @@ vget(vnode_t *vp, int flags) } /* - * If the vnode is in the process of being cleaned out for - * another use, we wait for the cleaning to finish and then - * return failure. Cleaning is determined by checking if - * the VI_XLOCK flag is set. + * If the vnode is in the process of changing state we wait + * for the change to complete and take care not to return + * a clean vnode. */ - if ((vp-v_iflag VI_XLOCK) != 0) { + if ((vp-v_iflag VI_CHANGING) != 0) { if ((flags LK_NOWAIT) != 0) { vrelel(vp, 0); return EBUSY; } - vwait(vp, VI_XLOCK); - vrelel(vp, 0); - return ENOENT; - } - - if ((vp-v_iflag VI_INACTNOW) != 0) { - /* - * if it's being desactived, wait for it to complete. - * Make sure to not return a clean vnode. - */ - if ((flags LK_NOWAIT) != 0) { - vrelel(vp, 0); - return EBUSY; - } - vwait(vp, VI_INACTNOW); + vwait(vp, VI_CHANGING); if ((vp-v_iflag VI_CLEAN) != 0) { vrelel(vp, 0); return ENOENT; @@ -605,7 +593,11 @@ vrelel(vnode_t *vp, int flags) * and unlock. */ if (vtryrele(vp)) { - vp-v_iflag |= VI_INACTREDO; + if ((flags VRELEL_CHANGING_SET) != 0) { + KASSERT((vp-v_iflag VI_CHANGING) != 0); + vp-v_iflag = ~VI_CHANGING; + cv_broadcast(vp-v_cv); + } mutex_exit(vp-v_interlock); return; } @@ -614,6 +606,10 @@ vrelel(vnode_t *vp, int flags) } KASSERT((vp-v_iflag VI_XLOCK) == 0); + if ((flags VRELEL_CHANGING_SET) == 0) { + KASSERT((vp-v_iflag VI_CHANGING) == 0); + vp-v_iflag |= VI_CHANGING; + } #ifdef DIAGNOSTIC if ((vp-v_type == VBLK || vp-v_type == VCHR) @@ -626,10 +622,8 @@ vrelel(vnode_t *vp, int flags) * If not clean, deactivate the vnode, but preserve * our reference across the call to VOP_INACTIVE(). */ -retry: if ((vp-v_iflag VI_CLEAN) == 0) { recycle = false; - vp-v_iflag |= VI_INACTNOW; /* * XXX This ugly block can be largely eliminated if @@ -644,11 +638,8 @@ retry: defer = true; } else if (curlwp == vrele_lwp) { /* - * We have to try harder. But we can't sleep - * with VI_INACTNOW as vget() may be waiting on it. + * We have to try harder. */ - vp-v_iflag = ~(VI_INACTREDO|VI_INACTNOW); - cv_broadcast(vp-v_cv); mutex_exit(vp-v_interlock); error = vn_lock(vp, LK_EXCLUSIVE); if (error != 0) { @@ -663,10 +654,12 @@ retry: */ if (__predict_false(vtryrele(vp))) { VOP_UNLOCK(vp); +KASSERT((vp-v_iflag VI_CHANGING) != 0); +vp-v_iflag = ~VI_CHANGING; +
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Nov 29 14:58:55 UTC 2013 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Change vrelel() to mark the vnode as changing after it has aquired the vnode lock but before it calls VOP_INACTIVE(). Should fix the race between layer_node_find() trying to vget(, LK_NOWAIT) a locked vnode when vrelel() marked it as changing and wants its lock. PR kern/48411 (repeatable SMP crashes in amd64-current) To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.26 src/sys/kern/vfs_vnode.c:1.27 --- src/sys/kern/vfs_vnode.c:1.26 Sat Nov 23 13:46:22 2013 +++ src/sys/kern/vfs_vnode.c Fri Nov 29 14:58:55 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.26 2013/11/23 13:46:22 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.27 2013/11/29 14:58:55 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -116,7 +116,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.26 2013/11/23 13:46:22 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.27 2013/11/29 14:58:55 hannken Exp $); #define _VFS_VNODE_PRIVATE @@ -606,10 +606,6 @@ vrelel(vnode_t *vp, int flags) } KASSERT((vp-v_iflag VI_XLOCK) == 0); - if ((flags VRELEL_CHANGING_SET) == 0) { - KASSERT((vp-v_iflag VI_CHANGING) == 0); - vp-v_iflag |= VI_CHANGING; - } #ifdef DIAGNOSTIC if ((vp-v_type == VBLK || vp-v_type == VCHR) @@ -654,13 +650,14 @@ vrelel(vnode_t *vp, int flags) */ if (__predict_false(vtryrele(vp))) { VOP_UNLOCK(vp); -KASSERT((vp-v_iflag VI_CHANGING) != 0); -vp-v_iflag = ~VI_CHANGING; -cv_broadcast(vp-v_cv); +if ((flags VRELEL_CHANGING_SET) != 0) { + KASSERT((vp-v_iflag VI_CHANGING) != 0); + vp-v_iflag = ~VI_CHANGING; + cv_broadcast(vp-v_cv); +} mutex_exit(vp-v_interlock); return; } - mutex_exit(vp-v_interlock); defer = false; } else if ((vp-v_iflag VI_LAYER) != 0) { /* @@ -675,10 +672,10 @@ vrelel(vnode_t *vp, int flags) error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT); if (error != 0) { defer = true; -mutex_enter(vp-v_interlock); } else { defer = false; } + mutex_enter(vp-v_interlock); } if (defer) { @@ -687,18 +684,26 @@ vrelel(vnode_t *vp, int flags) * clean it here. We donate it our last reference. */ KASSERT(mutex_owned(vp-v_interlock)); - KASSERT((vp-v_iflag VI_CHANGING) != 0); - vp-v_iflag = ~VI_CHANGING; + if ((flags VRELEL_CHANGING_SET) != 0) { +KASSERT((vp-v_iflag VI_CHANGING) != 0); +vp-v_iflag = ~VI_CHANGING; +cv_broadcast(vp-v_cv); + } mutex_enter(vrele_lock); TAILQ_INSERT_TAIL(vrele_list, vp, v_freelist); if (++vrele_pending (desiredvnodes 8)) cv_signal(vrele_cv); mutex_exit(vrele_lock); - cv_broadcast(vp-v_cv); mutex_exit(vp-v_interlock); return; } + if ((flags VRELEL_CHANGING_SET) == 0) { + KASSERT((vp-v_iflag VI_CHANGING) == 0); + vp-v_iflag |= VI_CHANGING; + } + mutex_exit(vp-v_interlock); + /* * The vnode can gain another reference while being * deactivated. If VOP_INACTIVE() indicates that @@ -739,6 +744,11 @@ vrelel(vnode_t *vp, int flags) vclean(vp); } KASSERT(vp-v_usecount 0); + } else { /* vnode was already clean */ + if ((flags VRELEL_CHANGING_SET) == 0) { + KASSERT((vp-v_iflag VI_CHANGING) == 0); + vp-v_iflag |= VI_CHANGING; + } } if (atomic_dec_uint_nv(vp-v_usecount) != 0) {
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sat Dec 7 10:03:28 UTC 2013 Modified Files: src/sys/kern: vfs_vnode.c Log Message: When deciding to defer in vrelel(): - No need to always defer layer vnodes, if we get the vnode lock it is safe to inactivate. - Always use VOP_LOCK(), it makes no sense to use vn_lock() here. - No need to drop v_interlock for VOP_LOCK(... LK_NOWAIT). To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.29 src/sys/kern/vfs_vnode.c:1.30 --- src/sys/kern/vfs_vnode.c:1.29 Sun Dec 1 17:29:40 2013 +++ src/sys/kern/vfs_vnode.c Sat Dec 7 10:03:28 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.29 2013/12/01 17:29:40 christos Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.30 2013/12/07 10:03:28 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -116,7 +116,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.29 2013/12/01 17:29:40 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.30 2013/12/07 10:03:28 hannken Exp $); #define _VFS_VNODE_PRIVATE @@ -626,27 +626,22 @@ vrelel(vnode_t *vp, int flags) * locking is pushed down into the file systems. * * Defer vnode release to vrele_thread if caller - * requests it explicitly. + * requests it explicitly or is the pagedaemon. */ if ((curlwp == uvm.pagedaemon_lwp) || (flags VRELEL_ASYNC_RELE) != 0) { - /* The pagedaemon can't wait around; defer. */ defer = true; } else if (curlwp == vrele_lwp) { /* * We have to try harder. */ mutex_exit(vp-v_interlock); - error = vn_lock(vp, LK_EXCLUSIVE); - if (error != 0) { -/* XXX */ -vnpanic(vp, %s: unable to lock %p, -__func__, vp); - } + error = VOP_LOCK(vp, LK_EXCLUSIVE); + KASSERT(error == 0); mutex_enter(vp-v_interlock); /* - * if we did get another reference while - * sleeping, don't try to inactivate it yet. + * If the node got another reference while sleeping, + * don't try to inactivate it yet. */ if (__predict_false(vtryrele(vp))) { VOP_UNLOCK(vp); @@ -659,31 +654,20 @@ vrelel(vnode_t *vp, int flags) return; } defer = false; - } else if ((vp-v_iflag VI_LAYER) != 0) { - /* - * Acquiring the stack's lock in vclean() even - * for an honest vput/vrele is dangerous because - * our caller may hold other vnode locks; defer. - */ - defer = true; } else { /* If we can't acquire the lock, then defer. */ - mutex_exit(vp-v_interlock); - error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT); - if (error != 0) { -defer = true; - } else { -defer = false; - } - mutex_enter(vp-v_interlock); + error = VOP_LOCK(vp, LK_EXCLUSIVE | LK_NOWAIT); + defer = (error != 0); } + KASSERT(mutex_owned(vp-v_interlock)); + KASSERT(! (curlwp == vrele_lwp defer)); + if (defer) { /* * Defer reclaim to the kthread; it's not safe to * clean it here. We donate it our last reference. */ - KASSERT(mutex_owned(vp-v_interlock)); if ((flags VRELEL_CHANGING_SET) != 0) { KASSERT((vp-v_iflag VI_CHANGING) != 0); vp-v_iflag = ~VI_CHANGING;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Tue Dec 24 09:23:33 UTC 2013 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: It is not the task of tmpfs_open() to check for unlinked nodes. Fix tmpfs_lookup() to always return ENOENT when looking up from an unlinked directory. To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.109 src/sys/fs/tmpfs/tmpfs_vnops.c:1.110 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.109 Sun Nov 24 17:16:29 2013 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Tue Dec 24 09:23:33 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.109 2013/11/24 17:16:29 rmind Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.110 2013/12/24 09:23:33 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.109 2013/11/24 17:16:29 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.110 2013/12/24 09:23:33 hannken Exp $); #include sys/param.h #include sys/dirent.h @@ -176,6 +176,15 @@ tmpfs_lookup(void *v) goto out; } + /* + * Treat an unlinked directory as empty (no . or ..) + */ + if (dnode-tn_links == 0) { + KASSERT(dnode-tn_size == 0); + error = ENOENT; + goto out; + } + if (cnp-cn_flags ISDOTDOT) { tmpfs_node_t *pnode; @@ -352,14 +361,6 @@ tmpfs_open(void *v) KASSERT(VOP_ISLOCKED(vp)); node = VP_TO_TMPFS_NODE(vp); - if (node-tn_links 1) { - /* - * The file is still active, but all its names have been - * removed (e.g. by a rmdir $(pwd)). It cannot be opened - * any more, as it is about to be destroyed. - */ - return ENOENT; - } /* If the file is marked append-only, deny write requests. */ if ((node-tn_flags APPEND) != 0
CVS commit: src/sys/fs/sysvbfs
Module Name:src Committed By: hannken Date: Tue Dec 24 09:56:18 UTC 2013 Modified Files: src/sys/fs/sysvbfs: sysvbfs_vnops.c Log Message: It is not the task of sysvbfs_open() to check for unlinked nodes. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/fs/sysvbfs/sysvbfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/sysvbfs/sysvbfs_vnops.c diff -u src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.48 src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.49 --- src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.48 Wed May 15 16:44:03 2013 +++ src/sys/fs/sysvbfs/sysvbfs_vnops.c Tue Dec 24 09:56:18 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: sysvbfs_vnops.c,v 1.48 2013/05/15 16:44:03 pooka Exp $ */ +/* $NetBSD: sysvbfs_vnops.c,v 1.49 2013/12/24 09:56:18 hannken Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysvbfs_vnops.c,v 1.48 2013/05/15 16:44:03 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: sysvbfs_vnops.c,v 1.49 2013/12/24 09:56:18 hannken Exp $); #include sys/param.h #include sys/kernel.h @@ -185,14 +185,10 @@ sysvbfs_open(void *arg) struct vnode *v = a-a_vp; struct sysvbfs_node *bnode = v-v_data; struct bfs_inode *inode = bnode-inode; - struct bfs *bfs = bnode-bmp-bfs; - struct bfs_dirent *dirent; DPRINTF(%s:\n, __func__); KDASSERT(v-v_type == VREG || v-v_type == VDIR); - if (!bfs_dirent_lookup_by_inode(bfs, inode-number, dirent)) - return ENOENT; bnode-update_atime = true; if ((a-a_mode FWRITE) !(a-a_mode O_APPEND)) { bnode-size = 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Fri Jan 3 09:53:12 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c tmpfs_vnops.c Log Message: Fix a race where thread1 runs VOP_REMOVE() and gets preempted in tmpfs_reclaim() before the call to tmpfs_free_node(). Thread2 runs VFS_FHTOVP() and gets a new vnode attached to the node thread1 is about to destroy. Change tmpfs_alloc_node() to always assign non-zero generation number and tmpfs_inactive() to set the generation number of unlinked nodes to zero. To generate a diff of this commit: cvs rdiff -u -r1.92 -r1.93 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.110 -r1.111 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.92 src/sys/fs/tmpfs/tmpfs_subr.c:1.93 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.92 Sun Nov 24 17:16:29 2013 +++ src/sys/fs/tmpfs/tmpfs_subr.c Fri Jan 3 09:53:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.92 2013/11/24 17:16:29 rmind Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.93 2014/01/03 09:53:12 hannken Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tmpfs_subr.c,v 1.92 2013/11/24 17:16:29 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_subr.c,v 1.93 2014/01/03 09:53:12 hannken Exp $); #include sys/param.h #include sys/cprng.h @@ -127,7 +127,13 @@ tmpfs_alloc_node(tmpfs_mount_t *tmp, enu * for applications that do not understand 64-bit ino_t. */ nnode-tn_id = (ino_t)((uintptr_t)nnode / sizeof(*nnode)); - nnode-tn_gen = TMPFS_NODE_GEN_MASK cprng_fast32(); + /* + * Make sure the generation number is not zero. + * tmpfs_inactive() uses generation zero to mark dead nodes. + */ + do { + nnode-tn_gen = TMPFS_NODE_GEN_MASK cprng_fast32(); + } while (nnode-tn_gen == 0); /* Generic initialization. */ nnode-tn_type = type; @@ -252,6 +258,7 @@ tmpfs_free_node(tmpfs_mount_t *tmp, tmpf default: break; } + KASSERT(node-tn_vnode == NULL); KASSERT(node-tn_links == 0); mutex_destroy(node-tn_vlock); Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.110 src/sys/fs/tmpfs/tmpfs_vnops.c:1.111 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.110 Tue Dec 24 09:23:33 2013 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Fri Jan 3 09:53:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.110 2013/12/24 09:23:33 hannken Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.111 2014/01/03 09:53:12 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.110 2013/12/24 09:23:33 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.111 2014/01/03 09:53:12 hannken Exp $); #include sys/param.h #include sys/dirent.h @@ -49,6 +49,7 @@ __KERNEL_RCSID(0, $NetBSD: tmpfs_vnops. #include sys/vnode.h #include sys/lockf.h #include sys/kauth.h +#include sys/atomic.h #include uvm/uvm.h @@ -1052,7 +1053,15 @@ tmpfs_inactive(void *v) KASSERT(VOP_ISLOCKED(vp)); node = VP_TO_TMPFS_NODE(vp); - *ap-a_recycle = (node-tn_links == 0); + if (node-tn_links == 0) { + /* + * Mark node as dead by setting its generation to zero. + */ + atomic_and_32(node-tn_gen, ~TMPFS_NODE_GEN_MASK); + *ap-a_recycle = true; + } else { + *ap-a_recycle = false; + } VOP_UNLOCK(vp); return 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Sat Jan 4 12:36:49 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Fix a race where thread1 runs VOP_REMOVE() and gets preempted in tmpfs_reclaim() before the call to tmpfs_free_node(). Thread2 runs VFS_FHTOVP() and gets a new vnode attached to the node thread1 is about to destroy. Change tmpfs_fhtovp() to check the generation number after tmpfs_vnode_get() succeeded. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/fs/tmpfs/tmpfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.55 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.56 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.55 Sat Nov 23 16:35:32 2013 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Sat Jan 4 12:36:49 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.55 2013/11/23 16:35:32 rmind Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.56 2014/01/04 12:36:49 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tmpfs_vfsops.c,v 1.55 2013/11/23 16:35:32 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vfsops.c,v 1.56 2014/01/04 12:36:49 hannken Exp $); #include sys/param.h #include sys/types.h @@ -282,6 +282,7 @@ tmpfs_fhtovp(struct mount *mp, struct fi tmpfs_mount_t *tmp = VFS_TO_TMPFS(mp); tmpfs_node_t *node; tmpfs_fid_t tfh; + int error; if (fhp-fid_len != sizeof(tmpfs_fid_t)) { return EINVAL; @@ -290,19 +291,25 @@ tmpfs_fhtovp(struct mount *mp, struct fi mutex_enter(tmp-tm_lock); LIST_FOREACH(node, tmp-tm_nodes, tn_entries) { - if (node-tn_id != tfh.tf_id) { - continue; - } - if (TMPFS_NODE_GEN(node) != tfh.tf_gen) { - continue; + if (node-tn_id == tfh.tf_id) { + mutex_enter(node-tn_vlock); + break; } - mutex_enter(node-tn_vlock); - break; } mutex_exit(tmp-tm_lock); + if (node == NULL) + return ESTALE; /* Will release the tn_vlock. */ - return node ? tmpfs_vnode_get(mp, node, vpp) : ESTALE; + if ((error = tmpfs_vnode_get(mp, node, vpp)) != 0) + return error; + if (TMPFS_NODE_GEN(node) != tfh.tf_gen) { + vput(*vpp); + *vpp = NULL; + return ESTALE; + } + + return 0; } static int
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Tue May 7 09:40:54 UTC 2013 Modified Files: src/sys/ufs/ffs: ffs_snapshot.c Log Message: When invalidating short buffers on the snapshots clean list use bbusy() to mark the buffer busy. There exists a small window where a buffer is done but not released and therefore still busy. To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/sys/ufs/ffs/ffs_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.121 src/sys/ufs/ffs/ffs_snapshot.c:1.122 --- src/sys/ufs/ffs/ffs_snapshot.c:1.121 Tue Jan 22 09:39:16 2013 +++ src/sys/ufs/ffs/ffs_snapshot.c Tue May 7 09:40:54 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.121 2013/01/22 09:39:16 dholland Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.122 2013/05/07 09:40:54 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.121 2013/01/22 09:39:16 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.122 2013/05/07 09:40:54 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -345,11 +345,17 @@ ffs_snapshot(struct mount *mp, struct vn KASSERT(LIST_FIRST(vp-v_dirtyblkhd) == NULL); for (bp = LIST_FIRST(vp-v_cleanblkhd); bp; bp = nbp) { nbp = LIST_NEXT(bp, b_vnbufs); - KASSERT((bp-b_cflags BC_BUSY) == 0); - if (bp-b_bcount fs-fs_bsize) { - bp-b_cflags |= BC_BUSY; - brelsel(bp, BC_INVAL | BC_VFLUSH); + if (bp-b_bcount == fs-fs_bsize) + continue; + error = bbusy(bp, false, 0, NULL); + if (error != 0) { + if (error == EPASSTHROUGH) { +nbp = LIST_FIRST(vp-v_cleanblkhd); +continue; + } + break; } + brelsel(bp, BC_INVAL | BC_VFLUSH); } mutex_exit(bufcache_lock);
CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: hannken Date: Mon Jun 10 09:25:05 UTC 2013 Modified Files: src/sys/ufs/lfs: lfs_vfsops.c Log Message: Make DEBUG kernel compile: di_u.inumber - di_inumber To generate a diff of this commit: cvs rdiff -u -r1.304 -r1.305 src/sys/ufs/lfs/lfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/lfs/lfs_vfsops.c diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.304 src/sys/ufs/lfs/lfs_vfsops.c:1.305 --- src/sys/ufs/lfs/lfs_vfsops.c:1.304 Sat Jun 8 02:14:46 2013 +++ src/sys/ufs/lfs/lfs_vfsops.c Mon Jun 10 09:25:05 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vfsops.c,v 1.304 2013/06/08 02:14:46 dholland Exp $ */ +/* $NetBSD: lfs_vfsops.c,v 1.305 2013/06/10 09:25:05 hannken Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007 @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: lfs_vfsops.c,v 1.304 2013/06/08 02:14:46 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: lfs_vfsops.c,v 1.305 2013/06/10 09:25:05 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_lfs.h @@ -1471,8 +1471,8 @@ retry: (*bpp)-b_blkno); dp = (struct ulfs1_dinode *)(*bpp)-b_data; for (i = 0; i INOPB(fs); i++) - if (dp[i].di_u.inumber) -printf(%d , dp[i].di_u.inumber); + if (dp[i].di_inumber) +printf(%d , dp[i].di_inumber); printf(\n); } }
CVS commit: src/sys/arch/sparc/stand/bootblk
Module Name:src Committed By: hannken Date: Mon Jun 10 10:26:22 UTC 2013 Modified Files: src/sys/arch/sparc/stand/bootblk: genfth.cf genlfs.cf Log Message: Move member di_inumber from ufs1_dinode to ulfs1_dinode. No functional change intended. Tested on sparc64. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc/stand/bootblk/genfth.cf cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc/stand/bootblk/genlfs.cf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/stand/bootblk/genfth.cf diff -u src/sys/arch/sparc/stand/bootblk/genfth.cf:1.8 src/sys/arch/sparc/stand/bootblk/genfth.cf:1.9 --- src/sys/arch/sparc/stand/bootblk/genfth.cf:1.8 Tue Jan 22 09:39:14 2013 +++ src/sys/arch/sparc/stand/bootblk/genfth.cf Mon Jun 10 10:26:22 2013 @@ -1,4 +1,4 @@ -# $NetBSD: genfth.cf,v 1.8 2013/01/22 09:39:14 dholland Exp $ +# $NetBSD: genfth.cf,v 1.9 2013/06/10 10:26:22 hannken Exp $ # # Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -136,7 +136,6 @@ member di1_size di_size member di1_mode di_mode member di1_db di_db member di1_ib di_ib -member di_inumber di_inumber # # ufs2 dinode Index: src/sys/arch/sparc/stand/bootblk/genlfs.cf diff -u src/sys/arch/sparc/stand/bootblk/genlfs.cf:1.1 src/sys/arch/sparc/stand/bootblk/genlfs.cf:1.2 --- src/sys/arch/sparc/stand/bootblk/genlfs.cf:1.1 Sat Feb 13 23:38:17 2010 +++ src/sys/arch/sparc/stand/bootblk/genlfs.cf Mon Jun 10 10:26:22 2013 @@ -1,4 +1,4 @@ -# $NetBSD: genlfs.cf,v 1.1 2010/02/13 23:38:17 eeh Exp $ +# $NetBSD: genlfs.cf,v 1.2 2013/06/10 10:26:22 hannken Exp $ # Copyright (c) 2010 Eduardo Horvath. # All rights reserved. @@ -70,8 +70,10 @@ member if2_version if_version member if2_daddr if_daddr # -# the dinode is the same as ffs v1 +# LFS v1 dinode # +struct ulfs1_dinode +member di_inumber di_inumber define lfs_magic_value LFS_MAGIC define lfs_unused_daddr LFS_UNUSED_DADDR
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Sun Jun 16 13:33:30 UTC 2013 Modified Files: src/sys/sys: param.h src/sys/ufs/ffs: ffs_extern.h ffs_snapshot.c ffs_vfsops.c src/sys/ufs/ufs: ufs_extern.h ufs_lookup.c ufsmount.h Log Message: Add an UFS_SNAPGONE() ufs op replacing the calls to ffs_snapgone() in ufs_lookup.c. Ok: David Holland dholl...@netbsd.org Welcome to 6.99.22 To generate a diff of this commit: cvs rdiff -u -r1.430 -r1.431 src/sys/sys/param.h cvs rdiff -u -r1.79 -r1.80 src/sys/ufs/ffs/ffs_extern.h cvs rdiff -u -r1.122 -r1.123 src/sys/ufs/ffs/ffs_snapshot.c cvs rdiff -u -r1.283 -r1.284 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.72 -r1.73 src/sys/ufs/ufs/ufs_extern.h cvs rdiff -u -r1.123 -r1.124 src/sys/ufs/ufs/ufs_lookup.c cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/ufs/ufsmount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.430 src/sys/sys/param.h:1.431 --- src/sys/sys/param.h:1.430 Wed May 29 00:47:49 2013 +++ src/sys/sys/param.h Sun Jun 16 13:33:30 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.430 2013/05/29 00:47:49 christos Exp $ */ +/* $NetBSD: param.h,v 1.431 2013/06/16 13:33:30 hannken Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -63,7 +63,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 699002100 /* NetBSD 6.99.21 */ +#define __NetBSD_Version__ 699002200 /* NetBSD 6.99.22 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) = __NetBSD_Version__) Index: src/sys/ufs/ffs/ffs_extern.h diff -u src/sys/ufs/ffs/ffs_extern.h:1.79 src/sys/ufs/ffs/ffs_extern.h:1.80 --- src/sys/ufs/ffs/ffs_extern.h:1.79 Fri Oct 19 17:09:08 2012 +++ src/sys/ufs/ffs/ffs_extern.h Sun Jun 16 13:33:30 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_extern.h,v 1.79 2012/10/19 17:09:08 drochner Exp $ */ +/* $NetBSD: ffs_extern.h,v 1.80 2013/06/16 13:33:30 hannken Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -153,7 +153,7 @@ void ffs_snapremove(struct vnode *); int ffs_snapshot(struct mount *, struct vnode *, struct timespec *); void ffs_snapshot_mount(struct mount *); void ffs_snapshot_unmount(struct mount *); -void ffs_snapgone(struct inode *); +void ffs_snapgone(struct vnode *); int ffs_snapshot_read(struct vnode *, struct uio *, int); /* Write Ahead Physical Block Logging */ Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.122 src/sys/ufs/ffs/ffs_snapshot.c:1.123 --- src/sys/ufs/ffs/ffs_snapshot.c:1.122 Tue May 7 09:40:54 2013 +++ src/sys/ufs/ffs/ffs_snapshot.c Sun Jun 16 13:33:30 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.122 2013/05/07 09:40:54 hannken Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.123 2013/06/16 13:33:30 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.122 2013/05/07 09:40:54 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.123 2013/06/16 13:33:30 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -1372,10 +1372,10 @@ blocks_in_journal(struct fs *fs) * It will not be freed until the last open reference goes away. */ void -ffs_snapgone(struct inode *ip) +ffs_snapgone(struct vnode *vp) { + struct inode *xp, *ip = VTOI(vp); struct mount *mp = ip-i_devvp-v_specmountpoint; - struct inode *xp; struct fs *fs; struct snap_info *si; int snaploc; Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.283 src/sys/ufs/ffs/ffs_vfsops.c:1.284 --- src/sys/ufs/ffs/ffs_vfsops.c:1.283 Sun Jun 9 17:57:08 2013 +++ src/sys/ufs/ffs/ffs_vfsops.c Sun Jun 16 13:33:30 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.283 2013/06/09 17:57:08 dholland Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.284 2013/06/16 13:33:30 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_vfsops.c,v 1.283 2013/06/09 17:57:08 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_vfsops.c,v 1.284 2013/06/16 13:33:30 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -174,6 +174,7 @@ static const struct ufs_ops ffs_ufsops = .uo_vfree = ffs_vfree, .uo_balloc = ffs_balloc, .uo_unmark_vnode = (void (*)(vnode_t *))nullop, + .uo_snapgone = ffs_snapgone, }; static int Index: src/sys/ufs/ufs/ufs_extern.h diff -u src/sys/ufs/ufs/ufs_extern.h:1.72 src/sys/ufs/ufs/ufs_extern.h:1.73 --- src/sys/ufs/ufs/ufs_extern.h:1.72 Wed May 9 00:21:18 2012 +++ src/sys/ufs/ufs/ufs_extern.h Sun Jun 16 13:33:30 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp $ */ +/* $NetBSD: ufs_extern.h,v 1.73 2013/06/16 13:33:30 hannken Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -199,12 +199,6 @@ int ufs_makeinode(int,
CVS commit: src
Module Name:src Committed By: hannken Date: Wed Aug 3 10:03:52 UTC 2011 Modified Files: src/sys/ufs/ufs: ufs_vnops.c src/tests/fs/vfs: t_union.c Log Message: Make whiteouts work on journaling ffs file system by adding the missing UFS_WAPBL_BEGIN() / UFS_WAPBL_END() around CREATE and DELETE ops. Fixes PR #44377 (union whiteouts don't work on ffs -o log) To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/sys/ufs/ufs/ufs_vnops.c cvs rdiff -u -r1.5 -r1.6 src/tests/fs/vfs/t_union.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.201 src/sys/ufs/ufs/ufs_vnops.c:1.202 --- src/sys/ufs/ufs/ufs_vnops.c:1.201 Fri Jul 29 22:18:56 2011 +++ src/sys/ufs/ufs/ufs_vnops.c Wed Aug 3 10:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.201 2011/07/29 22:18:56 riastradh Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.202 2011/08/03 10:03:51 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.201 2011/07/29 22:18:56 riastradh Exp $); +__KERNEL_RCSID(0, $NetBSD: ufs_vnops.c,v 1.202 2011/08/03 10:03:51 hannken Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -912,6 +912,9 @@ case CREATE: /* create a new directory whiteout */ fstrans_start(dvp-v_mount, FSTRANS_SHARED); + error = UFS_WAPBL_BEGIN(dvp-v_mount); + if (error) + break; #ifdef DIAGNOSTIC if (ump-um_maxsymlinklen = 0) panic(ufs_whiteout: old format filesystem); @@ -931,6 +934,9 @@ case DELETE: /* remove an existing directory whiteout */ fstrans_start(dvp-v_mount, FSTRANS_SHARED); + error = UFS_WAPBL_BEGIN(dvp-v_mount); + if (error) + break; #ifdef DIAGNOSTIC if (ump-um_maxsymlinklen = 0) panic(ufs_whiteout: old format filesystem); @@ -943,6 +949,7 @@ panic(ufs_whiteout: unknown op); /* NOTREACHED */ } + UFS_WAPBL_END(dvp-v_mount); fstrans_done(dvp-v_mount); return (error); } Index: src/tests/fs/vfs/t_union.c diff -u src/tests/fs/vfs/t_union.c:1.5 src/tests/fs/vfs/t_union.c:1.6 --- src/tests/fs/vfs/t_union.c:1.5 Thu Jan 13 11:00:19 2011 +++ src/tests/fs/vfs/t_union.c Wed Aug 3 10:03:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_union.c,v 1.5 2011/01/13 11:00:19 pooka Exp $ */ +/* $NetBSD: t_union.c,v 1.6 2011/08/03 10:03:51 hannken Exp $ */ #include sys/types.h #include sys/mount.h @@ -133,11 +133,7 @@ /* check that we can whiteout stuff in the upper layer */ FSTEST_ENTER(); - if (FSTYPE_FFSLOG(tc)) { - atf_tc_expect_signal(SIGABRT, PR kern/44377); - } RL(rump_sys_unlink(TFILE)); - atf_tc_expect_pass(); ATF_REQUIRE_ERRNO(ENOENT, rump_sys_stat(TFILE, sb) == -1); FSTEST_EXIT();
CVS commit: src/sys/rump/librump/rumpvfs
Module Name:src Committed By: hannken Date: Fri Aug 5 08:14:00 UTC 2011 Modified Files: src/sys/rump/librump/rumpvfs: rumpfs.c Log Message: Make whiteouts work on rumpfs: - On lookup it is ok to create if the name exists and is a whiteout - When replacing a whiteout directory entry remove the whiteout first. - Set UF_OPAQUE when creating a node in place of a whiteout. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/rump/librump/rumpvfs/rumpfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.96 src/sys/rump/librump/rumpvfs/rumpfs.c:1.97 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.96 Sun Jun 19 02:42:53 2011 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Fri Aug 5 08:13:59 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfs.c,v 1.96 2011/06/19 02:42:53 rmind Exp $ */ +/* $NetBSD: rumpfs.c,v 1.97 2011/08/05 08:13:59 hannken Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: rumpfs.c,v 1.96 2011/06/19 02:42:53 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: rumpfs.c,v 1.97 2011/08/05 08:13:59 hannken Exp $); #include sys/param.h #include sys/atomic.h @@ -217,6 +217,7 @@ static int lastino = 2; static kmutex_t reclock; +static void freedir(struct rumpfs_node *, struct componentname *); static struct rumpfs_node *makeprivate(enum vtype, dev_t, off_t, bool); /* @@ -611,6 +612,10 @@ strlcpy(rdent-rd_name, cnp-cn_nameptr, cnp-cn_namelen+1); rdent-rd_namelen = strlen(rdent-rd_name); + if ((cnp-cn_flags ISWHITEOUT) != 0) { + KASSERT((cnp-cn_flags DOWHITEOUT) == 0); + freedir(rnd, cnp); + } LIST_INSERT_HEAD(rnd-rn_dir, rdent, rd_entries); } @@ -756,6 +761,8 @@ if (RDENT_ISWHITEOUT(rd)) { cnp-cn_flags |= ISWHITEOUT; + if ((cnp-cn_flags ISLASTCN) cnp-cn_nameiop == CREATE) + return EJUSTRETURN; return ENOENT; } @@ -893,6 +900,8 @@ int rv = 0; rn = makeprivate(VDIR, NODEV, DEV_BSIZE, false); + if ((cnp-cn_flags ISWHITEOUT) != 0) + rn-rn_va.va_flags |= UF_OPAQUE; rn-rn_parent = rnd; rv = makevnode(dvp-v_mount, rn, vpp); if (rv) @@ -984,6 +993,8 @@ int rv; rn = makeprivate(va-va_type, va-va_rdev, DEV_BSIZE, false); + if ((cnp-cn_flags ISWHITEOUT) != 0) + rn-rn_va.va_flags |= UF_OPAQUE; rv = makevnode(dvp-v_mount, rn, vpp); if (rv) goto out; @@ -1014,6 +1025,8 @@ newsize = va-va_type == VSOCK ? DEV_BSIZE : 0; rn = makeprivate(va-va_type, NODEV, newsize, false); + if ((cnp-cn_flags ISWHITEOUT) != 0) + rn-rn_va.va_flags |= UF_OPAQUE; rv = makevnode(dvp-v_mount, rn, vpp); if (rv) goto out; @@ -1046,6 +1059,8 @@ linklen = strlen(target); KASSERT(linklen MAXPATHLEN); rn = makeprivate(VLNK, NODEV, linklen, false); + if ((cnp-cn_flags ISWHITEOUT) != 0) + rn-rn_va.va_flags |= UF_OPAQUE; rv = makevnode(dvp-v_mount, rn, vpp); if (rv) goto out;
CVS commit: src
Module Name:src Committed By: hannken Date: Fri Aug 5 08:17:48 UTC 2011 Modified Files: src/sys/fs/union: union_vnops.c src/tests/fs/vfs: t_union.c Log Message: When union_lookup() creates a shadow directory and nameiop is not LOOKUP it has to restart the lookup to get the componentname right. Fixes PR #44383 (an endless stream of whiteout and opaque dir problems ...) To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/fs/union/union_vnops.c cvs rdiff -u -r1.6 -r1.7 src/tests/fs/vfs/t_union.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_vnops.c diff -u src/sys/fs/union/union_vnops.c:1.40 src/sys/fs/union/union_vnops.c:1.41 --- src/sys/fs/union/union_vnops.c:1.40 Sun Jun 12 03:35:55 2011 +++ src/sys/fs/union/union_vnops.c Fri Aug 5 08:17:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vnops.c,v 1.40 2011/06/12 03:35:55 rmind Exp $ */ +/* $NetBSD: union_vnops.c,v 1.41 2011/08/05 08:17:47 hannken Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995 @@ -72,7 +72,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: union_vnops.c,v 1.40 2011/06/12 03:35:55 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: union_vnops.c,v 1.41 2011/08/05 08:17:47 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -304,6 +304,7 @@ (cnp-cn_nameiop == DELETE || cnp-cn_nameiop == RENAME)) return (EROFS); +start: upperdvp = dun-un_uppervp; lowerdvp = dun-un_lowervp; uppervp = NULLVP; @@ -483,6 +484,9 @@ * We may be racing another process to make the * upper-level shadow directory. Be careful with * locks/etc! + * If we have to create a shadow directory and want + * to commit the node we have to restart the lookup + * to get the componentname right. */ if (upperdvp) { dun-un_flags = ~UN_ULOCK; @@ -491,6 +495,12 @@ uppervp); vn_lock(upperdvp, LK_EXCLUSIVE | LK_RETRY); dun-un_flags |= UN_ULOCK; +if (uerror == 0 cnp-cn_nameiop != LOOKUP) { + vput(uppervp); + if (lowervp != NULLVP) + vput(lowervp); + goto start; +} } if (uerror) { if (lowervp != NULLVP) { Index: src/tests/fs/vfs/t_union.c diff -u src/tests/fs/vfs/t_union.c:1.6 src/tests/fs/vfs/t_union.c:1.7 --- src/tests/fs/vfs/t_union.c:1.6 Wed Aug 3 10:03:51 2011 +++ src/tests/fs/vfs/t_union.c Fri Aug 5 08:17:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_union.c,v 1.6 2011/08/03 10:03:51 hannken Exp $ */ +/* $NetBSD: t_union.c,v 1.7 2011/08/05 08:17:47 hannken Exp $ */ #include sys/types.h #include sys/mount.h @@ -177,7 +177,6 @@ mountunion(mp, lower); /* all file systems fail sooner or later */ - atf_tc_expect_fail(PR kern/44383); FSTEST_ENTER(); RL(rump_sys_rmdir(TDIR)); ATF_REQUIRE_ERRNO(ENOENT, rump_sys_stat(TDFILE, sb) == -1);