From: pluknet <pl...@us...> - 2008-03-27 02:23:46
|
Update of /cvsroot/bsdext2fs/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30872 Modified Files: ext2fs_lookup.c ext2fs_vfsops.c ext2fs_vnops.c Log Message: The next round of syncing w/ FreeBSD: o Pick up GEOM accidently forgotten in prev. commits to leave from devfs. o Init (also forgotten *blush*) cp geom consumer so we do not call instruction on NULL addr (I don't know how that can happen). o There was recent KPI changes in CURRENT. Now it build in both 7+ and 8. o I do not understand why we loop in unmount op if MNT_LAZY is set so I simply dropped that code. o Do not call ufs ops where they don't belong to. Index: ext2fs_vfsops.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_vfsops.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ext2fs_vfsops.c 19 Mar 2008 23:06:36 -0000 1.2 +++ ext2fs_vfsops.c 27 Mar 2008 02:23:49 -0000 1.3 @@ -247,9 +247,9 @@ printf("vfs_busy\n"); if (vfs_busy(mp, LK_NOWAIT, 0, td)) return (EBUSY); - printf("ext2fs_mount ext2fs_flushfiles PRE\n"); + printf("ext2fs_mount -> ext2fs_flushfiles\n"); error = ext2fs_flushfiles(mp, flags, td); - printf("ext2fs_mount ext2fs_flushfiles POST\n"); + printf("ext2fs_mount <- ext2fs_flushfiles\n"); vfs_unbusy(mp, td); if (error == 0 && ext2fs_cgupdate(ump, MNT_WAIT) == 0 && @@ -271,16 +271,28 @@ return (error); devvp = ump->um_devvp; if (fs->e2fs_ronly && !vfs_flagopt(opts, "ro", NULL, 0)) { +#if __FreeBSD_version < 800000 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); +#else + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); +#endif error = VOP_ACCESS(devvp, VREAD | VWRITE, td->td_ucred, td); if (error) error = priv_check(td, PRIV_VFS_MOUNT_PERM); if (error) { +#if __FreeBSD_version < 800000 VOP_UNLOCK(devvp, 0, td); +#else + VOP_UNLOCK(devvp, 0); +#endif return (error); } +#if __FreeBSD_version < 800000 VOP_UNLOCK(devvp, 0, td); +#else + VOP_UNLOCK(devvp, 0); +#endif DROP_GIANT(); g_topology_lock(); error = g_access(ump->um_cp, 0, 1, 0); @@ -411,9 +423,17 @@ * Step 1: invalidate all cached meta-data. */ devvp = VFSTOUFS(mp)->um_devvp; +#if __FreeBSD_version < 800000 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); +#else + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); +#endif error = vinvalbuf(devvp, 0, td, 0, 0); +#if __FreeBSD_version < 800000 VOP_UNLOCK(devvp, 0, td); +#else + VOP_UNLOCK(devvp, 0); +#endif if (error) panic("ext2fs_reload: dirty1"); /* @@ -494,7 +514,11 @@ error = bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), (int)fs->e2fs_bsize, NOCRED, &bp); if (error) { +#if __FreeBSD_version < 800000 VOP_UNLOCK(vp, 0, td); +#else + VOP_UNLOCK(vp, 0); +#endif vput(vp); MNT_VNODE_FOREACH_ABORT(mp, mvp); return (error);; @@ -503,7 +527,11 @@ (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE); e2fs_iload((struct ext2fs_dinode *)cp, ip->i_e2di); brelse(bp); +#if __FreeBSD_version < 800000 VOP_UNLOCK(vp, 0, td); +#else + VOP_UNLOCK(vp, 0); +#endif vput(vp); MNT_ILOCK(mp); } @@ -534,7 +562,11 @@ error = g_vfs_open(devvp, &cp, "ext2fs", ronly ? 0 : 1); g_topology_unlock(); PICKUP_GIANT(); +#if __FreeBSD_version < 800000 VOP_UNLOCK(devvp, 0, td); +#else + VOP_UNLOCK(devvp, 0); +#endif if (error) return (error); @@ -564,10 +596,7 @@ printf("sb size: %d ino size %d\n", sizeof(struct ext2fs), EXT2_DINODE_SIZE); #endif - printf("ext2fs_mountfs bread PRE\n"); - printf("btodb(SBOFF)=%lld SBSIZE=%d\n", btodb(SBOFF), SBSIZE); error = bread(devvp, btodb(SBOFF), SBSIZE, NOCRED, &bp); - printf("ext2fs_mountfs bread POST\n"); if (error) goto out; fs = (struct ext2fs *)bp->b_data; @@ -578,9 +607,7 @@ ump->um_fstype = UFS1; ump->um_e2fs = malloc(sizeof(struct m_ext2fs), M_UFSMNT, M_WAITOK | M_ZERO); e2fs_sbload((struct ext2fs *)bp->b_data, &ump->um_e2fs->e2fs); - printf("ext2fs_mountfs brelse PRE\n"); brelse(bp); - printf("ext2fs_mountfs brelse POST\n"); bp = NULL; m_fs = ump->um_e2fs; m_fs->e2fs_ronly = ronly; @@ -628,10 +655,14 @@ mp->mnt_data = ump; mp->mnt_stat.f_namemax = EXT2FS_MAXNAMLEN; + MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + MNT_IUNLOCK(mp); ump->um_mountp = mp; ump->um_dev = dev; ump->um_devvp = devvp; + ump->um_bo = &devvp->v_bufobj; + ump->um_cp = cp; ump->um_nindir = NINDIR(m_fs); ump->um_bptrtodb = m_fs->e2fs_fsbtodb; ump->um_seqinc = 1; /* no frags */ @@ -642,7 +673,15 @@ out: MPASS(bp != NULL); - brelse(bp); + if (bp) + brelse(bp); + if (cp != NULL) { + DROP_GIANT(); + g_topology_lock(); + g_vfs_close(cp, td); + g_topology_unlock(); + PICKUP_GIANT(); + } if (ump) { free(ump->um_e2fs, M_UFSMNT); free(ump, M_UFSMNT); @@ -666,25 +705,37 @@ flags = 0; if (mntflags & MNT_FORCE) flags |= FORCECLOSE; + printf("ext2fs_unmount -> ext2fs_flushfiles\n"); if ((error = ext2fs_flushfiles(mp, flags, td)) != 0) return (error); + printf("ext2fs_unmount <- ext2fs_flushfiles\n"); ump = VFSTOUFS(mp); fs = ump->um_e2fs; + printf("ext2fs_unmount -> ext2fs_cgupdate\n"); if (fs->e2fs_ronly == 0 && ext2fs_cgupdate(ump, MNT_WAIT) == 0 && (fs->e2fs.e2fs_state & E2FS_ERRORS) == 0) { fs->e2fs.e2fs_state = E2FS_ISCLEAN; (void) ext2fs_sbupdate(ump, MNT_WAIT); } - vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); - error = VOP_CLOSE(ump->um_devvp, fs->e2fs_ronly ? FREAD : FREAD|FWRITE, - NOCRED, td); - vput(ump->um_devvp); + printf("ext2fs_unmount <- ext2fs_cgupdate\n"); + printf("ext2fs_umount ump->um_cp %p\n", ump->um_cp); + DROP_GIANT(); + g_topology_lock(); + g_vfs_close(ump->um_cp, td); + g_topology_unlock(); + PICKUP_GIANT(); + printf("ext2fs_unmount g_vfs_close POST\n"); + vrele(ump->um_devvp); + printf("ext2fs_unmount vrele POST\n"); free(fs->e2fs_gd, M_UFSMNT); free(fs, M_UFSMNT); free(ump, M_UFSMNT); + printf("ext2fs_unmount free POST\n"); mp->mnt_data = NULL; + MNT_ILOCK(mp); mp->mnt_flag &= ~MNT_LOCAL; + MNT_IUNLOCK(mp); printf("ext2fs_unmount exit\n"); return (error); } @@ -698,28 +749,46 @@ struct ufsmount *ump; int error; + printf("ext2fs_flushfiles enter\n"); ump = VFSTOUFS(mp); ASSERT_VOP_LOCKED(ump->um_devvp, "ffs_flushfiles"); + printf("ext2fs_flushfiles afterassert\n"); if (ump->um_devvp->v_vflag & VV_COPYONWRITE) { + printf("ext2fs_flushfiles -> vflush\n"); if ((error = vflush(mp, 0, SKIPSYSTEM | flags, td)) != 0) - return (error); - flags |= FORCECLOSE; + return (error); + printf("ext2fs_flushfiles <- vflush\n"); + flags |= FORCECLOSE; /* - * Here we fall through to vflush again to ensure + * Here we fall through to vflush again to ensure * that we have gotten rid of all the system vnodes. */ - } + } /* * Flush all the files. */ + printf("ext2fs_flushfiles -> vflush again\n"); if ((error = vflush(mp, 0, flags, td)) != 0) - return (error); + return (error); + printf("ext2fs_flushfiles <- vflush again\n"); /* * Flush filesystem metadata. */ +#if __FreeBSD_version < 800000 vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); +#else + vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY); +#endif + printf("ext2fs_flushfiles vn_lock POST\n"); error = VOP_FSYNC(ump->um_devvp, MNT_WAIT, td); + printf("ext2fs_flushfiles VOP_FSYNC POST\n"); +#if __FreeBSD_version < 800000 VOP_UNLOCK(ump->um_devvp, 0, td); +#else + VOP_UNLOCK(ump->um_devvp, 0); +#endif + printf("ext2fs_flushfiles VOP_UNLOCK POST\n"); + printf("ext2fs_flushfiles exit\n"); return (error); } @@ -789,6 +858,7 @@ struct m_ext2fs *fs; int error, allerror = 0; + printf("ext2fs_sync enter\n"); fs = ump->um_e2fs; if (fs->e2fs_fmod != 0 && fs->e2fs_ronly != 0) { /* XXX */ printf("fs = %s\n", fs->e2fs_fsmnt); @@ -798,20 +868,20 @@ loop: MNT_VNODE_FOREACH(vp, mp, mvp) { VI_LOCK(vp); - if (vp->v_iflag & VI_DOOMED) { + if (vp->v_type == VNON || (vp->v_iflag & VI_DOOMED)) { VI_UNLOCK(vp); continue; } + MNT_IUNLOCK(mp); ip = VTOI(vp); - if (ip == NULL || vp->v_type == VNON || - ((ip->i_flag & - (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) == 0 && - vp->v_bufobj.bo_dirty.bv_cnt == 0)) - { + if ((ip->i_flag & + (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFIED)) == 0 && + (vp->v_bufobj.bo_dirty.bv_cnt == 0 || + waitfor == MNT_LAZY)) { VI_UNLOCK(vp); + MNT_ILOCK(mp); continue; } - MNT_IUNLOCK(mp); error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, td); if (error) { MNT_ILOCK(mp); @@ -834,19 +904,33 @@ /* * Force stale file system control information to be flushed. */ + printf("ext2fs_sync afterloop\n"); devvp = ump->um_devvp; + printf("ext2fs_sync VI_LOCK PRE\n"); VI_LOCK(devvp); + printf("ext2fs_sync VI_LOCK POST\n"); if (waitfor != MNT_LAZY) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + printf("ext2fs_sync vn_lock PRE\n"); +#if __FreeBSD_version < 800000 + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, td); +#else + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK); +#endif + printf("ext2fs_sync vn_lock POST\n"); if ((error = VOP_FSYNC(devvp, waitfor, td)) != 0) allerror = error; + printf("ext2fs_sync VOP_UNLOCK PRE\n"); +#if __FreeBSD_version < 800000 VOP_UNLOCK(devvp, 0, td); - if(allerror == 0 && waitfor == MNT_WAIT) { - MNT_ILOCK(mp); - goto loop; - } - } else +#else + VOP_UNLOCK(devvp, 0); +#endif + printf("ext2fs_sync VOP_UNLOCK POST\n"); + } else { + printf("ext2fs_sync VI_UNLOCK PRE\n"); VI_UNLOCK(devvp); + printf("ext2fs_sync VI_UNLOCK POST\n"); + } /* * Write back modified superblock. */ @@ -856,6 +940,7 @@ if ((error = ext2fs_cgupdate(ump, waitfor))) allerror = error; } + printf("ext2fs_sync exit\n"); return (allerror); } @@ -910,7 +995,11 @@ */ td = curthread; +#if __FreeBSD_version < 800000 lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL, td); +#else + lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); +#endif error = insmntque(vp, mp); if (error) { uma_zfree(ext2fs_inode_pool, ip); Index: ext2fs_vnops.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_vnops.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ext2fs_vnops.c 19 Mar 2008 23:06:36 -0000 1.2 +++ ext2fs_vnops.c 27 Mar 2008 02:23:49 -0000 1.3 @@ -651,18 +651,30 @@ error = 0; goto abortit; } +#if __FreeBSD_version < 800000 if ((error = vn_lock(fvp, LK_EXCLUSIVE, td)) != 0) +#else + if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0) +#endif goto abortit; dp = VTOI(fdvp); ip = VTOI(fvp); if ((nlink_t) ip->i_e2di->e2di_nlink >= LINK_MAX) { +#if __FreeBSD_version < 800000 VOP_UNLOCK(fvp, 0, td); +#else + VOP_UNLOCK(fvp, 0); +#endif error = EMLINK; goto abortit; } if ((ip->i_e2di->e2di_flags & (EXT2_IMMUTABLE | EXT2_APPEND)) || (dp->i_e2di->e2di_flags & EXT2_APPEND)) { +#if __FreeBSD_version < 800000 VOP_UNLOCK(fvp, 0, td); +#else + VOP_UNLOCK(fvp, 0); +#endif error = EPERM; goto abortit; } @@ -671,7 +683,11 @@ if (!error && tvp) error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred, td); if (error) { +#if __FreeBSD_version < 800000 VOP_UNLOCK(fvp, 0, td); +#else + VOP_UNLOCK(fvp, 0); +#endif error = EACCES; goto abortit; } @@ -683,7 +699,11 @@ (fcnp->cn_flags & ISDOTDOT) || (tcnp->cn_flags & ISDOTDOT) || (ip->i_flag & IN_RENAME)) { +#if __FreeBSD_version < 800000 VOP_UNLOCK(fvp, 0, td); +#else + VOP_UNLOCK(fvp, 0); +#endif error = EINVAL; goto abortit; } @@ -710,7 +730,11 @@ ip->i_e2di->e2di_nlink++; ip->i_flag |= IN_CHANGE; if ((error = ext2fs_update(fvp, NULL, NULL, UPDATE_WAIT)) != 0) { +#if __FreeBSD_version < 800000 VOP_UNLOCK(fvp, 0, td); +#else + VOP_UNLOCK(fvp, 0); +#endif goto bad; } @@ -725,7 +749,11 @@ * call to checkpath(). */ error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, td); +#if __FreeBSD_version < 800000 VOP_UNLOCK(fvp, 0, td); +#else + VOP_UNLOCK(fvp, 0); +#endif if (oldparent != dp->i_number) newparent = dp->i_number; if (doingdirectory && newparent) { @@ -740,7 +768,11 @@ goto out; } tcnp->cn_flags &= ~SAVESTART; +#if __FreeBSD_version < 800000 vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY, td); +#else + vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY); +#endif if ((error = relookup(tdvp, &tvp, tcnp)) != 0) { vput(tdvp); goto out; @@ -868,7 +900,11 @@ */ fcnp->cn_flags &= ~(MODMASK | SAVESTART); fcnp->cn_flags |= LOCKPARENT | LOCKLEAF; +#if __FreeBSD_version < 800000 vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY, td); +#else + vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY); +#endif if ((error = relookup(fdvp, &fvp, fcnp))) { vput(fdvp); vrele(ap->a_fvp); @@ -955,7 +991,11 @@ out: if (doingdirectory) ip->i_flag &= ~IN_RENAME; +#if __FreeBSD_version < 800000 if (vn_lock(fvp, LK_EXCLUSIVE, td) == 0) { +#else + if (vn_lock(fvp, LK_EXCLUSIVE) == 0) { +#endif ip->i_e2di->e2di_nlink--; ip->i_flag |= IN_CHANGE; vput(fvp); @@ -1365,10 +1405,7 @@ { struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); - int error; - if ((error = ufs_reclaim(ap)) != 0) - return (error); if (ip->i_un.e2fs != NULL) uma_zfree(ext2fs_inode_ext_pool, ip->i_un.e2fs); if (ip->i_e2di != NULL) Index: ext2fs_lookup.c =================================================================== RCS file: /cvsroot/bsdext2fs/src/ext2fs_lookup.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ext2fs_lookup.c 19 Mar 2008 23:06:36 -0000 1.2 +++ ext2fs_lookup.c 27 Mar 2008 02:23:49 -0000 1.3 @@ -585,10 +585,18 @@ return (0); } if (flags & ISDOTDOT) +#if __FreeBSD_version < 800000 VOP_UNLOCK(vdp, 0, td); /* race to get the inode */ +#else + VOP_UNLOCK(vdp, 0); +#endif error = VFS_VGET(vdp->v_mount, foundino, LK_EXCLUSIVE, &tdp); if (flags & ISDOTDOT) +#if __FreeBSD_version < 800000 vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, td); +#else + vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); +#endif if (error) return (error); /* @@ -625,10 +633,18 @@ if (dp->i_number == foundino) return (EISDIR); if (flags & ISDOTDOT) +#if __FreeBSD_version < 800000 VOP_UNLOCK(vdp, 0, td); /* race to get the inode */ +#else + VOP_UNLOCK(vdp, 0); +#endif error = VFS_VGET(vdp->v_mount, foundino, LK_EXCLUSIVE, &tdp); if (flags & ISDOTDOT) +#if __FreeBSD_version < 800000 vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY, td); +#else + vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); +#endif if (error) return (error); *vpp = tdp; @@ -657,9 +673,17 @@ */ pdp = vdp; if (flags & ISDOTDOT) { +#if __FreeBSD_version < 800000 VOP_UNLOCK(pdp, 0, td); /* race to get the inode */ +#else + VOP_UNLOCK(pdp, 0); +#endif error = VFS_VGET(vdp->v_mount, foundino, cnp->cn_lkflags, &tdp); +#if __FreeBSD_version < 800000 vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); +#else + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY); +#endif if (error) { return (error); } |