Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/ufs/ufs/ufs_lookup.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/ufs/ufs/ufs_lookup.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.98.4.2 retrieving revision 1.104.2.1 diff -u -p -r1.98.4.2 -r1.104.2.1 --- src/sys/ufs/ufs/ufs_lookup.c 2008/12/13 01:15:41 1.98.4.2 +++ src/sys/ufs/ufs/ufs_lookup.c 2010/07/03 01:20:05 1.104.2.1 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.98.4.2 2008/12/13 01:15:41 haad Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.104.2.1 2010/07/03 01:20:05 rmind Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,11 +37,10 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.98.4.2 2008/12/13 01:15:41 haad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.104.2.1 2010/07/03 01:20:05 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" -#include "fs_ffs.h" #endif #include @@ -422,7 +421,7 @@ notfound: (nameiop == DELETE && (ap->a_cnp->cn_flags & DOWHITEOUT) && (ap->a_cnp->cn_flags & ISWHITEOUT))) && - (flags & ISLASTCN) && dp->i_ffs_effnlink != 0) { + (flags & ISLASTCN) && dp->i_nlink != 0) { /* * Access for write is interpreted as allowing * creation of files in the directory. @@ -531,13 +530,13 @@ found: else dp->i_count = dp->i_offset - prevoff; if (dp->i_number == foundino) { - VREF(vdp); + vref(vdp); *vpp = vdp; error = 0; goto out; } if (flags & ISDOTDOT) - VOP_UNLOCK(vdp, 0); /* race to get the inode */ + VOP_UNLOCK(vdp); /* race to get the inode */ error = VFS_VGET(vdp->v_mount, foundino, &tdp); if (flags & ISDOTDOT) vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); @@ -582,7 +581,7 @@ found: goto out; } if (flags & ISDOTDOT) - VOP_UNLOCK(vdp, 0); /* race to get the inode */ + VOP_UNLOCK(vdp); /* race to get the inode */ error = VFS_VGET(vdp->v_mount, foundino, &tdp); if (flags & ISDOTDOT) vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); @@ -615,7 +614,7 @@ found: */ pdp = vdp; if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp, 0); /* race to get the inode */ + VOP_UNLOCK(pdp); /* race to get the inode */ error = VFS_VGET(vdp->v_mount, foundino, &tdp); vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY); if (error) { @@ -623,7 +622,7 @@ found: } *vpp = tdp; } else if (dp->i_number == foundino) { - VREF(vdp); /* we want ourself, ie "." */ + vref(vdp); /* we want ourself, ie "." */ *vpp = vdp; } else { error = VFS_VGET(vdp->v_mount, foundino, &tdp); @@ -758,7 +757,7 @@ ufs_direnter(struct vnode *dvp, struct v struct buf *bp; u_int dsize; struct direct *ep, *nep; - int error, ret, blkoff, loc, spacefree, flags; + int error, ret, blkoff, loc, spacefree; char *dirbuf; struct timespec ts; struct ufsmount *ump = VFSTOUFS(dvp->v_mount); @@ -783,13 +782,8 @@ ufs_direnter(struct vnode *dvp, struct v */ if (dp->i_offset & (dirblksiz - 1)) panic("ufs_direnter: newblk"); - flags = B_CLRBUF; - if (!DOINGSOFTDEP(dvp)) - flags |= B_SYNC; if ((error = UFS_BALLOC(dvp, (off_t)dp->i_offset, dirblksiz, - cr, flags, &bp)) != 0) { - if (DOINGSOFTDEP(dvp) && newdirbp != NULL) - bdwrite(newdirbp); + cr, B_CLRBUF | B_SYNC, &bp)) != 0) { return (error); } dp->i_size = dp->i_offset + dirblksiz; @@ -819,47 +813,7 @@ ufs_direnter(struct vnode *dvp, struct v dp->i_offset); } #endif - if (DOINGSOFTDEP(dvp)) { - /* - * Ensure that the entire newly allocated block is a - * valid directory so that future growth within the - * block does not have to ensure that the block is - * written before the inode. - */ - blkoff += dirblksiz; - while (blkoff < bp->b_bcount) { - ((struct direct *) - ((char *)bp->b_data + blkoff))->d_reclen = dirblksiz; - blkoff += dirblksiz; - } - if (softdep_setup_directory_add(bp, dp, dp->i_offset, - ufs_rw32(dirp->d_ino, needswap), newdirbp, 1) == 0) { - bdwrite(bp); - vfs_timestamp(&ts); - return UFS_UPDATE(dvp, &ts, &ts, UPDATE_DIROP); - } - /* We have just allocated a directory block in an - * indirect block. Rather than tracking when it gets - * claimed by the inode, we simply do a VOP_FSYNC - * now to ensure that it is there (in case the user - * does a future fsync). Note that we have to unlock - * the inode for the entry that we just entered, as - * the VOP_FSYNC may need to lock other inodes which - * can lead to deadlock if we also hold a lock on - * the newly entered node. - */ - error = VOP_BWRITE(bp); - if (error != 0) - return (error); - if (tvp != NULL) - VOP_UNLOCK(tvp, 0); - error = VOP_FSYNC(dvp, l->l_cred, FSYNC_WAIT, 0, 0); - if (tvp != 0) - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); - return (error); - } else { - error = VOP_BWRITE(bp); - } + error = VOP_BWRITE(bp); vfs_timestamp(&ts); ret = UFS_UPDATE(dvp, &ts, &ts, UPDATE_DIROP); if (error == 0) @@ -894,8 +848,6 @@ ufs_direnter(struct vnode *dvp, struct v */ error = ufs_blkatoff(dvp, (off_t)dp->i_offset, &dirbuf, &bp, true); if (error) { - if (DOINGSOFTDEP(dvp) && newdirbp != NULL) - bdwrite(newdirbp); return (error); } /* @@ -940,11 +892,7 @@ ufs_direnter(struct vnode *dvp, struct v dp->i_offset + ((char *)nep - dirbuf), dp->i_offset + ((char *)ep - dirbuf)); #endif - if (DOINGSOFTDEP(dvp)) - softdep_change_directoryentry_offset(dp, dirbuf, - (void *)nep, (void *)ep, dsize); - else - memcpy((void *)ep, (void *)nep, dsize); + memcpy((void *)ep, (void *)nep, dsize); } /* * Here, `ep' points to a directory entry containing `dsize' in-use @@ -993,14 +941,7 @@ ufs_direnter(struct vnode *dvp, struct v (dp->i_offset & (dirblksiz - 1)), dp->i_offset & ~(dirblksiz - 1)); #endif - if (DOINGSOFTDEP(dvp)) { - softdep_setup_directory_add(bp, dp, - dp->i_offset + (char *)ep - dirbuf, - ufs_rw32(dirp->d_ino, needswap), newdirbp, 0); - bdwrite(bp); - } else { - error = VOP_BWRITE(bp); - } + error = VOP_BWRITE(bp); dp->i_flag |= IN_CHANGE | IN_UPDATE; /* * If all went well, and the directory can be shortened, proceed @@ -1010,15 +951,11 @@ ufs_direnter(struct vnode *dvp, struct v * lock on the newly entered node. */ if (error == 0 && dp->i_endoff && dp->i_endoff < dp->i_size) { - if (DOINGSOFTDEP(dvp) && (tvp != NULL)) - VOP_UNLOCK(tvp, 0); #ifdef UFS_DIRHASH if (dp->i_dirhash != NULL) ufsdirhash_dirtrunc(dp, dp->i_endoff); #endif (void) UFS_TRUNCATE(dvp, (off_t)dp->i_endoff, IO_SYNC, cr); - if (DOINGSOFTDEP(dvp) && (tvp != NULL)) - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); } UFS_WAPBL_UPDATE(dvp, NULL, NULL, UPDATE_DIROP); return (error); @@ -1101,35 +1038,23 @@ ufs_dirremove(struct vnode *dvp, struct #endif out: - if (DOINGSOFTDEP(dvp)) { - if (ip) { - ip->i_ffs_effnlink--; - softdep_change_linkcnt(ip); - softdep_setup_remove(bp, dp, ip, isrmdir); - } - bdwrite(bp); - } else { - if (ip) { - ip->i_ffs_effnlink--; - ip->i_nlink--; - DIP_ASSIGN(ip, nlink, ip->i_nlink); - ip->i_flag |= IN_CHANGE; - UFS_WAPBL_UPDATE(ITOV(ip), NULL, NULL, 0); - } - error = VOP_BWRITE(bp); + if (ip) { + ip->i_nlink--; + DIP_ASSIGN(ip, nlink, ip->i_nlink); + ip->i_flag |= IN_CHANGE; + UFS_WAPBL_UPDATE(ITOV(ip), NULL, NULL, 0); } + error = VOP_BWRITE(bp); dp->i_flag |= IN_CHANGE | IN_UPDATE; -#ifdef FFS /* * If the last named reference to a snapshot goes away, * drop its snapshot reference so that it will be reclaimed * when last open reference goes away. */ if (ip != 0 && (ip->i_flags & SF_SNAPSHOT) != 0 && - ip->i_ffs_effnlink == 0) + ip->i_nlink == 0) ffs_snapgone(ip); UFS_WAPBL_UPDATE(dvp, NULL, NULL, 0); -#endif return (error); } @@ -1153,29 +1078,20 @@ ufs_dirrewrite(struct inode *dp, struct ep->d_ino = ufs_rw32(newinum, UFS_MPNEEDSWAP(dp->i_ump)); if (!FSFMT(vdp)) ep->d_type = newtype; - oip->i_ffs_effnlink--; - if (DOINGSOFTDEP(vdp)) { - softdep_change_linkcnt(oip); - softdep_setup_directory_change(bp, dp, oip, newinum, isrmdir); - bdwrite(bp); - } else { - oip->i_nlink--; - DIP_ASSIGN(oip, nlink, oip->i_nlink); - oip->i_flag |= IN_CHANGE; - UFS_WAPBL_UPDATE(ITOV(oip), NULL, NULL, UPDATE_DIROP); - error = VOP_BWRITE(bp); - } + oip->i_nlink--; + DIP_ASSIGN(oip, nlink, oip->i_nlink); + oip->i_flag |= IN_CHANGE; + UFS_WAPBL_UPDATE(ITOV(oip), NULL, NULL, UPDATE_DIROP); + error = VOP_BWRITE(bp); dp->i_flag |= iflags; -#ifdef FFS /* * If the last named reference to a snapshot goes away, * drop its snapshot reference so that it will be reclaimed * when last open reference goes away. */ - if ((oip->i_flags & SF_SNAPSHOT) != 0 && oip->i_ffs_effnlink == 0) + if ((oip->i_flags & SF_SNAPSHOT) != 0 && oip->i_nlink == 0) ffs_snapgone(oip); UFS_WAPBL_UPDATE(vdp, NULL, NULL, UPDATE_DIROP); -#endif return (error); } @@ -1255,7 +1171,7 @@ ufs_dirempty(struct inode *ip, ino_t par int ufs_checkpath(struct inode *source, struct inode *target, kauth_cred_t cred) { - struct vnode *vp = ITOV(target); + struct vnode *nextvp, *vp; int error, rootino, namlen; struct dirtemplate dirbuf; const int needswap = UFS_MPNEEDSWAP(target->i_ump); @@ -1303,13 +1219,15 @@ ufs_checkpath(struct inode *source, stru } if (ufs_rw32(dirbuf.dotdot_ino, needswap) == rootino) break; - vput(vp); + VOP_UNLOCK(vp); error = VFS_VGET(vp->v_mount, - ufs_rw32(dirbuf.dotdot_ino, needswap), &vp); + ufs_rw32(dirbuf.dotdot_ino, needswap), &nextvp); + vrele(vp); if (error) { vp = NULL; break; } + vp = nextvp; } out: