From: Valerie Aurora <valerie.aurora@gmail.com>
To: linux-fsdevel@vger.kernel.org, linux@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, Valerie Aurora <vaurora@redhat.com>,
Valerie Aurora <valerie.aurora@gmail.com>
Subject: [PATCH 28/74] union-mount: Add union_alloc()
Date: Tue, 22 Mar 2011 18:59:04 -0700 [thread overview]
Message-ID: <1300845590-14184-29-git-send-email-valerie.aurora@gmail.com> (raw)
In-Reply-To: <1300845590-14184-1-git-send-email-valerie.aurora@gmail.com>
From: Valerie Aurora <vaurora@redhat.com>
union_alloc() allocates a union stack with enough entries for the
maximum possible number of directories that might be unioned at this
point.
The union_stack may be larger than strictly necessary if this
directory does not exist on all layers, but allocating exactly the
right number would require keeping the number of layers in the
union_stack structure. We optimize for the case of unioning two file
systems and keep the count of layers in the superblock.
Signed-off-by: Valerie Aurora <valerie.aurora@gmail.com>
---
fs/Makefile | 1 +
fs/union.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/fs/Makefile b/fs/Makefile
index e6ec1d3..936acf0 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_NFS_COMMON) += nfs_common/
obj-$(CONFIG_GENERIC_ACL) += generic_acl.o
obj-y += quota/
+obj-$(CONFIG_UNION_MOUNT) += union.o
obj-$(CONFIG_PROC_FS) += proc/
obj-y += partitions/
diff --git a/fs/union.c b/fs/union.c
new file mode 100644
index 0000000..52a5c28
--- /dev/null
+++ b/fs/union.c
@@ -0,0 +1,42 @@
+ /*
+ * VFS-based union mounts for Linux
+ *
+ * Copyright (C) 2004-2007 IBM Corporation, IBM Deutschland Entwicklung GmbH.
+ * Copyright (C) 2007-2009 Novell Inc.
+ * Copyright (C) 2009-2010 Red Hat, Inc.
+ *
+ * Author(s): Jan Blunck (j.blunck@tu-harburg.de)
+ * Valerie Aurora <vaurora@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+
+#include <linux/bootmem.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/mount.h>
+#include <linux/fs_struct.h>
+#include <linux/slab.h>
+
+#include "union.h"
+
+/**
+ * union_alloc - allocate a union stack
+ *
+ * @path: path of topmost directory
+ *
+ * Allocate a union_stack large enough to contain the maximum number
+ * of layers in this union mount.
+ */
+
+static struct union_stack *union_alloc(struct path *topmost)
+{
+ unsigned int layers = topmost->dentry->d_sb->s_union_count;
+ BUG_ON(!S_ISDIR(topmost->dentry->d_inode->i_mode));
+
+ return kzalloc(sizeof(struct path) * layers, GFP_KERNEL);
+}
--
1.7.0.4
next prev parent reply other threads:[~2011-03-23 2:01 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-23 1:58 [PATCH 00/74] Union mounts version something or other Valerie Aurora
2011-03-23 1:58 ` [PATCH 01/74] VFS: Comment follow_mount() and friends Valerie Aurora
2011-03-23 1:58 ` [PATCH 02/74] VFS: Make lookup_hash() return a struct path Valerie Aurora
2011-03-23 1:58 ` [PATCH 03/74] autofs4: Save autofs trigger's vfsmount in super block info Valerie Aurora
2011-03-23 1:58 ` [PATCH 04/74] Documentation: Fix trivial typo in filesystems/sharedsubtree.txt Valerie Aurora
2011-03-23 1:58 ` [PATCH 05/74] whiteout/NFSD: Don't return information about whiteouts to userspace Valerie Aurora
2011-03-23 1:58 ` [PATCH 06/74] whiteout: Define opaque inode flags and operations Valerie Aurora
2011-03-23 1:58 ` [PATCH 07/74] whiteout: Add vfs_whiteout() and whiteout inode operation Valerie Aurora
2011-03-23 1:58 ` [PATCH 08/74] whiteout: Allow removal of a directory with whiteouts Valerie Aurora
2011-03-23 1:58 ` [PATCH 09/74] whiteout: tmpfs whiteout support Valerie Aurora
2011-03-23 1:58 ` [PATCH 10/74] ext2: Add ext2_dirent_in_use() Valerie Aurora
2011-03-23 1:58 ` [PATCH 11/74] ext2: Split ext2_add_entry() from ext2_add_link() Valerie Aurora
2011-03-23 1:58 ` [PATCH 12/74] whiteout: ext2 whiteout support Valerie Aurora
2011-03-23 1:58 ` [PATCH 13/74] whiteout: jffs2 " Valerie Aurora
2011-03-23 1:58 ` [PATCH 14/74] fallthru: Basic fallthru definitions Valerie Aurora
2011-03-23 1:58 ` [PATCH 15/74] fallthru: ext2 fallthru support Valerie Aurora
2011-03-23 1:58 ` [PATCH 16/74] fallthru: tmpfs " Valerie Aurora
2011-03-23 1:58 ` [PATCH 17/74] fallthru: jffs2 " Valerie Aurora
2011-03-23 1:58 ` [PATCH 18/74] VFS: Add hard read-only users count to superblock Valerie Aurora
2011-03-23 1:58 ` [PATCH 19/74] VFS: Make clone_mnt()/copy_tree()/collect_mounts() return errors Valerie Aurora
2011-03-23 1:58 ` [PATCH 20/74] VFS: Add CL_NO_SHARED flag to clone_mnt()/copy_tree() Valerie Aurora
2011-03-23 1:58 ` [PATCH 21/74] VFS: Add CL_NO_SLAVE " Valerie Aurora
2011-03-23 1:58 ` [PATCH 22/74] VFS: Add CL_MAKE_HARD_READONLY " Valerie Aurora
2011-03-23 1:58 ` [PATCH 23/74] union-mount: Union mounts documentation Valerie Aurora
2011-03-23 1:59 ` [PATCH 24/74] union-mount: Introduce MNT_UNION and MS_UNION flags Valerie Aurora
2011-03-23 1:59 ` [PATCH 25/74] union-mount: Add CONFIG_UNION_MOUNT option Valerie Aurora
2011-03-23 1:59 ` [PATCH 26/74] union-mount: Create union_stack structure Valerie Aurora
2011-03-23 1:59 ` [PATCH 27/74] union-mount: Add two superblock fields for union mounts Valerie Aurora
2011-03-23 1:59 ` Valerie Aurora [this message]
2011-03-23 1:59 ` [PATCH 29/74] union-mount: Add union_find_dir() Valerie Aurora
2011-03-23 1:59 ` [PATCH 30/74] union-mount: Create d_free_unions() Valerie Aurora
2011-03-23 1:59 ` [PATCH 31/74] union-mount: Free union stack on removal of topmost dentry from dcache Valerie Aurora
2011-03-23 1:59 ` [PATCH 32/74] union-mount: Create union_add_dir() Valerie Aurora
2011-03-23 1:59 ` [PATCH 33/74] union-mount: Add union_create_topmost_dir() Valerie Aurora
2011-03-23 1:59 ` [PATCH 34/74] union-mount: Create IS_MNT_UNION() Valerie Aurora
2011-03-23 1:59 ` [PATCH 35/74] union-mount: Create needs_lookup_union() Valerie Aurora
2011-03-23 1:59 ` [PATCH 36/74] union-mount: Create check_topmost_union_mnt() Valerie Aurora
2011-03-23 1:59 ` [PATCH 37/74] union-mount: Add clone_union_tree() and put_union_sb() Valerie Aurora
2011-03-23 1:59 ` [PATCH 38/74] union-mount: Create build_root_union() Valerie Aurora
2011-03-23 1:59 ` [PATCH 39/74] union-mount: Create prepare_mnt_union() and cleanup_mnt_union() Valerie Aurora
2011-03-23 1:59 ` [PATCH 40/74] union-mount: Prevent improper union-related remounts Valerie Aurora
2011-03-23 1:59 ` [PATCH 41/74] union-mount: Prevent topmost file system from being mounted elsewhere Valerie Aurora
2011-03-23 1:59 ` [PATCH 42/74] union-mount: Prevent bind mounts of union mounts Valerie Aurora
2011-03-23 1:59 ` [PATCH 43/74] union-mount: Implement union mount Valerie Aurora
2011-03-23 1:59 ` [PATCH 44/74] union-mount: Temporarily disable some syscalls Valerie Aurora
2011-03-23 2:12 ` [PATCH 00/74] Union mounts version something or other Valerie Aurora
2011-03-24 13:43 ` Union mounts comparison with overlay file system prototype? Ric Wheeler
2011-03-25 11:38 ` Szeredi Miklos
2011-03-25 12:12 ` Ric Wheeler
2011-03-23 8:38 ` [PATCH 00/74] Union mounts version something or other Sedat Dilek
2011-03-24 22:40 ` Ben Hutchings
2011-03-25 2:32 ` Sedat Dilek
2011-03-30 14:30 ` David Howells
2011-04-01 16:48 ` Valerie Aurora
2011-04-21 13:09 ` David Howells
2011-04-24 21:48 ` Valerie Aurora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1300845590-14184-29-git-send-email-valerie.aurora@gmail.com \
--to=valerie.aurora@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux@vger.kernel.org \
--cc=vaurora@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).