Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Check for v_type before v_rdev because it is cheape...
details: https://anonhg.NetBSD.org/src/rev/b8e0c942e6fd
branches: trunk
changeset: 769139:b8e0c942e6fd
user: christos <christos%NetBSD.org@localhost>
date: Thu Sep 01 09:04:08 2011 +0000
description:
Check for v_type before v_rdev because it is cheaper and safer.
diffstat:
sys/kern/vfs_mount.c | 9 +++++----
sys/kern/vfs_subr.c | 8 ++++----
sys/kern/vfs_vnode.c | 6 +++---
3 files changed, 12 insertions(+), 11 deletions(-)
diffs (114 lines):
diff -r 89170b0a90d6 -r b8e0c942e6fd sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c Thu Sep 01 09:03:43 2011 +0000
+++ b/sys/kern/vfs_mount.c Thu Sep 01 09:04:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_mount.c,v 1.6 2011/06/12 03:35:56 rmind Exp $ */
+/* $NetBSD: vfs_mount.c,v 1.7 2011/09/01 09:04:08 christos 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.6 2011/06/12 03:35:56 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.7 2011/09/01 09:04:08 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -1268,7 +1268,7 @@
mutex_enter(&device_lock);
for (vq = specfs_hash[SPECHASH(vp->v_rdev)]; vq != NULL;
vq = vq->v_specnext) {
- if (vq->v_rdev != vp->v_rdev || vq->v_type != vp->v_type)
+ if (vq->v_type != vp->type || vq->v_rdev != vp->v_rdev)
continue;
if (vq->v_specmountpoint != NULL) {
error = EBUSY;
@@ -1295,7 +1295,6 @@
int d_type;
bvp = NULL;
- dev = vp->v_rdev;
d_type = D_OTHER;
if (iskmemvp(vp))
@@ -1305,6 +1304,7 @@
case VCHR: {
const struct cdevsw *cdev;
+ dev = vp->v_rdev;
cdev = cdevsw_lookup(dev);
if (cdev != NULL) {
dev_t blkdev;
@@ -1325,6 +1325,7 @@
case VBLK: {
const struct bdevsw *bdev;
+ dev = vp->v_rdev;
bdev = bdevsw_lookup(dev);
if (bdev != NULL)
d_type = (bdev->d_flag & D_TYPEMASK);
diff -r 89170b0a90d6 -r b8e0c942e6fd sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Thu Sep 01 09:03:43 2011 +0000
+++ b/sys/kern/vfs_subr.c Thu Sep 01 09:04:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.424 2011/07/11 08:27:37 hannken Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.425 2011/09/01 09:04:08 christos 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.424 2011/07/11 08:27:37 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.425 2011/09/01 09:04:08 christos Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -508,7 +508,7 @@
mutex_enter(&device_lock);
for (vp = specfs_hash[SPECHASH(dev)]; vp; vp = vp->v_specnext) {
- if (dev == vp->v_rdev && type == vp->v_type)
+ if (type == vp->v_type && dev == vp->v_rdev)
break;
}
if (vp == NULL) {
@@ -543,7 +543,7 @@
for (vp = *vpp; vp != NULL;) {
mutex_enter(vp->v_interlock);
if ((vp->v_iflag & VI_CLEAN) != 0 ||
- dev != vp->v_rdev || type != vp->v_type) {
+ type != vp->v_type || dev != vp->v_rdev) {
mutex_exit(vp->v_interlock);
vp = vp->v_specnext;
continue;
diff -r 89170b0a90d6 -r b8e0c942e6fd sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Thu Sep 01 09:03:43 2011 +0000
+++ b/sys/kern/vfs_vnode.c Thu Sep 01 09:04:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.9 2011/06/12 03:35:57 rmind Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.10 2011/09/01 09:04:08 christos Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -121,7 +121,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.9 2011/06/12 03:35:57 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.10 2011/09/01 09:04:08 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -1131,7 +1131,7 @@
/* If clean or being cleaned, then ignore it. */
mutex_enter(vq->v_interlock);
if ((vq->v_iflag & (VI_CLEAN | VI_XLOCK)) != 0 ||
- vq->v_rdev != dev || vq->v_type != type) {
+ vq->v_type != type || vq->v_rdev != dev) {
mutex_exit(vq->v_interlock);
vq = vq->v_specnext;
continue;
Home |
Main Index |
Thread Index |
Old Index