FreeBSD: use cache_rename if available

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Matt Macy <mmacy@FreeBSD.org>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #11045
This commit is contained in:
Mateusz Guzik 2020-10-14 01:41:26 +02:00 committed by Brian Behlendorf
parent f40a1ad9e0
commit 7f0b3fa042

View File

@ -3901,6 +3901,19 @@ zfs_rename_check(znode_t *szp, znode_t *sdzp, znode_t *tdzp)
return (error);
}
#if __FreeBSD_version < 1300110
static void
cache_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp,
struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp)
{
cache_purge(fvp);
if (tvp != NULL)
cache_purge(tvp);
cache_purge_negative(tdvp);
}
#endif
/*
* Move an entry from the provided source directory to the target
* directory. Change the entry name as indicated.
@ -4159,10 +4172,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp,
}
}
if (error == 0) {
cache_purge(*svpp);
if (*tvpp != NULL)
cache_purge(*tvpp);
cache_purge_negative(tdvp);
cache_rename(sdvp, *svpp, tdvp, *tvpp, scnp, tcnp);
}
}