Author: mjg
Date: Sat Feb  8 15:52:20 2020
New Revision: 357680
URL: https://svnweb.freebsd.org/changeset/base/357680

Log:
  vfs: tidy up vget_finish and vn_lock
  
  - remove assertion which duplicates vn_lock
  - use VNPASS instead of retyping the failure
  - report what flags were passed if panicking on them

Modified:
  head/sys/kern/vfs_subr.c
  head/sys/kern/vfs_vnops.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c    Sat Feb  8 15:51:08 2020        (r357679)
+++ head/sys/kern/vfs_subr.c    Sat Feb  8 15:52:20 2020        (r357680)
@@ -2889,19 +2889,12 @@ vget_finish(struct vnode *vp, int flags, enum vgetstat
 {
        int error, old;
 
-       VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
-           ("%s: invalid lock operation", __func__));
-
        if ((flags & LK_INTERLOCK) != 0)
                ASSERT_VI_LOCKED(vp, __func__);
        else
                ASSERT_VI_UNLOCKED(vp, __func__);
-       VNASSERT(vp->v_holdcnt > 0, vp, ("%s: vnode not held", __func__));
-       if (vs == VGET_USECOUNT) {
-               VNASSERT(vp->v_usecount > 0, vp,
-                   ("%s: vnode without usecount when VGET_USECOUNT was passed",
-                   __func__));
-       }
+       VNPASS(vp->v_holdcnt > 0, vp);
+       VNPASS(vs == VGET_HOLDCNT || vp->v_usecount > 0, vp);
 
        error = vn_lock(vp, flags);
        if (__predict_false(error != 0)) {
@@ -2914,9 +2907,8 @@ vget_finish(struct vnode *vp, int flags, enum vgetstat
                return (error);
        }
 
-       if (vs == VGET_USECOUNT) {
+       if (vs == VGET_USECOUNT)
                return (0);
-       }
 
        if (__predict_false(vp->v_type == VCHR))
                return (vget_finish_vchr(vp));

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c   Sat Feb  8 15:51:08 2020        (r357679)
+++ head/sys/kern/vfs_vnops.c   Sat Feb  8 15:52:20 2020        (r357680)
@@ -1606,8 +1606,9 @@ _vn_lock(struct vnode *vp, int flags, char *file, int 
 {
        int error;
 
-       VNASSERT((flags & LK_TYPE_MASK) != 0, vp, ("vn_lock: no locktype"));
-       VNASSERT(vp->v_holdcnt != 0, vp, ("vn_lock: zero hold count"));
+       VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
+           ("vn_lock: no locktype (%d passed)", flags));
+       VNPASS(vp->v_holdcnt > 0, vp);
        error = VOP_LOCK1(vp, flags, file, line);
        if (__predict_false(error != 0 || VN_IS_DOOMED(vp)))
                return (_vn_lock_fallback(vp, flags, file, line, error));
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to