[1835] | 1 | From 7c3999e05c928991d22e3eeae2c69e5759c6ea4a Mon Sep 17 00:00:00 2001 |
---|
| 2 | From: Marc Dionne <marc.c.dionne@gmail.com> |
---|
| 3 | Date: Wed, 2 Feb 2011 21:55:27 -0500 |
---|
| 4 | Subject: [PATCH 8/8] Linux: 2.6.38: dentry->d_count is not an atomic |
---|
| 5 | |
---|
| 6 | d_count is now an int protected by the dentry's d_lock. |
---|
| 7 | Take the lock when we use it, instead of using an atomic_* |
---|
| 8 | function. |
---|
| 9 | |
---|
| 10 | Reviewed-on: http://gerrit.openafs.org/3883 |
---|
| 11 | Tested-by: BuildBot <buildbot@rampaginggeek.com> |
---|
| 12 | Reviewed-by: Derrick Brashear <shadow@dementia.org> |
---|
| 13 | (cherry picked from commit 281f5bf5fbb0a546edcce62ef4e097ae9bbdbf73) |
---|
| 14 | |
---|
| 15 | Change-Id: Id6b17d9cfe18d348a66df02f6b309fc53b00da86 |
---|
| 16 | Signed-off-by: Anders Kaseorg <andersk@mit.edu> |
---|
| 17 | Reviewed-on: http://gerrit.openafs.org/3999 |
---|
| 18 | Tested-by: BuildBot <buildbot@rampaginggeek.com> |
---|
| 19 | Reviewed-by: Russ Allbery <rra@stanford.edu> |
---|
| 20 | Reviewed-on: http://gerrit.openafs.org/4044 |
---|
| 21 | Reviewed-by: Derrick Brashear <shadow@dementia.org> |
---|
| 22 | Tested-by: Derrick Brashear <shadow@dementia.org> |
---|
| 23 | --- |
---|
| 24 | acinclude.m4 | 1 + |
---|
| 25 | src/afs/LINUX/osi_vnodeops.c | 9 +++++++++ |
---|
| 26 | src/cf/linux-test4.m4 | 12 ++++++++++++ |
---|
| 27 | 3 files changed, 22 insertions(+), 0 deletions(-) |
---|
| 28 | |
---|
| 29 | diff --git a/acinclude.m4 b/acinclude.m4 |
---|
| 30 | index 655fb11..c3f5e15 100644 |
---|
| 31 | --- a/acinclude.m4 |
---|
| 32 | +++ b/acinclude.m4 |
---|
| 33 | @@ -818,6 +818,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) |
---|
| 34 | LINUX_INIT_WORK_HAS_DATA |
---|
| 35 | LINUX_REGISTER_SYSCTL_TABLE_NOFLAG |
---|
| 36 | LINUX_HAVE_DCACHE_LOCK |
---|
| 37 | + LINUX_D_COUNT_IS_INT |
---|
| 38 | LINUX_SYSCTL_TABLE_CHECKING |
---|
| 39 | LINUX_STRUCT_CTL_TABLE_HAS_CTL_NAME |
---|
| 40 | LINUX_HAVE_IGET |
---|
| 41 | diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c |
---|
| 42 | index e2a3e28..3118ec7 100644 |
---|
| 43 | --- a/src/afs/LINUX/osi_vnodeops.c |
---|
| 44 | +++ b/src/afs/LINUX/osi_vnodeops.c |
---|
| 45 | @@ -1396,9 +1396,18 @@ afs_linux_rename(struct inode *oldip, struct dentry *olddp, |
---|
| 46 | #endif |
---|
| 47 | |
---|
| 48 | #if defined(AFS_LINUX24_ENV) |
---|
| 49 | +#if defined(D_COUNT_INT) |
---|
| 50 | + spin_lock(&olddp->d_lock); |
---|
| 51 | + if (olddp->d_count > 1) { |
---|
| 52 | + spin_unlock(&olddp->d_lock); |
---|
| 53 | + shrink_dcache_parent(olddp); |
---|
| 54 | + } else |
---|
| 55 | + spin_unlock(&olddp->d_lock); |
---|
| 56 | +#else |
---|
| 57 | if (atomic_read(&olddp->d_count) > 1) |
---|
| 58 | shrink_dcache_parent(olddp); |
---|
| 59 | #endif |
---|
| 60 | +#endif |
---|
| 61 | |
---|
| 62 | AFS_GLOCK(); |
---|
| 63 | code = afs_rename(VTOAFS(oldip), oldname, VTOAFS(newip), newname, credp); |
---|
| 64 | diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 |
---|
| 65 | index 2f426ce..b428f37 100644 |
---|
| 66 | --- a/src/cf/linux-test4.m4 |
---|
| 67 | +++ b/src/cf/linux-test4.m4 |
---|
| 68 | @@ -1327,3 +1327,15 @@ AC_DEFUN([LINUX_HAVE_DCACHE_LOCK], [ |
---|
| 69 | []) |
---|
| 70 | ]) |
---|
| 71 | |
---|
| 72 | + |
---|
| 73 | +AC_DEFUN([LINUX_D_COUNT_IS_INT], [ |
---|
| 74 | + AC_CHECK_LINUX_BUILD([if dentry->d_count is an int], |
---|
| 75 | + [ac_cv_linux_d_count_int], |
---|
| 76 | + [#include <linux/dcache.h> ], |
---|
| 77 | + [struct dentry _d; |
---|
| 78 | + dget(&_d); |
---|
| 79 | + _d.d_count = 1;], |
---|
| 80 | + [D_COUNT_INT], |
---|
| 81 | + [define if dentry->d_count is an int], |
---|
| 82 | + [-Werror]) |
---|
| 83 | +]) |
---|
| 84 | -- |
---|
| 85 | 1.7.3.4 |
---|
| 86 | |
---|