[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120221180040.25235.53816.stgit@warthog.procyon.org.uk>
Date: Tue, 21 Feb 2012 18:00:41 +0000
From: David Howells <dhowells@...hat.com>
To: linux-fsdevel@...r.kernel.org, viro@...IV.linux.org.uk,
valerie.aurora@...il.com
Cc: linux-kernel@...r.kernel.org, David Howells <dhowells@...hat.com>
Subject: [PATCH 25/73] union-mount: Create d_free_unions() [ver #2]
From: Valerie Aurora <vaurora@...hat.com>
d_free_unions() frees the union stack associated with a directory.
Original-author: Valerie Aurora <vaurora@...hat.com>
Signed-off-by: David Howells <dhowells@...hat.com>
---
fs/union.c | 24 ++++++++++++++++++++++++
fs/union.h | 10 ++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/fs/union.c b/fs/union.c
index c8d7766..77d6a74 100644
--- a/fs/union.c
+++ b/fs/union.c
@@ -19,6 +19,7 @@
#include <linux/mount.h>
#include <linux/fs_struct.h>
#include <linux/slab.h>
+#include <linux/namei.h>
#include "union.h"
@@ -36,3 +37,26 @@ static struct union_stack *union_alloc(struct path *topmost)
return kcalloc(sizeof(struct path), layers, GFP_KERNEL);
}
+
+/**
+ * d_free_unions - free all unions for this dentry
+ * @dentry: topmost dentry in the union stack to remove
+ *
+ * This must be called when freeing a dentry.
+ */
+void d_free_unions(struct dentry *topmost)
+{
+ struct path *path;
+ unsigned int i, layers = topmost->d_sb->s_union_count;
+
+ if (!IS_DIR_UNIONED(topmost))
+ return;
+
+ for (i = 0; i < layers; i++) {
+ path = union_find_dir(topmost, i);
+ if (path->mnt)
+ path_put(path);
+ }
+ kfree(topmost->d_union_stack);
+ topmost->d_union_stack = NULL;
+}
diff --git a/fs/union.h b/fs/union.h
index f90d037..04a02ec 100644
--- a/fs/union.h
+++ b/fs/union.h
@@ -51,6 +51,13 @@ struct union_stack {
struct path u_dirs[0];
};
+static inline bool IS_DIR_UNIONED(struct dentry *dentry)
+{
+ return !!dentry->d_union_stack;
+}
+
+extern void d_free_unions(struct dentry *);
+
static inline
struct path *union_find_dir(struct dentry *dentry, unsigned int layer)
{
@@ -67,4 +74,7 @@ struct path *union_find_dir(struct dentry *dentry, unsigned int layer)
return NULL;
}
+static inline bool IS_DIR_UNIONED(struct dentry *dentry) { return false; }
+static inline void d_free_unions(struct dentry *dentry) {}
+
#endif /* CONFIG_UNION_MOUNT */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists