linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/5] Interface proposal for dentry grouping
@ 2011-07-25 15:16 Glauber Costa
  2011-07-25 15:16 ` [RFC 1/5] Accept per-mntpoint named options Glauber Costa
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Glauber Costa @ 2011-07-25 15:16 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Pavel Emelyanov, Al Viro, Hugh Dickins, Nick Piggin,
	Andrea Arcangeli, Rik van Riel, Dave Hansen, David Chinner,
	Glauber Costa

Hello folks,

If you would remember, Pavel recently posted a series proposing a way 
of grouping entries in the dcache, in order to in the future limit the
per-container dcache size growth
(http://article.gmane.org/gmane.linux.file-systems/53346).

At the time, a proper interface for proper operation of those entities was
missing. This patchset contains my proposal on how to do so. Note that I am not
reposting Pavel original series (+ changes) this time. This is on purpose, since
I want to focus on the interface here.

So here's briefly what I am proposing:

* dentry groups are created per-mntpoint. Combined with our ability to bind mount,
  this means that we can specify a dentry group root to be at any arbitrary point
  of the filesystem.
* Also, per-mntpoint also ties the dentry groups to a fs-independent entity, 
  instead of a super-block, which is tied to a filesystem / real mount.
* Any mount helper is able to pass arbitrary strings to mount(). I build on it by
  allowing the generic vfs code to parse these options. A reference to a super
  block is hard to obtain at this point, which is one more reason (given of course
  this interface will be liked) to tie this to a mntpoint, not sb.
* Although options to the vfs are a new thing introduced here, mount() is a natural way
  to specify attributes of a filesystem hierarchy, I believe.

Glauber Costa (5):
  Accept per-mntpoint named options
  introduce dentry_is_mob_root
  parse options at mount operation
  destroy 0-sized mobs
  save mnt info in do_loopback.

 fs/dcache.c            |   11 ++++++
 fs/namespace.c         |   84 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/dcache.h |    1 +
 include/linux/mount.h  |    2 +
 4 files changed, 98 insertions(+), 0 deletions(-)

-- 
1.7.5.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC 1/5] Accept per-mntpoint named options
  2011-07-25 15:16 [RFC 0/5] Interface proposal for dentry grouping Glauber Costa
@ 2011-07-25 15:16 ` Glauber Costa
  2011-07-25 15:16 ` [RFC 2/5] introduce dentry_is_mob_root Glauber Costa
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Glauber Costa @ 2011-07-25 15:16 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Pavel Emelyanov, Al Viro, Hugh Dickins, Nick Piggin,
	Andrea Arcangeli, Rik van Riel, Dave Hansen, David Chinner,
	Glauber Costa

This is the core patch of the proposed interface.
It basically consists of an option parser much like the one
some filesystems, like for instance the ext family, ships.
It does, however, have two fundamental differences:
 * Since it is generic, it does not operate on a super block. Rather, a
   mountpoint, which is a file-system independent entity, is its argument.
   Per-mntpoint options are expected to be tweaked here.
 * It modifies the option string to remove whatever option it handled. This
   allow us to chain this parser with whatever parser the underlying filesystem
   may have.

Its first option is vfs_dcache_size. It specifies how many dentries are allowed
to exist at any given time in the dentry group that lives in this mount point.

---
 fs/namespace.c        |   65 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mount.h |    2 +
 2 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index dffe6f4..3ccd264 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -33,6 +33,7 @@
 #include <linux/fsnotify.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
+#include <linux/parser.h>
 #include "pnode.h"
 #include "internal.h"
 
@@ -2190,6 +2191,70 @@ int copy_mount_string(const void __user *data, char **where)
 	return 0;
 }
 
+static const match_table_t tokens = {
+	{1, "vfs_dcache_size=%u"},
+};
+
+int vfs_parse_options(char *options, struct vfsmount *mnt)
+{
+	substring_t args[MAX_OPT_ARGS];
+	unsigned int option;
+	char *p;
+	char *opt;
+	char *start = NULL;
+	
+	/* FIXME: remove options from original string */
+	if (!options)
+		return 1;
+
+	opt = kstrdup(options, GFP_KERNEL);
+	if (!opt)
+		return 0;
+	
+	start = opt;
+
+	while ((p = strsep(&opt, ",")) != NULL) {
+		int token;
+		if (!*p)
+			continue;
+
+		/*
+		 * Initialize args struct so we know whether arg was
+		 * found; some options take optional arguments.
+		 */
+		args[0].to = args[0].from = 0;
+		token = match_token(p, tokens, args);
+		switch (token) {
+		case 1:
+			if (args[0].from) {
+				if (match_int(&args[0], &option)) {
+					break;
+				}
+				else {
+					mnt->dcache_size = option;
+				}
+			}
+			else {
+				printk("did not give an option\n");
+				break;
+			}
+
+			if (!opt) /* it is the last option listed */
+				*(options + (p - start)) = '\0';
+			else
+				strcpy(options + (p - start), opt);
+			break;
+		default:
+			break;
+		}
+	}
+	kfree(start);
+
+	return 0;
+}
+
+
+
 /*
  * Flags is a 32-bit value that allows up to 31 non-fs dependent flags to
  * be given to the mount() call (ie: read-only, no-dev, no-suid etc).
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 604f122..cf50da2 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -86,6 +86,8 @@ struct vfsmount {
 	int mnt_expiry_mark;		/* true if marked for expiry */
 	int mnt_pinned;
 	int mnt_ghosts;
+
+	unsigned int dcache_size;
 };
 
 struct file; /* forward dec */
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC 2/5] introduce dentry_is_mob_root
  2011-07-25 15:16 [RFC 0/5] Interface proposal for dentry grouping Glauber Costa
  2011-07-25 15:16 ` [RFC 1/5] Accept per-mntpoint named options Glauber Costa
@ 2011-07-25 15:16 ` Glauber Costa
  2011-07-25 15:16 ` [RFC 3/5] parse options at mount operation Glauber Costa
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Glauber Costa @ 2011-07-25 15:16 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Pavel Emelyanov, Al Viro, Hugh Dickins, Nick Piggin,
	Andrea Arcangeli, Rik van Riel, Dave Hansen, David Chinner,
	Glauber Costa

Very simple function to test if a given dentry is the root of
a dentry group (mob)

---
 fs/dcache.c            |    6 ++++++
 include/linux/dcache.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 39db354..0960b80 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3000,6 +3000,12 @@ rename_retry:
 	goto again;
 }
 
+
+int dentry_is_mob_root(struct dentry *root)
+{
+	return (root->d_flags & DCACHE_MOB_ROOT);
+}
+
 int dcache_new_mob(struct dentry *root)
 {
 	struct dentry_mob *dmob, *old = NULL;
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 7b1fdc1..fd137c7 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -62,6 +62,7 @@ struct dentry_mob_stat {
 };
 
 int dcache_new_mob(struct dentry *root);
+int dentry_is_mob_root(struct dentry *root);
 int dcache_set_mob_size(struct dentry *de, unsigned long size);
 int dcache_get_mob_stat(struct dentry *de, struct dentry_mob_stat __user *stat);
 
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC 3/5] parse options at mount operation
  2011-07-25 15:16 [RFC 0/5] Interface proposal for dentry grouping Glauber Costa
  2011-07-25 15:16 ` [RFC 1/5] Accept per-mntpoint named options Glauber Costa
  2011-07-25 15:16 ` [RFC 2/5] introduce dentry_is_mob_root Glauber Costa
@ 2011-07-25 15:16 ` Glauber Costa
  2011-07-25 15:16 ` [RFC 4/5] destroy 0-sized mobs Glauber Costa
  2011-07-25 15:16 ` [RFC 5/5] save mnt info in do_loopback Glauber Costa
  4 siblings, 0 replies; 6+ messages in thread
From: Glauber Costa @ 2011-07-25 15:16 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Pavel Emelyanov, Al Viro, Hugh Dickins, Nick Piggin,
	Andrea Arcangeli, Rik van Riel, Dave Hansen, David Chinner,
	Glauber Costa

This patch presents a proposed use of the just introduced interface.
The caller is expected to have passed a vfs_dcache_size=%d option. If this is
not true, nothing should be changed.

If such an option is present, however, two things can happen:
* A new dentry group (mob) is created, rooted at the given mount point. It has
  the size specified in the arguments.
* An existing dentry group (mob) is modified, such that the argument passed reflects
  the new maximum number of dentries.

Note that the existance of bind mounts allow us to specify dentry groups starting
at any arbitrary point in the hierarchy.

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

diff --git a/fs/namespace.c b/fs/namespace.c
index 3ccd264..0d8a53b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2275,6 +2275,7 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
 	struct path path;
 	int retval = 0;
 	int mnt_flags = 0;
+	int dcache_size = 0;
 
 	/* Discard magic */
 	if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
@@ -2298,6 +2299,10 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
 	if (retval)
 		goto dput_out;
 
+
+	dcache_size = path.mnt->dcache_size;
+	vfs_parse_options(data_page, path.mnt);
+
 	/* Default to relatime unless overriden */
 	if (!(flags & MS_NOATIME))
 		mnt_flags |= MNT_RELATIME;
@@ -2334,6 +2339,17 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
 	else
 		retval = do_new_mount(&path, type_page, flags, mnt_flags,
 				      dev_name, data_page);
+
+
+	if (retval || !path.mnt->dcache_size)
+		goto dput_out;
+
+	if (!dentry_is_mob_root(path.mnt->mnt_mountpoint))
+		dcache_new_mob(path.mnt->mnt_mountpoint);
+	if (dcache_size != path.mnt->dcache_size)
+		dcache_set_mob_size(path.mnt->mnt_mountpoint, path.mnt->dcache_size);
+
+
 dput_out:
 	path_put(&path);
 	return retval;
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC 4/5] destroy 0-sized mobs
  2011-07-25 15:16 [RFC 0/5] Interface proposal for dentry grouping Glauber Costa
                   ` (2 preceding siblings ...)
  2011-07-25 15:16 ` [RFC 3/5] parse options at mount operation Glauber Costa
@ 2011-07-25 15:16 ` Glauber Costa
  2011-07-25 15:16 ` [RFC 5/5] save mnt info in do_loopback Glauber Costa
  4 siblings, 0 replies; 6+ messages in thread
From: Glauber Costa @ 2011-07-25 15:16 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Pavel Emelyanov, Al Viro, Hugh Dickins, Nick Piggin,
	Andrea Arcangeli, Rik van Riel, Dave Hansen, David Chinner,
	Glauber Costa

Our API should consider vfs_dcache_size=0 to mean that the dentry group should be
destroyed. Nothing else is meaningful.

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

diff --git a/fs/dcache.c b/fs/dcache.c
index 0960b80..c9e988d 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3044,6 +3044,11 @@ int dcache_set_mob_size(struct dentry *de, unsigned long size)
 	if (mob == &init_dentry_mob) /* for safety */
 		return 0;
 
+	if (size == 0) {
+		destroy_mob(de->d_mob);
+		return 0;
+	}
+
 	mob->nr_dentry_max = size;
 	usage = percpu_counter_sum_positive(&mob->nr_dentry);
 	if (usage > mob->nr_dentry_max)
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC 5/5] save mnt info in do_loopback.
  2011-07-25 15:16 [RFC 0/5] Interface proposal for dentry grouping Glauber Costa
                   ` (3 preceding siblings ...)
  2011-07-25 15:16 ` [RFC 4/5] destroy 0-sized mobs Glauber Costa
@ 2011-07-25 15:16 ` Glauber Costa
  4 siblings, 0 replies; 6+ messages in thread
From: Glauber Costa @ 2011-07-25 15:16 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Pavel Emelyanov, Al Viro, Hugh Dickins, Nick Piggin,
	Andrea Arcangeli, Rik van Riel, Dave Hansen, David Chinner,
	Glauber Costa

It is overwritten by a new mnt structure, so save it.

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

diff --git a/fs/namespace.c b/fs/namespace.c
index 0d8a53b..1a67f0d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1741,6 +1741,9 @@ static int do_loopback(struct path *path, char *old_name,
 		release_mounts(&umount_list);
 	}
 
+	mnt->dcache_size = path->mnt->dcache_size;
+	path->mnt = mnt;
+
 out:
 	up_write(&namespace_sem);
 	path_put(&old_path);
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-25 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-25 15:16 [RFC 0/5] Interface proposal for dentry grouping Glauber Costa
2011-07-25 15:16 ` [RFC 1/5] Accept per-mntpoint named options Glauber Costa
2011-07-25 15:16 ` [RFC 2/5] introduce dentry_is_mob_root Glauber Costa
2011-07-25 15:16 ` [RFC 3/5] parse options at mount operation Glauber Costa
2011-07-25 15:16 ` [RFC 4/5] destroy 0-sized mobs Glauber Costa
2011-07-25 15:16 ` [RFC 5/5] save mnt info in do_loopback Glauber Costa

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).