[BACK]Return to ufs_wapbl.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / ufs / ufs

Annotation of src/sys/ufs/ufs/ufs_wapbl.c, Revision 1.24

1.24    ! hannken     1: /*  $NetBSD: ufs_wapbl.c,v 1.23 2012/01/27 19:22:50 para Exp $ */
1.2       simonb      2:
                      3: /*-
                      4:  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by Wasabi Systems, Inc.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     20:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     21:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     22:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     23:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     24:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     25:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     26:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     27:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     28:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     29:  * POSSIBILITY OF SUCH DAMAGE.
                     30:  */
                     31:
                     32: /*
                     33:  * Copyright (c) 1982, 1986, 1989, 1993, 1995
                     34:  *     The Regents of the University of California.  All rights reserved.
                     35:  * (c) UNIX System Laboratories, Inc.
                     36:  * All or some portions of this file are derived from material licensed
                     37:  * to the University of California by American Telephone and Telegraph
                     38:  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
                     39:  * the permission of UNIX System Laboratories, Inc.
                     40:  *
                     41:  * Redistribution and use in source and binary forms, with or without
                     42:  * modification, are permitted provided that the following conditions
                     43:  * are met:
                     44:  * 1. Redistributions of source code must retain the above copyright
                     45:  *    notice, this list of conditions and the following disclaimer.
                     46:  * 2. Redistributions in binary form must reproduce the above copyright
                     47:  *    notice, this list of conditions and the following disclaimer in the
                     48:  *    documentation and/or other materials provided with the distribution.
                     49:  * 3. Neither the name of the University nor the names of its contributors
                     50:  *    may be used to endorse or promote products derived from this software
                     51:  *    without specific prior written permission.
                     52:  *
                     53:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     54:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     55:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     56:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     57:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     58:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     59:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     60:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     61:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     62:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     63:  * SUCH DAMAGE.
                     64:  *
                     65:  *     @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95
                     66:  */
                     67:
                     68: #include <sys/cdefs.h>
1.24    ! hannken    69: __KERNEL_RCSID(0, "$NetBSD: ufs_wapbl.c,v 1.23 2012/01/27 19:22:50 para Exp $");
1.2       simonb     70:
                     71: #include <sys/param.h>
                     72: #include <sys/systm.h>
                     73: #include <sys/namei.h>
                     74: #include <sys/resourcevar.h>
                     75: #include <sys/kernel.h>
                     76: #include <sys/file.h>
                     77: #include <sys/stat.h>
                     78: #include <sys/buf.h>
                     79: #include <sys/proc.h>
                     80: #include <sys/mount.h>
                     81: #include <sys/vnode.h>
                     82: #include <sys/dirent.h>
                     83: #include <sys/lockf.h>
                     84: #include <sys/kauth.h>
                     85: #include <sys/wapbl.h>
                     86:
                     87: #include <miscfs/specfs/specdev.h>
                     88: #include <miscfs/fifofs/fifo.h>
                     89:
                     90: #include <ufs/ufs/quota.h>
                     91: #include <ufs/ufs/inode.h>
                     92: #include <ufs/ufs/dir.h>
                     93: #include <ufs/ufs/ufsmount.h>
                     94: #include <ufs/ufs/ufs_bswap.h>
                     95: #include <ufs/ufs/ufs_extern.h>
                     96: #include <ufs/ufs/ufs_wapbl.h>
                     97: #include <ufs/ext2fs/ext2fs_extern.h>
                     98: #include <ufs/lfs/lfs_extern.h>
                     99:
                    100: #include <uvm/uvm.h>
                    101:
                    102: #ifdef WAPBL_DEBUG_INODES
1.3       pooka     103: #error WAPBL_DEBUG_INODES: not functional before ufs_wapbl.c is updated
1.2       simonb    104: void
                    105: ufs_wapbl_verify_inodes(struct mount *mp, const char *str)
                    106: {
                    107:        struct vnode *vp, *nvp;
                    108:        struct inode *ip;
1.13      rmind     109:        struct buf *bp, *nbp;
1.2       simonb    110:
1.13      rmind     111:        mutex_enter(&mntvnode_lock);
1.2       simonb    112:  loop:
                    113:        TAILQ_FOREACH_REVERSE(vp, &mp->mnt_vnodelist, vnodelst, v_mntvnodes) {
                    114:                /*
                    115:                 * If the vnode that we are about to sync is no longer
                    116:                 * associated with this mount point, start over.
                    117:                 */
                    118:                if (vp->v_mount != mp)
                    119:                        goto loop;
1.13      rmind     120:                mutex_enter(&vp->v_interlock);
1.2       simonb    121:                nvp = TAILQ_NEXT(vp, v_mntvnodes);
                    122:                ip = VTOI(vp);
                    123:                if (vp->v_type == VNON) {
1.13      rmind     124:                        mutex_exit(&vp->v_interlock);
1.2       simonb    125:                        continue;
                    126:                }
                    127:                /* verify that update has been called on all inodes */
                    128:                if (ip->i_flag & (IN_CHANGE | IN_UPDATE)) {
                    129:                        panic("wapbl_verify: mp %p: dirty vnode %p (inode %p): 0x%x\n",
                    130:                                mp, vp, ip, ip->i_flag);
                    131:                }
1.13      rmind     132:                mutex_exit(&mntvnode_lock);
1.2       simonb    133:
1.13      rmind     134:                mutex_enter(&bufcache_lock);
                    135:                for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
                    136:                        nbp = LIST_NEXT(bp, b_vnbufs);
                    137:                        if ((bp->b_cflags & BC_BUSY)) {
                    138:                                continue;
1.2       simonb    139:                        }
1.13      rmind     140:                        KASSERT((bp->b_oflags & BO_DELWRI) != 0);
                    141:                        KASSERT((bp->b_flags & B_LOCKED) != 0);
1.2       simonb    142:                }
1.13      rmind     143:                mutex_exit(&bufcache_lock);
                    144:                mutex_exit(&vp->v_interlock);
                    145:
                    146:                mutex_enter(&mntvnode_lock);
1.2       simonb    147:        }
1.13      rmind     148:        mutex_exit(&mntvnode_lock);
1.2       simonb    149:
                    150:        vp = VFSTOUFS(mp)->um_devvp;
1.13      rmind     151:        mutex_enter(&vp->v_interlock);
                    152:        mutex_enter(&bufcache_lock);
                    153:        for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
                    154:                nbp = LIST_NEXT(bp, b_vnbufs);
                    155:                if ((bp->b_cflags & BC_BUSY)) {
                    156:                        continue;
1.2       simonb    157:                }
1.13      rmind     158:                KASSERT((bp->b_oflags & BO_DELWRI) != 0);
                    159:                KASSERT((bp->b_flags & B_LOCKED) != 0);
1.2       simonb    160:        }
1.13      rmind     161:        mutex_exit(&bufcache_lock);
                    162:        mutex_exit(&vp->v_interlock);
1.2       simonb    163: }
                    164: #endif /* WAPBL_DEBUG_INODES */

CVSweb <webmaster@jp.NetBSD.org>