cache: add cache_rename, a dedicated helper to use for renames

While here make both tmpfs and ufs use it.

No fuctional changes.
This commit is contained in:
Mateusz Guzik 2020-08-20 10:05:46 +00:00
parent 16be9f9956
commit 39f8815070
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=364419
4 changed files with 21 additions and 8 deletions

View File

@ -1144,10 +1144,7 @@ tmpfs_rename(struct vop_rename_args *v)
tmpfs_dir_attach(tdvp, de);
if (tmpfs_use_nc(fvp)) {
cache_purge(fvp);
if (tvp != NULL)
cache_purge(tvp);
cache_purge_negative(tdvp);
cache_rename(fdvp, fvp, tdvp, tvp, fcnp, tcnp);
}
error = 0;

View File

@ -2339,6 +2339,23 @@ cache_purge_negative(struct vnode *vp)
}
}
void
cache_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp,
struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp)
{
ASSERT_VOP_IN_SEQC(fdvp);
ASSERT_VOP_IN_SEQC(fvp);
ASSERT_VOP_IN_SEQC(tdvp);
if (tvp != NULL)
ASSERT_VOP_IN_SEQC(tvp);
cache_purge(fvp);
if (tvp != NULL)
cache_purge(tvp);
cache_purge_negative(tdvp);
}
/*
* Flush all entries referencing a particular filesystem.
*/

View File

@ -642,6 +642,8 @@ void cache_vnode_init(struct vnode *vp);
void cache_purge(struct vnode *vp);
void cache_purge_vgone(struct vnode *vp);
void cache_purge_negative(struct vnode *vp);
void cache_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp,
struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp);
void cache_purgevfs(struct mount *mp, bool force);
int change_dir(struct vnode *vp, struct thread *td);
void cvtstat(struct stat *st, struct ostat *ost);

View File

@ -1629,10 +1629,7 @@ ufs_rename(ap)
* name that references the old i-node if it has other links
* or open file descriptors.
*/
cache_purge(fvp);
if (tvp)
cache_purge(tvp);
cache_purge_negative(tdvp);
cache_rename(fdvp, fvp, tdvp, tvp, fcnp, tcnp);
unlockout:
if (want_seqc_end) {