diff --git a/acinclude.m4 b/acinclude.m4 index 6897a5c1a4..0315f69e0e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -905,6 +905,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_INIT_WORK_HAS_DATA LINUX_REGISTER_SYSCTL_TABLE_NOFLAG LINUX_HAVE_DCACHE_LOCK + LINUX_D_COUNT_IS_INT dnl If we are guaranteed that keyrings will work - that is dnl a) The kernel has keyrings enabled diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index a741998811..f3ba62a77d 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1306,8 +1306,17 @@ afs_linux_rename(struct inode *oldip, struct dentry *olddp, rehash = newdp; } +#if defined(D_COUNT_INT) + spin_lock(&olddp->d_lock); + if (olddp->d_count > 1) { + spin_unlock(&olddp->d_lock); + shrink_dcache_parent(olddp); + } else + spin_unlock(&olddp->d_lock); +#else if (atomic_read(&olddp->d_count) > 1) shrink_dcache_parent(olddp); +#endif AFS_GLOCK(); code = afs_rename(VTOAFS(oldip), (char *)oldname, VTOAFS(newip), (char *)newname, credp); diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 945b4f091c..cf6045a235 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -592,3 +592,15 @@ AC_DEFUN([LINUX_HAVE_DCACHE_LOCK], [ []) ]) + +AC_DEFUN([LINUX_D_COUNT_IS_INT], [ + AC_CHECK_LINUX_BUILD([if dentry->d_count is an int], + [ac_cv_linux_d_count_int], + [#include ], + [struct dentry _d; + dget(&_d); + _d.d_count = 1;], + [D_COUNT_INT], + [define if dentry->d_count is an int], + [-Werror]) +])