kernel - Performance tuning (3)
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 14 Nov 2013 19:54:09 +0000 (11:54 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 14 Nov 2013 19:54:09 +0000 (11:54 -0800)
* The VOP_CLOSE issues revealed a bigger issue with vn_lock().  Many
  callers do not check the return code for vn_lock() and in nearly all
  of those cases it wouldn't fail anyway due to a prior ref, but it
  creates an API issue.

* Add the LK_FAILRECLAIM flag to vn_lock().  This flag explicitly allows
  vn_lock() to fail if the vnode is undergoing reclamation.

  This fixes numerous issues, particularly when VOP_CLOSE() is called
  during a reclaim due to recent LK_UPGRADE's that we do in some VFS
  *_close() functions.

* Remove some unused LK_ defines.

28 files changed:
sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c
sys/gnu/vfs/ext2fs/ext2_lookup.c
sys/gnu/vfs/ext2fs/ext2_vnops.c
sys/gnu/vfs/ext2fs/fs.h
sys/kern/tty.c
sys/kern/tty_tty.c
sys/kern/vfs_lock.c
sys/kern/vfs_syscalls.c
sys/kern/vfs_vnops.c
sys/sys/lock.h
sys/vfs/devfs/devfs_vnops.c
sys/vfs/hpfs/hpfs.h
sys/vfs/hpfs/hpfs_vnops.c
sys/vfs/isofs/cd9660/cd9660_lookup.c
sys/vfs/isofs/cd9660/cd9660_vnops.c
sys/vfs/msdosfs/msdosfs_lookup.c
sys/vfs/msdosfs/msdosfs_vnops.c
sys/vfs/nfs/nfs_vnops.c
sys/vfs/ntfs/ntfs.h
sys/vfs/ntfs/ntfs_vnops.c
sys/vfs/nwfs/nwfs_vnops.c
sys/vfs/procfs/procfs_vnops.c
sys/vfs/smbfs/smbfs_vnops.c
sys/vfs/udf/udf_vnops.c
sys/vfs/ufs/ufs_lookup.c
sys/vfs/ufs/ufs_vnops.c
sys/vfs/union/union_subr.c
sys/vm/vm_pageout.c

index 86327eb..fc4fe94 100644 (file)
@@ -976,7 +976,8 @@ linprocfs_readdir(struct vop_readdir_args *ap)
                return (EINVAL);
 
        pfs = VTOPFS(ap->a_vp);
-       if ((error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        switch (pfs->pfs_type) {
index 1dd68e1..dd0c323 100644 (file)
@@ -145,7 +145,8 @@ ext2_readdir(struct vop_readdir_args *ap)
        int readcnt, retval;
        off_t startoffset = uio->uio_offset;
 
-       if ((error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return(error);
 
        count = uio->uio_resid;
@@ -643,13 +644,17 @@ found:
        pdp = vdp;
        if (flags & CNP_ISDOTDOT) {
                vn_unlock(pdp); /* race to get the inode */
-               if ((error = VFS_VGET(vdp->v_mount, NULL, dp->i_ino, &tdp)) != 0) {
+               error = VFS_VGET(vdp->v_mount, NULL, dp->i_ino, &tdp);
+               if (error) {
                        vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY);
                        return (error);
                }
-               if (lockparent && (error = vn_lock(pdp, LK_EXCLUSIVE))) {
-                       vput(tdp);
-                       return (error);
+               if (lockparent) {
+                       error = vn_lock(pdp, LK_EXCLUSIVE | LK_FAILRECLAIM);
+                       if (error) {
+                               vput(tdp);
+                               return (error);
+                       }
                }
                *vpp = tdp;
        } else if (dp->i_number == dp->i_ino) {
index 19e6973..848b46d 100644 (file)
@@ -356,8 +356,10 @@ ext2_link(struct vop_old_link_args *ap)
                error = EXDEV;
                goto out2;
        }
-       if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE))) {
-               goto out2;
+       if (tdvp != vp) {
+               error = vn_lock(vp, LK_EXCLUSIVE | LK_FAILRECLAIM);
+               if (error)
+                       goto out2;
        }
        ip = VTOI(vp);
        if ((nlink_t)ip->i_nlink >= LINK_MAX) {
@@ -441,7 +443,8 @@ abortit:
                goto abortit;
        }
 
-       if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0)
+       error = vn_lock(fvp, LK_EXCLUSIVE | LK_FAILRECLAIM);
+       if (error)
                goto abortit;
 
        /*
@@ -819,7 +822,9 @@ bad:
 out:
        if (doingdirectory)
                ip->i_flag &= ~IN_RENAME;
-       if (vn_lock(fvp, LK_EXCLUSIVE) == 0) {
+
+       error = vn_lock(fvp, LK_EXCLUSIVE);
+       if (error == 0) {
                ip->i_nlink--;
                ip->i_flag |= IN_CHANGE;
                ip->i_flag &= ~IN_RENAME;
index 52f2fec..c699156 100644 (file)
@@ -166,7 +166,8 @@ extern u_char *fragtbl[];
  * I think I'll try a vn_lock/vn_unlock on the device vnode
  */
 #define  DEVVP(inode)          (VFSTOEXT2(ITOV(inode)->v_mount)->um_devvp)
-#define  lock_super(devvp)     vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY)
+#define  lock_super(devvp)     \
+               vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM)
 #define  unlock_super(devvp)   vn_unlock(devvp)
 
 /*
index 786bd2a..7aaf1a8 100644 (file)
@@ -340,7 +340,7 @@ retry:
         */
        if ((vp->v_flag & VCTTYISOPEN) || dorevoke) {
                vhold(vp);
-               if (vn_lock(vp, LK_EXCLUSIVE|LK_RETRY)) {
+               if (vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM)) {
                        vdrop(vp);
                        goto retry;
                }
index c23cb29..016f2f5 100644 (file)
@@ -154,7 +154,8 @@ retry:
                 * Avoid a nasty race if we block while getting the lock.
                 */
                vref(ttyvp);
-               error = vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY);
+               error = vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY |
+                                      LK_FAILRECLAIM);
                if (error) {
                        vrele(ttyvp);
                        goto retry;
index 2de5690..95f1e05 100644 (file)
@@ -471,7 +471,7 @@ vget(struct vnode *vp, int flags)
        if ((atomic_fetchadd_int(&vp->v_refcnt, 1) & VREF_MASK) == 0)
                atomic_add_int(&cachedvnodes, -1);
 
-       if ((error = vn_lock(vp, flags)) != 0) {
+       if ((error = vn_lock(vp, flags | LK_FAILRECLAIM)) != 0) {
                /*
                 * The lock failed, undo and return an error.  This will not
                 * normally trigger a termination.
index b7ee2d1..d9db9f6 100644 (file)
@@ -2304,7 +2304,8 @@ kern_link(struct nlookupdata *nd, struct nlookupdata *linknd)
                vrele(vp);
                return (EEXIST);
        }
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) != 0) {
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error) {
                vrele(vp);
                return (error);
        }
@@ -3539,7 +3540,8 @@ kern_truncate(struct nlookupdata *nd, off_t length)
                return (error);
        if ((error = cache_vref(&nd->nl_nch, nd->nl_cred, &vp)) != 0)
                return (error);
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) != 0) {
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error) {
                vrele(vp);
                return (error);
        }
index 33d42f2..40b0bc5 100644 (file)
@@ -416,7 +416,7 @@ vn_close(struct vnode *vp, int flags)
 {
        int error;
 
-       error = vn_lock(vp, LK_SHARED | LK_RETRY);
+       error = vn_lock(vp, LK_SHARED | LK_RETRY | LK_FAILRECLAIM);
        if (error == 0) {
                error = VOP_CLOSE(vp, flags);
                vn_unlock(vp);
@@ -978,8 +978,17 @@ vn_ioctl(struct file *fp, u_long com, caddr_t data, struct ucred *ucred,
 }
 
 /*
- * Check that the vnode is still valid, and if so
- * acquire requested lock.
+ * Obtain the requested vnode lock
+ *
+ *     LK_RETRY        Automatically retry on timeout
+ *     LK_FAILRECLAIM  Fail if the vnode is being reclaimed
+ *
+ * Failures will occur if the vnode is undergoing recyclement, but not
+ * all callers expect that the function will fail so the caller must pass
+ * LK_FAILOK if it wants to process an error code.
+ *
+ * Errors can occur for other reasons if you pass in other LK_ flags,
+ * regardless of whether you pass in LK_FAILRECLAIM
  */
 int
 #ifndef        DEBUG_LOCKS
@@ -1009,8 +1018,10 @@ debug_vn_lock(struct vnode *vp, int flags, const char *filename, int line)
         * refs go away.  So we can just check the flag.
         */
        if (error == 0 && (vp->v_flag & VRECLAIMED)) {
-               lockmgr(&vp->v_lock, LK_RELEASE);
-               error = ENOENT;
+               if (flags & LK_FAILRECLAIM) {
+                       lockmgr(&vp->v_lock, LK_RELEASE);
+                       error = ENOENT;
+               }
        }
        return (error);
 }
index 4a1b132..f4cdc9b 100644 (file)
@@ -148,10 +148,10 @@ struct lock {
  *
  * Non-persistent external flags.
  */
-#define LK_UNUSED10000 0x00010000
+#define LK_FAILRECLAIM 0x00010000 /* vn_lock: allowed to fail on reclaim */
 #define LK_RETRY       0x00020000 /* vn_lock: retry until locked */
-#define        LK_NOOBJ        0x00040000 /* vget: don't create object */
-#define        LK_THISLAYER    0x00080000 /* vn_lock: lock/unlock only current layer */
+#define        LK_UNUSED40000  0x00040000
+#define        LK_UNUSED80000  0x00080000
 
 /*
  * Lock return status.
index 975f0e4..f3a9f92 100644 (file)
@@ -326,7 +326,8 @@ devfs_vop_readdir(struct vop_readdir_args *ap)
 
        if (ap->a_uio->uio_offset < 0 || ap->a_uio->uio_offset > INT_MAX)
                return (EINVAL);
-       if ((error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        if (!devfs_node_is_accessible(dnode)) {
@@ -1090,7 +1091,9 @@ devfs_spec_close(struct vop_close_args *ap)
                /* node is now stale */
 
                if (needrelock) {
-                       if (vn_lock(vp, LK_EXCLUSIVE | LK_RETRY) != 0) {
+                       if (vn_lock(vp, LK_EXCLUSIVE |
+                                       LK_RETRY |
+                                       LK_FAILRECLAIM) != 0) {
                                panic("devfs_spec_close: vnode %p "
                                      "unexpectedly could not be relocked",
                                      vp);
index 492534e..f0c8d88 100644 (file)
@@ -384,7 +384,7 @@ MALLOC_DECLARE(M_HPFSNO);
 #define        FID(f)          (*((lsn_t *)(f)->fid_data))
 #define dbtodoff(dbn)  ((off_t)(dbn) << DEV_BSHIFT)
 
-#define VOP__LOCK(a, b)                vn_lock((a), (b))
+#define VOP__LOCK(a, b)                vn_lock((a), (b) | LK_FAILRECLAIM)
 #define VOP__UNLOCK(a, b)      vn_unlock((a))
 #define VGET(a, b, c)          vget((a), (b))
 #define VN_LOCK(a, b)          vn_lock((a), (b))
index 0b6d825..06db0bc 100644 (file)
@@ -788,7 +788,8 @@ hpfs_readdir(struct vop_readdir_args *ap)
         */
        if (uio->uio_offset < 0 || uio->uio_offset > INT_MAX)
                return(EINVAL);
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        num = uio->uio_offset;
index 5d2e553..53431cc 100644 (file)
@@ -354,7 +354,8 @@ found:
                        return (error);
                }
                if (lockparent) {
-                       if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0) {
+                       error = vn_lock(pdp, LK_EXCLUSIVE | LK_FAILRECLAIM);
+                       if (error) {
                                cnp->cn_flags |= CNP_PDIRUNLOCK;
                                vput(tdp);
                                return (error);
index 22edcde..03f2499 100644 (file)
@@ -428,7 +428,8 @@ cd9660_readdir(struct vop_readdir_args *ap)
        imp = dp->i_mnt;
        bmask = imp->im_bmask;
 
-       if ((error = vn_lock(vdp, LK_EXCLUSIVE|LK_RETRY)) != 0)
+       error = vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        idp = kmalloc(sizeof(*idp), M_TEMP, M_WAITOK);
index 5f21004..9b2e4dc 100644 (file)
@@ -517,7 +517,7 @@ foundroot:
                        return (error);
                }
                if (lockparent) {
-                       error = vn_lock(pdp, LK_EXCLUSIVE);
+                       error = vn_lock(pdp, LK_EXCLUSIVE | LK_FAILRECLAIM);
                        if (error) {
                                vput(DETOV(tdp));
                                return (error);
index 183dcc2..31bdd95 100644 (file)
@@ -970,7 +970,7 @@ abortit:
         * fvp, fdvp are unlocked, tvp, tdvp are locked.  Lock fvp and note
         * that we have to unlock it to use the abortit target.
         */
-       error = vn_lock(fvp, LK_EXCLUSIVE);
+       error = vn_lock(fvp, LK_EXCLUSIVE | LK_FAILRECLAIM);
        if (error)
                goto abortit;
        dp = VTODE(fdvp);
@@ -1516,7 +1516,8 @@ msdosfs_readdir(struct vop_readdir_args *ap)
        char *d_name_storage = NULL;
        char *d_name = NULL;
 
-       if ((error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        dep = VTODE(ap->a_vp);
index c4cf40a..688d28e 100644 (file)
@@ -1169,7 +1169,7 @@ nfs_lookup(struct vop_old_lookup_args *ap)
                }
                newvp = NFSTOV(np);
                if (lockparent) {
-                       error = vn_lock(dvp, LK_EXCLUSIVE);
+                       error = vn_lock(dvp, LK_EXCLUSIVE | LK_FAILRECLAIM);
                        if (error) {
                                vput(newvp);
                                lwkt_reltoken(&nmp->nm_token);
@@ -2336,7 +2336,8 @@ nfs_readdir(struct vop_readdir_args *ap)
        if (vp->v_type != VDIR)
                return (EPERM);
 
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        lwkt_gettoken(&nmp->nm_token);
index 27ce558..90e0082 100644 (file)
@@ -306,6 +306,7 @@ MALLOC_DECLARE(M_NTFSNTHASH);
 #define VOP__UNLOCK(a, b)      vn_unlock((a))
 #define VGET(a, b)             vget((a), (b))
 #define VN_LOCK(a, b)          vn_lock((a), (b))
+#define VOP_LOCK(a, b)         vn_lock((a), (b) | LK_FAILRECLAIM)
 #define        LOCKMGR(a, b)           lockmgr((a), (b))
 
 #ifdef _KERNEL
index 0fcf31c..db99915 100644 (file)
@@ -555,7 +555,8 @@ ntfs_readdir(struct vop_readdir_args *ap)
 
        if (uio->uio_offset < 0 || uio->uio_offset > INT_MAX)
                return (EINVAL);
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        /*
@@ -726,13 +727,13 @@ ntfs_lookup(struct vop_old_lookup_args *ap)
                                 vap->va_a_name->n_pnumber,ap->a_vpp); 
                ntfs_ntvattrrele(vap);
                if (error) {
-                       if (VN_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY) == 0)
+                       if (VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY) == 0)
                                cnp->cn_flags &= ~CNP_PDIRUNLOCK;
                        return (error);
                }
 
                if (lockparent) {
-                       error = VN_LOCK(dvp, LK_EXCLUSIVE);
+                       error = VOP_LOCK(dvp, LK_EXCLUSIVE);
                        if (error) {
                                vput(*ap->a_vpp);
                                *ap->a_vpp = NULL;
index 1fab287..87a06df 100644 (file)
@@ -659,7 +659,8 @@ nwfs_readdir(struct vop_readdir_args *ap)
                kprintf("nwfs_readdir: no support for cookies now...");
                return (EOPNOTSUPP);
        }
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
        error = nwfs_readvnode(vp, uio, ap->a_cred);
        vn_unlock(vp);
@@ -921,9 +922,12 @@ kprintf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & CNP_IS
                        vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
                        return (error);
                }
-               if (lockparent && (error = vn_lock(dvp, LK_EXCLUSIVE))) {
-                       vput(vp);
-                       return (error);
+               if (lockparent) {
+                       error = vn_lock(dvp, LK_EXCLUSIVE | LK_FAILRECLAIM);
+                       if (error) {
+                               vput(vp);
+                               return (error);
+                       }
                }
                *vpp = vp;
        } else if (NWCMPF(&dnp->n_fid, &fid)) {
index 598512c..c98c7c4 100644 (file)
@@ -889,7 +889,8 @@ procfs_readdir(struct vop_readdir_args *ap)
 
        if (ap->a_uio->uio_offset < 0 || ap->a_uio->uio_offset > INT_MAX)
                return (EINVAL);
-       if ((error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
        pfs = VTOPFS(ap->a_vp);
 
index f5cd0a6..56dd40b 100644 (file)
@@ -219,7 +219,8 @@ smbfs_closel(struct vop_close_args *ap)
        struct vattr vattr;
        int error;
 
-       SMBVDEBUG("name=%s, pid=%d, c=%d\n",np->n_name, p->p_pid, np->n_opencount);
+       SMBVDEBUG("name=%s, pid=%d, c=%d\n",
+                 np->n_name, p->p_pid, np->n_opencount);
        vn_lock(vp, LK_UPGRADE | LK_RETRY);
 
        smb_makescred(&scred, curthread, proc0.p_ucred);
@@ -713,7 +714,8 @@ smbfs_readdir(struct vop_readdir_args *ap)
                return (EOPNOTSUPP);
        }
 #endif
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) == 0) {
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error) {
                error = smbfs_readvnode(vp, uio, ap->a_cred);
                vn_unlock(vp);
        }
@@ -1132,7 +1134,7 @@ smbfs_lookup(struct vop_old_lookup_args *ap)
                        return error;
                }
                if (lockparent) {
-                       error = vn_lock(dvp, LK_EXCLUSIVE);
+                       error = vn_lock(dvp, LK_EXCLUSIVE | LK_FAILRECLAIM);
                        if (error) {
                                cnp->cn_flags |= CNP_PDIRUNLOCK;
                                vput(vp);
index c996502..9bc6193 100644 (file)
@@ -638,7 +638,8 @@ udf_readdir(struct vop_readdir_args *a)
 
        vp = a->a_vp;
 
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        uio = a->a_uio;
index 589405a..e4bfa36 100644 (file)
@@ -480,8 +480,10 @@ found:
                        vn_unlock(vdp); /* race to get the inode */
                error = VFS_VGET(vdp->v_mount, NULL, dp->i_ino, &tdp);
                if (flags & CNP_ISDOTDOT) {
-                       if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY) != 0)
+                       if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY |
+                                        LK_FAILRECLAIM) != 0) {
                                cnp->cn_flags |= CNP_PDIRUNLOCK;
+                       }
                }
                if (error)
                        return (error);
@@ -525,8 +527,10 @@ found:
                        vn_unlock(vdp); /* race to get the inode */
                error = VFS_VGET(vdp->v_mount, NULL, dp->i_ino, &tdp);
                if (flags & CNP_ISDOTDOT) {
-                       if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY) != 0)
+                       if (vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY |
+                                        LK_FAILRECLAIM) != 0) {
                                cnp->cn_flags |= CNP_PDIRUNLOCK;
+                       }
                }
                if (error)
                        return (error);
@@ -563,12 +567,15 @@ found:
                cnp->cn_flags |= CNP_PDIRUNLOCK;
                error = VFS_VGET(vdp->v_mount, NULL, dp->i_ino, &tdp);
                if (error) {
-                       if (vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY) == 0)
+                       if (vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY |
+                                        LK_FAILRECLAIM) == 0) {
                                cnp->cn_flags &= ~CNP_PDIRUNLOCK;
+                       }
                        return (error);
                }
                if (lockparent) {
-                       if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0) {
+                       error = vn_lock(pdp, LK_EXCLUSIVE | LK_FAILRECLAIM);
+                       if (error) {
                                vput(tdp);
                                return (error);
                        }
index 51b67a0..1086651 100644 (file)
@@ -684,8 +684,10 @@ ufs_link(struct vop_old_link_args *ap)
                error = EXDEV;
                goto out2;
        }
-       if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE))) {
-               goto out2;
+       if (tdvp != vp) {
+               error = vn_lock(vp, LK_EXCLUSIVE | LK_FAILRECLAIM);
+               if (error)
+                       goto out2;
        }
        ip = VTOI(vp);
        if ((nlink_t)ip->i_nlink >= LINK_MAX) {
@@ -856,7 +858,8 @@ abortit:
                goto abortit;
        }
 
-       if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0)
+       error = vn_lock(fvp, LK_EXCLUSIVE | LK_FAILRECLAIM);
+       if (error)
                goto abortit;
 
        /*
@@ -1225,7 +1228,7 @@ bad:
 out:
        if (doingdirectory)
                ip->i_flag &= ~IN_RENAME;
-       if (vn_lock(fvp, LK_EXCLUSIVE) == 0) {
+       if (vn_lock(fvp, LK_EXCLUSIVE | LK_FAILRECLAIM) == 0) {
                ip->i_effnlink--;
                ip->i_nlink--;
                ip->i_flag |= IN_CHANGE;
@@ -1617,7 +1620,8 @@ ufs_readdir(struct vop_readdir_args *ap)
        }
        cookie_index = 0;
 
-       if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+       error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);
+       if (error)
                return (error);
 
        /*
index cf480d9..c2260c9 100644 (file)
@@ -427,20 +427,23 @@ loop:
                                 */
                                vref(dvp);
                                vn_unlock(dvp);
-                               error = vn_lock(un->un_vnode, LK_EXCLUSIVE);
+                               error = vn_lock(un->un_vnode, LK_EXCLUSIVE |
+                                                             LK_FAILRECLAIM);
                                vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
                                vrele(dvp);
                        } else {
                                /*
                                 * our new un is under dvp
                                 */
-                               error = vn_lock(un->un_vnode, LK_EXCLUSIVE);
+                               error = vn_lock(un->un_vnode, LK_EXCLUSIVE |
+                                                             LK_FAILRECLAIM);
                        }
                } else if (dvp == NULLVP) {
                        /*
                         * dvp is NULL, we need to lock un.
                         */
-                       error = vn_lock(un->un_vnode, LK_EXCLUSIVE);
+                       error = vn_lock(un->un_vnode, LK_EXCLUSIVE |
+                                                     LK_FAILRECLAIM);
                } else {
                        /*
                         * dvp == un->un_vnode, we are already locked.
index 7fabf13..ecd20f1 100644 (file)
@@ -1031,7 +1031,7 @@ vm_pageout_scan_inactive(int pass, int q, int avail_shortage,
                                int flags;
 
                                vp = object->handle;
-                               flags = LK_EXCLUSIVE | LK_NOOBJ;
+                               flags = LK_EXCLUSIVE;
                                if (vp == vpfailed)
                                        flags |= LK_NOWAIT;
                                else