Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys VOP_OPEN() needs a locked vnode. All these copy-and-pas...
details: https://anonhg.NetBSD.org/src/rev/46d782f36037
branches: trunk
changeset: 771217:46d782f36037
user: hannken <hannken%NetBSD.org@localhost>
date: Mon Nov 14 18:35:12 2011 +0000
description:
VOP_OPEN() needs a locked vnode. All these copy-and-pasted xxxfs_mount()
implementations need more review.
diffstat:
sys/fs/adosfs/advfsops.c | 10 +++++++---
sys/fs/cd9660/cd9660_vfsops.c | 6 ++++--
sys/fs/filecorefs/filecore_vfsops.c | 6 ++++--
sys/fs/hfs/hfs_subr.c | 10 ++++++----
sys/fs/msdosfs/msdosfs_vfsops.c | 6 ++++--
sys/fs/nilfs/nilfs_vfsops.c | 6 ++++--
sys/fs/ntfs/ntfs_vfsops.c | 6 ++++--
sys/fs/udf/udf_vfsops.c | 6 ++++--
sys/ufs/ext2fs/ext2fs_vfsops.c | 6 ++++--
sys/ufs/ffs/ffs_vfsops.c | 6 ++++--
sys/ufs/lfs/lfs_vfsops.c | 6 ++++--
11 files changed, 49 insertions(+), 25 deletions(-)
diffs (truncated from 316 to 300 lines):
diff -r 89e8a12ac172 -r 46d782f36037 sys/fs/adosfs/advfsops.c
--- a/sys/fs/adosfs/advfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/fs/adosfs/advfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -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 @@
/*
* 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;
diff -r 89e8a12ac172 -r 46d782f36037 sys/fs/cd9660/cd9660_vfsops.c
--- a/sys/fs/cd9660/cd9660_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/fs/cd9660/cd9660_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -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 @@
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);
diff -r 89e8a12ac172 -r 46d782f36037 sys/fs/filecorefs/filecore_vfsops.c
--- a/sys/fs/filecorefs/filecore_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/fs/filecorefs/filecore_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -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 @@
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;
diff -r 89e8a12ac172 -r 46d782f36037 sys/fs/hfs/hfs_subr.c
--- a/sys/fs/hfs/hfs_subr.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/fs/hfs/hfs_subr.c Mon Nov 14 18:35:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hfs_subr.c,v 1.16 2011/11/13 23:03:55 christos Exp $ */
+/* $NetBSD: hfs_subr.c,v 1.17 2011/11/14 18:35:13 hannken Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_subr.c,v 1.16 2011/11/13 23:03:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_subr.c,v 1.17 2011/11/14 18:35:13 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -178,8 +178,10 @@
/* Open the device node. */
mode = vol->readonly ? FREAD : FREAD|FWRITE;
- if ((result = VOP_OPEN(args->devvp, mode,
- FSCRED)) != 0)
+ vn_lock(args->devvp, LK_EXCLUSIVE | LK_RETRY);
+ result = VOP_OPEN(args->devvp, mode, FSCRED);
+ VOP_UNLOCK(args->devvp);
+ if (result != 0)
goto error;
/* Flush out any old buffers remaining from a previous use. */
diff -r 89e8a12ac172 -r 46d782f36037 sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vfsops.c,v 1.92 2011/10/07 09:35:04 hannken Exp $ */
+/* $NetBSD: msdosfs_vfsops.c,v 1.93 2011/11/14 18:35:13 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.92 2011/10/07 09:35:04 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.93 2011/11/14 18:35:13 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -418,7 +418,9 @@
xflags = FREAD;
else
xflags = FREAD|FWRITE;
+ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(devvp, xflags, FSCRED);
+ VOP_UNLOCK(devvp);
if (error) {
DPRINTF(("VOP_OPEN %d\n", error));
goto fail;
diff -r 89e8a12ac172 -r 46d782f36037 sys/fs/nilfs/nilfs_vfsops.c
--- a/sys/fs/nilfs/nilfs_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/fs/nilfs/nilfs_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.7 2011/11/13 18:29:08 christos Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.8 2011/11/14 18:35:13 hannken Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_vfsops.c,v 1.7 2011/11/13 18:29:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_vfsops.c,v 1.8 2011/11/14 18:35:13 hannken Exp $");
#endif /* not lint */
@@ -618,7 +618,9 @@
* Open device read-write; TODO how about upgrading later when needed?
*/
openflags = FREAD | FWRITE;
+ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(devvp, openflags, FSCRED);
+ VOP_UNLOCK(devvp);
if (error) {
vrele(devvp);
return error;
diff -r 89e8a12ac172 -r 46d782f36037 sys/fs/ntfs/ntfs_vfsops.c
--- a/sys/fs/ntfs/ntfs_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/fs/ntfs/ntfs_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_vfsops.c,v 1.86 2011/06/12 03:35:53 rmind Exp $ */
+/* $NetBSD: ntfs_vfsops.c,v 1.87 2011/11/14 18:35:13 hannken Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.86 2011/06/12 03:35:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.87 2011/11/14 18:35:13 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -270,7 +270,9 @@
flags = FREAD;
else
flags = FREAD|FWRITE;
+ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
err = VOP_OPEN(devvp, flags, FSCRED);
+ VOP_UNLOCK(devvp);
if (err)
goto fail;
err = ntfs_mountfs(devvp, mp, args, l);
diff -r 89e8a12ac172 -r 46d782f36037 sys/fs/udf/udf_vfsops.c
--- a/sys/fs/udf/udf_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/fs/udf/udf_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vfsops.c,v 1.61 2011/09/27 01:13:16 christos Exp $ */
+/* $NetBSD: udf_vfsops.c,v 1.62 2011/11/14 18:35:14 hannken Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.61 2011/09/27 01:13:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.62 2011/11/14 18:35:14 hannken Exp $");
#endif /* not lint */
@@ -395,7 +395,9 @@
} else {
openflags = FREAD | FWRITE;
}
+ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(devvp, openflags, FSCRED);
+ VOP_UNLOCK(devvp);
if (error == 0) {
/* opened ok, try mounting */
error = udf_mountfs(devvp, mp, l, args);
diff -r 89e8a12ac172 -r 46d782f36037 sys/ufs/ext2fs/ext2fs_vfsops.c
--- a/sys/ufs/ext2fs/ext2fs_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/ufs/ext2fs/ext2fs_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_vfsops.c,v 1.161 2011/10/07 09:35:06 hannken Exp $ */
+/* $NetBSD: ext2fs_vfsops.c,v 1.162 2011/11/14 18:35:14 hannken Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.161 2011/10/07 09:35:06 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.162 2011/11/14 18:35:14 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -406,7 +406,9 @@
xflags = FREAD;
else
xflags = FREAD|FWRITE;
+ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(devvp, xflags, FSCRED);
+ VOP_UNLOCK(devvp);
if (error)
goto fail;
error = ext2fs_mountfs(devvp, mp);
diff -r 89e8a12ac172 -r 46d782f36037 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_vfsops.c,v 1.270 2011/11/13 23:10:34 christos Exp $ */
+/* $NetBSD: ffs_vfsops.c,v 1.271 2011/11/14 18:35:14 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.270 2011/11/13 23:10:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.271 2011/11/14 18:35:14 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -429,7 +429,9 @@
xflags = FREAD;
else
xflags = FREAD | FWRITE;
+ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(devvp, xflags, FSCRED);
+ VOP_UNLOCK(devvp);
if (error)
goto fail;
error = ffs_mountfs(devvp, mp, l);
diff -r 89e8a12ac172 -r 46d782f36037 sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c Mon Nov 14 18:24:45 2011 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c Mon Nov 14 18:35:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vfsops.c,v 1.290 2011/07/11 08:27:40 hannken Exp $ */
+/* $NetBSD: lfs_vfsops.c,v 1.291 2011/11/14 18:35:14 hannken Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
*/
Home |
Main Index |
Thread Index |
Old Index