[PATCH 26/73] union-mount: Free union stack on removal of topmostdentry from dcache [ver #2]

From: David Howells
Date: Tue Feb 21 2012 - 13:10:55 EST


From: Jan Blunck <jblunck@xxxxxxx>

If a dentry is removed from dentry cache because its usage count drops
to zero, its union stack is freed too.

Original-author: Jan Blunck <jblunck@xxxxxxx>
Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---

fs/dcache.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 326a432..e450890 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -39,6 +39,7 @@
#include <linux/ratelimit.h>
#include "internal.h"
#include "mount.h"
+#include "union.h"

/*
* Usage:
@@ -316,6 +317,7 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent)
if (parent)
spin_unlock(&parent->d_lock);
dentry_iput(dentry);
+ d_free_unions(dentry);
/*
* dentry_iput drops the locks, at which point nobody (except
* transient RCU lookups) can reach this dentry.
@@ -907,6 +909,7 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
iput(inode);
}

+ d_free_unions(dentry);
d_free(dentry);

/* finished when we fall off the top of the tree,
@@ -2009,6 +2012,7 @@ again:
}
dentry->d_flags &= ~DCACHE_CANT_MOUNT;
dentry_unlink_inode(dentry);
+ d_free_unions(dentry);
fsnotify_nameremove(dentry, isdir);
return;
}
@@ -2018,6 +2022,12 @@ again:

spin_unlock(&dentry->d_lock);

+ /* Remove any associated unions. While someone still has this
+ * directory open (ref count > 0), we could not have deleted it unless
+ * it was empty, and therefore has no references to directories below
+ * it. So we don't need the unions.
+ */
+ d_free_unions(dentry);
fsnotify_nameremove(dentry, isdir);
}
EXPORT_SYMBOL(d_delete);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/