From 83f7350f6d706c3f2886e41b05f1cb725b68e756 Mon Sep 17 00:00:00 2001 From: ad Date: Sun, 21 Dec 2008 10:44:32 +0000 Subject: [PATCH] PR kern/40210 5.0 BETA WAPBL related crash --- sys/ufs/ffs/ffs_vnops.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index df2e39ac4227..5640329022aa 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vnops.c,v 1.104 2008/10/10 09:21:58 hannken Exp $ */ +/* $NetBSD: ffs_vnops.c,v 1.105 2008/12/21 10:44:32 ad Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.104 2008/10/10 09:21:58 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.105 2008/12/21 10:44:32 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -402,12 +402,25 @@ out: int ffs_full_fsync(struct vnode *vp, int flags) { + extern struct vfsops ffs_vfsops; struct buf *bp, *nbp; int error, passes, skipmeta, inodedeps_only, waitfor; struct mount *mp; + bool ffsino; error = 0; + if ((flags & FSYNC_VFS) != 0) { + KASSERT(vp->v_specmountpoint != NULL); + mp = vp->v_specmountpoint; + ffsino = (mp->mnt_op == &ffs_vfsops); + KASSERT(vp->v_type == VBLK); + } else { + mp = vp->v_mount; + ffsino = true; + KASSERT(vp->v_tag == VT_UFS); + } + if (vp->v_type == VBLK && vp->v_specmountpoint != NULL && (vp->v_specmountpoint->mnt_flag & MNT_SOFTDEP)) @@ -425,11 +438,6 @@ ffs_full_fsync(struct vnode *vp, int flags) if (vp->v_type == VREG || vp->v_type == VBLK) { int pflags = PGO_ALLPAGES | PGO_CLEANIT; - if ((flags & FSYNC_VFS) != 0 && vp->v_specmountpoint != NULL) - mp = vp->v_specmountpoint; - else - mp = vp->v_mount; - if ((flags & FSYNC_WAIT)) pflags |= PGO_SYNCIO; if (vp->v_type == VREG && @@ -439,7 +447,6 @@ ffs_full_fsync(struct vnode *vp, int flags) if (error) return error; } else { - mp = vp->v_mount; mutex_exit(&vp->v_interlock); } @@ -449,7 +456,7 @@ ffs_full_fsync(struct vnode *vp, int flags) if (flags & FSYNC_DATAONLY) return error; - if (VTOI(vp) && (VTOI(vp)->i_flag & + if (ffsino && VTOI(vp) && (VTOI(vp)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY | IN_MODIFIED | IN_ACCESSED))) { error = UFS_WAPBL_BEGIN(mp); @@ -569,12 +576,8 @@ loop: else waitfor = (flags & FSYNC_WAIT) ? UPDATE_WAIT : 0; - if (vp->v_tag == VT_UFS) + if (ffsino) error = ffs_update(vp, NULL, NULL, waitfor); - else { - KASSERT(vp->v_type == VBLK); - KASSERT((flags & FSYNC_VFS) != 0); - } if (error == 0 && flags & FSYNC_CACHE) { int i = 0;