[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1284675145-4391-13-git-send-email-vaurora@redhat.com>
Date: Thu, 16 Sep 2010 15:12:03 -0700
From: Valerie Aurora <vaurora@...hat.com>
To: Alexander Viro <viro@...iv.linux.org.uk>
Cc: Miklos Szeredi <miklos@...redi.hu>,
Christoph Hellwig <hch@...radead.org>,
Andreas Gruenbacher <agruen@...e.de>,
Nick Piggin <npiggin@...nel.dk>, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org, Valerie Aurora <vaurora@...hat.com>
Subject: [PATCH 12/34] union-mount: Create d_free_unions()
d_free_unions() frees the union stack associated with a directory.
Signed-off-by: Valerie Aurora <vaurora@...hat.com>
---
fs/union.c | 25 +++++++++++++++++++++++++
fs/union.h | 7 +++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/fs/union.c b/fs/union.c
index 52a5c28..a191bef 100644
--- a/fs/union.c
+++ b/fs/union.c
@@ -21,6 +21,7 @@
#include <linux/mount.h>
#include <linux/fs_struct.h>
#include <linux/slab.h>
+#include <linux/namei.h>
#include "union.h"
@@ -40,3 +41,27 @@ static struct union_stack *union_alloc(struct path *topmost)
return kzalloc(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 e242451..353f78d 100644
--- a/fs/union.h
+++ b/fs/union.h
@@ -49,6 +49,10 @@ struct union_stack {
struct path u_dirs[0];
};
+#define IS_DIR_UNIONED(dentry) ((dentry)->d_union_stack)
+
+extern void d_free_unions(struct dentry *);
+
static inline struct path *union_find_dir(struct dentry *dentry,
unsigned int layer) {
BUG_ON(layer >= dentry->d_sb->s_union_count);
@@ -57,6 +61,9 @@ static inline struct path *union_find_dir(struct dentry *dentry,
#else /* CONFIG_UNION_MOUNT */
+#define IS_DIR_UNIONED(x) (0)
+
+#define d_free_unions(x) do { } while (0)
#define union_find_dir(x, y) ({ BUG(); (NULL); })
#endif /* CONFIG_UNION_MOUNT */
--
1.6.3.3
--
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