Author: mjg
Date: Thu Aug 20 10:05:46 2020
New Revision: 364419
URL: https://svnweb.freebsd.org/changeset/base/364419

Log:
  cache: add cache_rename, a dedicated helper to use for renames
  
  While here make both tmpfs and ufs use it.
  
  No fuctional changes.

Modified:
  head/sys/fs/tmpfs/tmpfs_vnops.c
  head/sys/kern/vfs_cache.c
  head/sys/sys/vnode.h
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c     Thu Aug 20 10:05:19 2020        
(r364418)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c     Thu Aug 20 10:05:46 2020        
(r364419)
@@ -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;

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c   Thu Aug 20 10:05:19 2020        (r364418)
+++ head/sys/kern/vfs_cache.c   Thu Aug 20 10:05:46 2020        (r364419)
@@ -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.
  */

Modified: head/sys/sys/vnode.h
==============================================================================
--- head/sys/sys/vnode.h        Thu Aug 20 10:05:19 2020        (r364418)
+++ head/sys/sys/vnode.h        Thu Aug 20 10:05:46 2020        (r364419)
@@ -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);

Modified: head/sys/ufs/ufs/ufs_vnops.c
==============================================================================
--- head/sys/ufs/ufs/ufs_vnops.c        Thu Aug 20 10:05:19 2020        
(r364418)
+++ head/sys/ufs/ufs/ufs_vnops.c        Thu Aug 20 10:05:46 2020        
(r364419)
@@ -1629,10 +1629,7 @@ relock:
         * 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) {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to