Author: mjg
Date: Mon Oct 26 18:01:18 2020
New Revision: 367064
URL: https://svnweb.freebsd.org/changeset/base/367064

Log:
  cache: add missing NIRES_ABS handling

Modified:
  head/sys/kern/vfs_cache.c
  head/sys/kern/vfs_lookup.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c   Mon Oct 26 17:52:28 2020        (r367063)
+++ head/sys/kern/vfs_cache.c   Mon Oct 26 18:01:18 2020        (r367064)
@@ -3607,7 +3607,7 @@ cache_fpl_checkpoint(struct cache_fpl *fpl, struct nam
 }
 
 static void
-cache_fpl_restore(struct cache_fpl *fpl, struct nameidata_saved *snd)
+cache_fpl_restore_partial(struct cache_fpl *fpl, struct nameidata_saved *snd)
 {
 
        fpl->ndp->ni_cnd.cn_flags = snd->cn_flags;
@@ -3616,6 +3616,17 @@ cache_fpl_restore(struct cache_fpl *fpl, struct nameid
        fpl->ndp->ni_pathlen = snd->ni_pathlen;
 }
 
+static void
+cache_fpl_restore_abort(struct cache_fpl *fpl, struct nameidata_saved *snd)
+{
+
+       cache_fpl_restore_partial(fpl, snd);
+       /*
+        * It is 0 on entry by API contract.
+        */
+       fpl->ndp->ni_resflags = 0;
+}
+
 #ifdef INVARIANTS
 #define cache_fpl_smr_assert_entered(fpl) ({                   \
        struct cache_fpl *_fpl = (fpl);                         \
@@ -3846,7 +3857,7 @@ cache_fplookup_partial_setup(struct cache_fpl *fpl)
                return (cache_fpl_aborted(fpl));
        }
 
-       cache_fpl_restore(fpl, &fpl->snd);
+       cache_fpl_restore_partial(fpl, &fpl->snd);
 
        ndp->ni_startdir = dvp;
        cnp->cn_flags |= MAKEENTRY;
@@ -4696,6 +4707,7 @@ cache_fplookup(struct nameidata *ndp, enum cache_fpl_s
        cnp->cn_nameptr = cnp->cn_pnbuf;
        if (cnp->cn_pnbuf[0] == '/') {
                cache_fpl_handle_root(ndp, &dvp);
+               ndp->ni_resflags |= NIRES_ABS;
        } else {
                if (ndp->ni_dirfd == AT_FDCWD) {
                        dvp = pwd->pwd_cdir;
@@ -4730,7 +4742,7 @@ out:
                 */
                break;
        case CACHE_FPL_STATUS_ABORTED:
-               cache_fpl_restore(&fpl, &orig);
+               cache_fpl_restore_abort(&fpl, &orig);
                break;
        }
        return (error);

Modified: head/sys/kern/vfs_lookup.c
==============================================================================
--- head/sys/kern/vfs_lookup.c  Mon Oct 26 17:52:28 2020        (r367063)
+++ head/sys/kern/vfs_lookup.c  Mon Oct 26 18:01:18 2020        (r367064)
@@ -511,6 +511,8 @@ namei(struct nameidata *ndp)
        cnp->cn_origflags = cnp->cn_flags;
 #endif
        ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_thread->td_ucred;
+       KASSERT(ndp->ni_resflags == 0, ("%s: garbage in ni_resflags: %x\n",
+           __func__, ndp->ni_resflags));
        KASSERT(cnp->cn_cred && td->td_proc, ("namei: bad cred/proc"));
        KASSERT((cnp->cn_flags & NAMEI_INTERNAL_FLAGS) == 0,
            ("namei: unexpected flags: %" PRIx64 "\n",
_______________________________________________
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