[PATCH 20/38] union-mount: Free union dirs on removal from dcache

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Valerie Aurora
Date: Tuesday, June 15, 2010 - 11:39 am

If a dentry is removed from dentry cache because its usage count drops
to zero, the union_dirs in its union stack are freed too.
---
 fs/dcache.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 54ff5a3..ce54dc5 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -34,6 +34,7 @@
 #include <linux/fs_struct.h>
 #include <linux/hardirq.h>
 #include "internal.h"
+#include "union.h"
 
 int sysctl_vfs_cache_pressure __read_mostly = 100;
 EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
@@ -175,6 +176,7 @@ static struct dentry *d_kill(struct dentry *dentry)
 	dentry_stat.nr_dentry--;	/* For d_free, below */
 	/*drops the locks, at that point nobody can reach this dentry */
 	dentry_iput(dentry);
+	d_free_unions(dentry);
 	if (IS_ROOT(dentry))
 		parent = NULL;
 	else
@@ -696,6 +698,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,
@@ -1535,6 +1538,7 @@ void d_delete(struct dentry * dentry)
 	isdir = S_ISDIR(dentry->d_inode->i_mode);
 	if (atomic_read(&dentry->d_count) == 1) {
 		dentry_iput(dentry);
+		d_free_unions(dentry);
 		fsnotify_nameremove(dentry, isdir);
 		return;
 	}
@@ -1545,6 +1549,13 @@ void d_delete(struct dentry * dentry)
 	spin_unlock(&dentry->d_lock);
 	spin_unlock(&dcache_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);
-- 
1.6.3.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/38] Union mounts - union stack as linked list, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 01/38] VFS: Comment follow_mount() and friends, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 02/38] VFS: Make lookup_hash() return a struct path, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 03/38] VFS: Add read-only users count to superblock, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 09/38] whiteout: tmpfs whiteout support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 11/38] whiteout: ext2 whiteout support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 12/38] whiteout: jffs2 whiteout support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 16/38] fallthru: tmpfs fallthru support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 17/38] union-mount: Union mounts documentation, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 20/38] union-mount: Free union dirs on removal from ..., Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 22/38] union-mount: Implement union lookup, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 27/38] union-mount: In-kernel file copyup routines, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 29/38] union-mount: Implement union-aware link(), Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 30/38] union-mount: Implement union-aware rename(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 32/38] union-mount: Implement union-aware chown(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 33/38] union-mount: Implement union-aware truncate(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 35/38] union-mount: Implement union-aware lchown(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 36/38] union-mount: Implement union-aware utimensat(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 37/38] union-mount: Implement union-aware setxattr(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 38/38] union-mount: Implement union-aware lsetxattr(), Valerie Aurora, (Tue Jun 15, 11:40 am)
Re: [PATCH 17/38] union-mount: Union mounts documentation, Valerie Aurora, (Thu Jun 17, 11:39 am)
Re: [PATCH 17/38] union-mount: Union mounts documentation, Valerie Aurora, (Fri Jun 18, 2:06 pm)
Re: [PATCH 17/38] union-mount: Union mounts documentation, Miklos Szeredi, (Mon Jun 21, 6:14 am)
Re: [PATCH 17/38] union-mount: Union mounts documentation, Valerie Aurora, (Mon Jun 21, 4:17 pm)
Re: [PATCH 11/38] whiteout: ext2 whiteout support, Ian Kent, (Mon Jul 12, 9:24 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Ian Kent, (Mon Jul 12, 9:30 pm)
Re: [PATCH 22/38] union-mount: Implement union lookup, Valerie Aurora, (Mon Jul 19, 2:58 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Wed Aug 4, 7:44 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Wed Aug 4, 3:48 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Thu Aug 5, 3:36 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Thu Aug 5, 4:13 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Thu Aug 5, 4:30 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Fri Aug 6, 10:12 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Fri Aug 6, 10:16 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Fri Aug 6, 10:44 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Tue Aug 17, 3:27 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Wed Aug 18, 1:26 am)