Author: kib
Date: Wed May 18 12:02:05 2016
New Revision: 300141
URL: https://svnweb.freebsd.org/changeset/base/300141

Log:
  MFC r299413:
  Use vfs_hash_ref(9) to eliminate LK_EXCLOTHER kludge.

Modified:
  stable/10/sys/fs/nfsclient/nfs_clport.c
  stable/10/sys/fs/nfsclient/nfs_clvnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- stable/10/sys/fs/nfsclient/nfs_clport.c     Wed May 18 11:58:16 2016        
(r300140)
+++ stable/10/sys/fs/nfsclient/nfs_clport.c     Wed May 18 12:02:05 2016        
(r300141)
@@ -279,7 +279,7 @@ nfscl_nget(struct mount *mntp, struct vn
 }
 
 /*
- * Anothe variant of nfs_nget(). This one is only used by reopen. It
+ * Another variant of nfs_nget(). This one is only used by reopen. It
  * takes almost the same args as nfs_nget(), but only succeeds if an entry
  * exists in the cache. (Since files should already be "open" with a
  * vnode ref cnt on the node when reopen calls this, it should always
@@ -318,21 +318,24 @@ nfscl_ngetreopen(struct mount *mntp, u_i
                NFSVOPUNLOCK(nvp, 0);
        } else if (error == EBUSY) {
                /*
-                * The LK_EXCLOTHER lock type tells nfs_lock1() to not try
-                * and lock the vnode, but just get a v_usecount on it.
-                * LK_NOWAIT is set so that when vget() returns ENOENT,
-                * vfs_hash_get() fails instead of looping.
-                * If this succeeds, it is safe so long as a vflush() with
+                * It is safe so long as a vflush() with
                 * FORCECLOSE has not been done. Since the Renew thread is
                 * stopped and the MNTK_UNMOUNTF flag is set before doing
                 * a vflush() with FORCECLOSE, we should be ok here.
                 */
                if ((mntp->mnt_kern_flag & MNTK_UNMOUNTF))
                        error = EINTR;
-               else
-                       error = vfs_hash_get(mntp, hash,
-                           (LK_EXCLOTHER | LK_NOWAIT), td, &nvp,
-                           newnfs_vncmpf, nfhp);
+               else {
+                       vfs_hash_ref(mntp, hash, td, &nvp, newnfs_vncmpf, nfhp);
+                       if (nvp == NULL) {
+                               error = ENOENT;
+                       } else if ((nvp->v_iflag & VI_DOOMED) != 0) {
+                               error = ENOENT;
+                               vrele(nvp);
+                       } else {
+                               error = 0;
+                       }
+               }
        }
        FREE(nfhp, M_NFSFH);
        if (error)

Modified: stable/10/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- stable/10/sys/fs/nfsclient/nfs_clvnops.c    Wed May 18 11:58:16 2016        
(r300140)
+++ stable/10/sys/fs/nfsclient/nfs_clvnops.c    Wed May 18 12:02:05 2016        
(r300141)
@@ -139,7 +139,6 @@ static vop_rmdir_t  nfs_rmdir;
 static vop_symlink_t   nfs_symlink;
 static vop_readdir_t   nfs_readdir;
 static vop_strategy_t  nfs_strategy;
-static vop_lock1_t     nfs_lock1;
 static int     nfs_lookitup(struct vnode *, char *, int,
                    struct ucred *, struct thread *, struct nfsnode **);
 static int     nfs_sillyrename(struct vnode *, struct vnode *,
@@ -168,7 +167,6 @@ struct vop_vector newnfs_vnodeops = {
        .vop_putpages =         ncl_putpages,
        .vop_inactive =         ncl_inactive,
        .vop_link =             nfs_link,
-       .vop_lock1 =            nfs_lock1,
        .vop_lookup =           nfs_lookup,
        .vop_mkdir =            nfs_mkdir,
        .vop_mknod =            nfs_mknod,
@@ -3350,37 +3348,6 @@ struct buf_ops buf_ops_newnfs = {
        .bop_bdflush    =       bufbdflush,
 };
 
-/*
- * Cloned from vop_stdlock(), and then the ugly hack added.
- */
-static int
-nfs_lock1(struct vop_lock1_args *ap)
-{
-       struct vnode *vp = ap->a_vp;
-       int error = 0;
-
-       /*
-        * Since vfs_hash_get() calls vget() and it will no longer work
-        * for FreeBSD8 with flags == 0, I can only think of this horrible
-        * hack to work around it. I call vfs_hash_get() with LK_EXCLOTHER
-        * and then handle it here. All I want for this case is a v_usecount
-        * on the vnode to use for recovery, while another thread might
-        * hold a lock on the vnode. I have the other threads blocked, so
-        * there isn't any race problem.
-        */
-       if ((ap->a_flags & LK_TYPE_MASK) == LK_EXCLOTHER) {
-               if ((ap->a_flags & LK_INTERLOCK) == 0)
-                       panic("ncllock1");
-               if ((vp->v_iflag & VI_DOOMED))
-                       error = ENOENT;
-               VI_UNLOCK(vp);
-               return (error);
-       }
-       return (_lockmgr_args(vp->v_vnlock, ap->a_flags, VI_MTX(vp),
-           LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT, ap->a_file,
-           ap->a_line));
-}
-
 static int
 nfs_getacl(struct vop_getacl_args *ap)
 {
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to