Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Extend the range of fstrans transactions to a sequence o...
details: https://anonhg.NetBSD.org/src/rev/0c30e8873459
branches: trunk
changeset: 760122:0c30e8873459
user: hannken <hannken%NetBSD.org@localhost>
date: Mon Dec 27 18:49:42 2010 +0000
description:
Extend the range of fstrans transactions to a sequence of vnode operations
on a locked vnode. This leaves a suspended file system and therefore a
snapshot with either all or no operations of such a sequence done.
diffstat:
sys/fs/msdosfs/msdosfs_vfsops.c | 23 +++++------------------
sys/miscfs/genfs/genfs_vnops.c | 19 ++++++++++++++-----
sys/ufs/ffs/ffs_vfsops.c | 21 +++++----------------
3 files changed, 24 insertions(+), 39 deletions(-)
diffs (182 lines):
diff -r 09f35594fff5 -r 0c30e8873459 sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c Mon Dec 27 18:41:07 2010 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c Mon Dec 27 18:49:42 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vfsops.c,v 1.88 2010/12/14 17:17:02 hannken Exp $ */
+/* $NetBSD: msdosfs_vfsops.c,v 1.89 2010/12/27 18:49:42 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.88 2010/12/14 17:17:02 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.89 2010/12/27 18:49:42 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -938,8 +938,7 @@
struct vnode *vp, *mvp;
struct denode *dep;
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
- int lk_flags, error, allerror = 0;
- bool is_suspending;
+ int error, allerror = 0;
/*
* If we ever switch to not updating all of the fats all the time,
@@ -956,15 +955,6 @@
if ((mvp = vnalloc(mp)) == NULL)
return ENOMEM;
fstrans_start(mp, FSTRANS_SHARED);
- is_suspending = (fstrans_getstate(mp) == FSTRANS_SUSPENDING);
- /*
- * We can't lock vnodes while the file system is suspending because
- * threads waiting on fstrans may have locked vnodes.
- */
- if (is_suspending)
- lk_flags = 0;
- else
- lk_flags = LK_EXCLUSIVE | LK_NOWAIT;
/*
* Write back each (modified) denode.
*/
@@ -985,7 +975,7 @@
continue;
}
mutex_exit(&mntvnode_lock);
- error = vget(vp, lk_flags);
+ error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT);
if (error) {
mutex_enter(&mntvnode_lock);
if (error == ENOENT) {
@@ -997,10 +987,7 @@
if ((error = VOP_FSYNC(vp, cred,
waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0)
allerror = error;
- if (is_suspending)
- vrele(vp);
- else
- vput(vp);
+ vput(vp);
mutex_enter(&mntvnode_lock);
}
mutex_exit(&mntvnode_lock);
diff -r 09f35594fff5 -r 0c30e8873459 sys/miscfs/genfs/genfs_vnops.c
--- a/sys/miscfs/genfs/genfs_vnops.c Mon Dec 27 18:41:07 2010 +0000
+++ b/sys/miscfs/genfs/genfs_vnops.c Mon Dec 27 18:49:42 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_vnops.c,v 1.185 2010/11/30 10:43:05 dholland Exp $ */
+/* $NetBSD: genfs_vnops.c,v 1.186 2010/12/27 18:49:42 hannken Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,13 +57,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.185 2010/11/30 10:43:05 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.186 2010/12/27 18:49:42 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/kernel.h>
#include <sys/mount.h>
+#include <sys/fstrans.h>
#include <sys/namei.h>
#include <sys/vnode.h>
#include <sys/fcntl.h>
@@ -293,10 +294,17 @@
KASSERT((flags & ~(LK_EXCLUSIVE | LK_SHARED | LK_NOWAIT)) == 0);
op = ((flags & LK_EXCLUSIVE) != 0 ? RW_WRITER : RW_READER);
+ if ((flags & LK_NOWAIT) != 0) {
+ if (fstrans_start_nowait(vp->v_mount, FSTRANS_SHARED))
+ return EBUSY;
+ if (! rw_tryenter(&vp->v_lock, op)) {
+ fstrans_done(vp->v_mount);
+ return EBUSY;
+ }
+ return 0;
+ }
- if ((flags & LK_NOWAIT) != 0)
- return (rw_tryenter(&vp->v_lock, op) ? 0 : EBUSY);
-
+ fstrans_start(vp->v_mount, FSTRANS_SHARED);
rw_enter(&vp->v_lock, op);
return 0;
@@ -314,6 +322,7 @@
struct vnode *vp = ap->a_vp;
rw_exit(&vp->v_lock);
+ fstrans_done(vp->v_mount);
return 0;
}
diff -r 09f35594fff5 -r 0c30e8873459 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c Mon Dec 27 18:41:07 2010 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c Mon Dec 27 18:49:42 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_vfsops.c,v 1.262 2010/08/09 17:12:18 pooka Exp $ */
+/* $NetBSD: ffs_vfsops.c,v 1.263 2010/12/27 18:49:42 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.262 2010/08/09 17:12:18 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.263 2010/12/27 18:49:42 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -1547,7 +1547,7 @@
struct inode *ip;
struct ufsmount *ump = VFSTOUFS(mp);
struct fs *fs;
- int lk_flags, error, allerror = 0;
+ int error, allerror = 0;
bool is_suspending;
fs = ump->um_fs;
@@ -1563,14 +1563,6 @@
fstrans_start(mp, FSTRANS_SHARED);
is_suspending = (fstrans_getstate(mp) == FSTRANS_SUSPENDING);
/*
- * We can't lock vnodes while the file system is suspending because
- * threads waiting on fstrans may have locked vnodes.
- */
- if (is_suspending)
- lk_flags = 0;
- else
- lk_flags = LK_EXCLUSIVE | LK_NOWAIT;
- /*
* Write back each (modified) inode.
*/
mutex_enter(&mntvnode_lock);
@@ -1632,7 +1624,7 @@
}
vmark(mvp, vp);
mutex_exit(&mntvnode_lock);
- error = vget(vp, lk_flags);
+ error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT);
if (error) {
mutex_enter(&mntvnode_lock);
nvp = vunmark(mvp);
@@ -1654,10 +1646,7 @@
}
if (error)
allerror = error;
- if (is_suspending)
- vrele(vp);
- else
- vput(vp);
+ vput(vp);
mutex_enter(&mntvnode_lock);
nvp = vunmark(mvp);
}
Home |
Main Index |
Thread Index |
Old Index