Page MenuHomeFreeBSD

vfs cache: Simplify cache_enter_time() a bit
AcceptedPublic

Authored by markj on Thu, May 1, 2:36 PM.

Details

Reviewers
kib
olce
mjg
Summary

The condition flag == NFC_ISDOTDOT && vp != NULL && vp->v_type != VDIR
is never true at this point in the function. This is asserted slightly
earlier. So, remove some dead code and simplify control flow.

N.B. we set v_cache_dd for all vnode types, not just VDIR. This seems
to be intentional, see commit ce575cd0e2f9069. For regular files it
appears to effectively represent the most recently entered cache entry
for the vnode.

No functional change intended.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63823
Build 60707: arc lint + arc unit

Event Timeline

markj requested review of this revision.Thu, May 1, 2:36 PM

N.B. we set v_cache_dd for all vnode types, not just VDIR. This seems to be intentional,

IIRC that's for the sake of vn_fullpath() and friends.

This revision is now accepted and ready to land.Thu, May 1, 3:12 PM

N.B. we set v_cache_dd for all vnode types, not just VDIR. This seems to be intentional,

IIRC that's for the sake of vn_fullpath() and friends.

Yes, vn_vptocnp() makes use of it. It seems reasonable, I was just very confused when first reading this code.

v_cache_dd is a small optimization for non-VDIR, it is not required for vn_vptocnp(), strictly speaking. It is only an optimization, if any.

In D50107#1142926, @kib wrote:

v_cache_dd is a small optimization for non-VDIR, it is not required for vn_vptocnp(), strictly speaking. It is only an optimization, if any.

True. Just to clear out any confusion, vn_vptocnp() relies on the VFS cache in the end (via v_cache_dst), and just cannot work without it. That said, v_cache_dd itself seems indeed just a small optimization, allowing not to walk v_cache_dst in case of (many) .. entries leading to the vnode.