cache: combine fast path enabled status into one flag
Tested by: pho
This commit is contained in:
parent
dbbbc07cc3
commit
33f3e81df5
@ -3571,12 +3571,45 @@ DB_SHOW_COMMAND(vpath, db_show_vpath)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool __read_frequently cache_fast_lookup = true;
|
static int cache_fast_lookup = 1;
|
||||||
SYSCTL_BOOL(_vfs, OID_AUTO, cache_fast_lookup, CTLFLAG_RW,
|
static char __read_frequently cache_fast_lookup_enabled = true;
|
||||||
&cache_fast_lookup, 0, "");
|
|
||||||
|
|
||||||
#define CACHE_FPL_FAILED -2020
|
#define CACHE_FPL_FAILED -2020
|
||||||
|
|
||||||
|
void
|
||||||
|
cache_fast_lookup_enabled_recalc(void)
|
||||||
|
{
|
||||||
|
int lookup_flag;
|
||||||
|
int mac_on;
|
||||||
|
|
||||||
|
#ifdef MAC
|
||||||
|
mac_on = mac_vnode_check_lookup_enabled();
|
||||||
|
#else
|
||||||
|
mac_on = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lookup_flag = atomic_load_int(&cache_fast_lookup);
|
||||||
|
if (lookup_flag && !mac_on) {
|
||||||
|
atomic_store_char(&cache_fast_lookup_enabled, true);
|
||||||
|
} else {
|
||||||
|
atomic_store_char(&cache_fast_lookup_enabled, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
syscal_vfs_cache_fast_lookup(SYSCTL_HANDLER_ARGS)
|
||||||
|
{
|
||||||
|
int error, old;
|
||||||
|
|
||||||
|
old = atomic_load_int(&cache_fast_lookup);
|
||||||
|
error = sysctl_handle_int(oidp, arg1, arg2, req);
|
||||||
|
if (error == 0 && req->newptr && old != atomic_load_int(&cache_fast_lookup))
|
||||||
|
cache_fast_lookup_enabled_recalc();
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
SYSCTL_PROC(_vfs, OID_AUTO, cache_fast_lookup, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE,
|
||||||
|
&cache_fast_lookup, 0, syscal_vfs_cache_fast_lookup, "IU", "");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Components of nameidata (or objects it can point to) which may
|
* Components of nameidata (or objects it can point to) which may
|
||||||
* need restoring in case fast path lookup fails.
|
* need restoring in case fast path lookup fails.
|
||||||
@ -3854,16 +3887,10 @@ cache_can_fplookup(struct cache_fpl *fpl)
|
|||||||
cnp = fpl->cnp;
|
cnp = fpl->cnp;
|
||||||
td = cnp->cn_thread;
|
td = cnp->cn_thread;
|
||||||
|
|
||||||
if (!cache_fast_lookup) {
|
if (!atomic_load_char(&cache_fast_lookup_enabled)) {
|
||||||
cache_fpl_aborted_early(fpl);
|
cache_fpl_aborted_early(fpl);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
#ifdef MAC
|
|
||||||
if (mac_vnode_check_lookup_enabled()) {
|
|
||||||
cache_fpl_aborted_early(fpl);
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if ((cnp->cn_flags & ~CACHE_FPL_SUPPORTED_CN_FLAGS) != 0) {
|
if ((cnp->cn_flags & ~CACHE_FPL_SUPPORTED_CN_FLAGS) != 0) {
|
||||||
cache_fpl_aborted_early(fpl);
|
cache_fpl_aborted_early(fpl);
|
||||||
return (false);
|
return (false);
|
||||||
@ -5205,9 +5232,9 @@ cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
|
|||||||
}
|
}
|
||||||
MPASS(cnp->cn_nameptr == cnp->cn_pnbuf);
|
MPASS(cnp->cn_nameptr == cnp->cn_pnbuf);
|
||||||
|
|
||||||
if (!cache_can_fplookup(&fpl)) {
|
if (__predict_false(!cache_can_fplookup(&fpl))) {
|
||||||
SDT_PROBE3(vfs, fplookup, lookup, done, ndp, fpl.line, fpl.status);
|
|
||||||
*status = fpl.status;
|
*status = fpl.status;
|
||||||
|
SDT_PROBE3(vfs, fplookup, lookup, done, ndp, fpl.line, fpl.status);
|
||||||
return (EOPNOTSUPP);
|
return (EOPNOTSUPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/sdt.h>
|
#include <sys/sdt.h>
|
||||||
#include <sys/sx.h>
|
#include <sys/sx.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
|
||||||
#include <security/mac/mac_framework.h>
|
#include <security/mac/mac_framework.h>
|
||||||
#include <security/mac/mac_internal.h>
|
#include <security/mac/mac_internal.h>
|
||||||
@ -399,6 +400,8 @@ mac_policy_update(void)
|
|||||||
mac_labeled |= mac_policy_getlabeled(mpc);
|
mac_labeled |= mac_policy_getlabeled(mpc);
|
||||||
mac_policy_count++;
|
mac_policy_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache_fast_lookup_enabled_recalc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -657,6 +657,7 @@ cache_validate(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
void cache_fast_lookup_enabled_recalc(void);
|
||||||
int change_dir(struct vnode *vp, struct thread *td);
|
int change_dir(struct vnode *vp, struct thread *td);
|
||||||
void cvtstat(struct stat *st, struct ostat *ost);
|
void cvtstat(struct stat *st, struct ostat *ost);
|
||||||
void freebsd11_cvtnstat(struct stat *sb, struct nstat *nsb);
|
void freebsd11_cvtnstat(struct stat *sb, struct nstat *nsb);
|
||||||
|
Loading…
Reference in New Issue
Block a user