diff options
author | Yan, Zheng <zheng.z.yan@intel.com> | 2013-08-13 03:42:02 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-03 22:50:28 -0400 |
commit | 590fb51f1cf99c4a48a3b1bd65885192e877b561 (patch) | |
tree | 62e706e81be88a9760a126b4270e2b09c03933a1 /fs | |
parent | 184cacabe274a0af65b3876e9cd95c9fdde069ea (diff) |
vfs: call d_op->d_prune() before unhashing dentry
The d_prune dentry operation is used to notify filesystem when VFS
about to prune a hashed dentry from the dcache. There are three
code paths that prune dentries: shrink_dcache_for_umount_subtree(),
prune_dcache_sb() and d_prune_aliases(). For the d_prune_aliases()
case, VFS unhashes the dentry first, then call the d_prune dentry
operation. This confuses ceph_d_prune() (ceph uses the d_prune
dentry operation to maintain a flag indicating whether the complete
contents of a directory are in the dcache, pruning unhashed dentry
does not affect dir's completeness)
This patch fixes the issue by calling the d_prune dentry operation
in d_prune_aliases(), before unhashing the dentry. Also make VFS
only call the d_prune dentry operation for hashed dentry, to avoid
calling the d_prune dentry operation twice when dentry is pruned
by d_prune_aliases().
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dcache.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 83cfb834db03..2e5f9ca83285 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -472,7 +472,7 @@ relock: | |||
472 | * inform the fs via d_prune that this dentry is about to be | 472 | * inform the fs via d_prune that this dentry is about to be |
473 | * unhashed and destroyed. | 473 | * unhashed and destroyed. |
474 | */ | 474 | */ |
475 | if (dentry->d_flags & DCACHE_OP_PRUNE) | 475 | if ((dentry->d_flags & DCACHE_OP_PRUNE) && !d_unhashed(dentry)) |
476 | dentry->d_op->d_prune(dentry); | 476 | dentry->d_op->d_prune(dentry); |
477 | 477 | ||
478 | dentry_lru_del(dentry); | 478 | dentry_lru_del(dentry); |
@@ -719,6 +719,14 @@ restart: | |||
719 | hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { | 719 | hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { |
720 | spin_lock(&dentry->d_lock); | 720 | spin_lock(&dentry->d_lock); |
721 | if (!dentry->d_count) { | 721 | if (!dentry->d_count) { |
722 | /* | ||
723 | * inform the fs via d_prune that this dentry | ||
724 | * is about to be unhashed and destroyed. | ||
725 | */ | ||
726 | if ((dentry->d_flags & DCACHE_OP_PRUNE) && | ||
727 | !d_unhashed(dentry)) | ||
728 | dentry->d_op->d_prune(dentry); | ||
729 | |||
722 | __dget_dlock(dentry); | 730 | __dget_dlock(dentry); |
723 | __d_drop(dentry); | 731 | __d_drop(dentry); |
724 | spin_unlock(&dentry->d_lock); | 732 | spin_unlock(&dentry->d_lock); |
@@ -907,7 +915,8 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) | |||
907 | * inform the fs that this dentry is about to be | 915 | * inform the fs that this dentry is about to be |
908 | * unhashed and destroyed. | 916 | * unhashed and destroyed. |
909 | */ | 917 | */ |
910 | if (dentry->d_flags & DCACHE_OP_PRUNE) | 918 | if ((dentry->d_flags & DCACHE_OP_PRUNE) && |
919 | !d_unhashed(dentry)) | ||
911 | dentry->d_op->d_prune(dentry); | 920 | dentry->d_op->d_prune(dentry); |
912 | 921 | ||
913 | dentry_lru_del(dentry); | 922 | dentry_lru_del(dentry); |