1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-27 08:00:11 +00:00

cache: add cache_enter_time_flags

This commit is contained in:
Mateusz Guzik 2021-07-08 09:56:27 +02:00
parent 4c87085d35
commit 844aa31c6d
2 changed files with 30 additions and 0 deletions

View File

@ -2582,6 +2582,30 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
return;
}
/*
* A variant of the above accepting flags.
*
* - VFS_CACHE_DROPOLD -- if a conflicting entry is found, drop it.
*
* TODO: this routine is a hack. It blindly removes the old entry, even if it
* happens to match and it is doing it in an inefficient manner. It was added
* to accomodate NFS which runs into a case where the target for a given name
* may change from under it. Note this does nothing to solve the following
* race: 2 callers of cache_enter_time_flags pass a different target vnode for
* the same [dvp, cnp]. It may be argued that code doing this is broken.
*/
void
cache_enter_time_flags(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
struct timespec *tsp, struct timespec *dtsp, int flags)
{
MPASS((flags & ~(VFS_CACHE_DROPOLD)) == 0);
if (flags & VFS_CACHE_DROPOLD)
cache_remove_cnp(dvp, cnp);
cache_enter_time(dvp, vp, cnp, tsp, dtsp);
}
static u_int
cache_roundup_2(u_int val)
{

View File

@ -641,6 +641,12 @@ int bnoreuselist(struct bufv *bufv, struct bufobj *bo, daddr_t startn,
daddr_t endn);
/* cache_* may belong in namei.h. */
void cache_changesize(u_long newhashsize);
#define VFS_CACHE_DROPOLD 0x1
void cache_enter_time_flags(struct vnode *dvp, struct vnode *vp,
struct componentname *cnp, struct timespec *tsp,
struct timespec *dtsp, int flags);
#define cache_enter(dvp, vp, cnp) \
cache_enter_time(dvp, vp, cnp, NULL, NULL)
void cache_enter_time(struct vnode *dvp, struct vnode *vp,