From: Pavel Emelyanov <xemul@parallels.com>
To: Hugh Dickins <hughd@google.com>, Nick Piggin <npiggin@kernel.dk>,
Andrea Arcangeli <aarcange@redhat.com>,
Rik van Riel <riel@redhat.com>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Alexa
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 13/13] vfs: Dentry mobs listing in proc
Date: Tue, 03 May 2011 16:20:30 +0400 [thread overview]
Message-ID: <4DBFF30E.8000409@parallels.com> (raw)
In-Reply-To: <4DBFF1AD.90303@parallels.com>
The /proc/dentry_mobs file lists the device the mob is located on,
the path to the dentry (starting from the device root) its usage and
size.
I tried to make it very simple, as this API is not perfect from my
POV and will most likely be rewritten. For the same reason (simplicity)
the dentry_path is used, not the full path to the root.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
fs/dcache.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
fs/proc/root.c | 3 ++
include/linux/dcache.h | 2 +
3 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 01e3464..c1120b3 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3028,6 +3028,7 @@ int dcache_new_mob(struct dentry *root)
spin_unlock(&root->d_lock);
spin_lock(&dcache_mobs_lock);
+ dmob->mob_root = root;
list_add(&dmob->mobs, &dentry_mobs);
dentry_mobs_nr++;
spin_unlock(&dcache_mobs_lock);
@@ -3068,6 +3069,63 @@ int dcache_get_mob_stat(struct dentry *de, struct dentry_mob_stat __user *stat)
return 0;
}
+static int dentry_mobs_show(struct seq_file *f, void *v)
+{
+ struct dentry_mob *dmob;
+
+ dmob = list_entry(v, struct dentry_mob, mobs);
+ if (dmob == &init_dentry_mob)
+ seq_putc(f, '/');
+ else {
+ struct dentry *root = dmob->mob_root;
+
+ seq_printf(f, "%u:%u ", MAJOR(root->d_sb->s_dev),
+ MINOR(root->d_sb->s_dev));
+ seq_dentry(f, root, " \t\n\\");
+ }
+
+ seq_printf(f, " %lu %lu\n",
+ (unsigned long)percpu_counter_sum_positive(&dmob->nr_dentry),
+ dmob->nr_dentry_max);
+
+ return 0;
+}
+
+static void *dentry_mobs_start(struct seq_file *f, loff_t *pos)
+{
+ spin_lock(&dcache_mobs_lock);
+ return seq_list_start(&dentry_mobs, *pos);
+}
+
+static void *dentry_mobs_next(struct seq_file *f, void *v, loff_t *pos)
+{
+ return seq_list_next(v, &dentry_mobs, pos);
+}
+
+static void dentry_mobs_stop(struct seq_file *f, void *v)
+{
+ spin_unlock(&dcache_mobs_lock);
+}
+
+static const struct seq_operations dentry_mobs_ops = {
+ .start = dentry_mobs_start,
+ .next = dentry_mobs_next,
+ .stop = dentry_mobs_stop,
+ .show = dentry_mobs_show
+};
+
+static int dentry_mobs_open(struct inode *inode, struct file *filp)
+{
+ return seq_open(filp, &dentry_mobs_ops);
+}
+
+const struct file_operations proc_dentry_mobs_fops = {
+ .open = dentry_mobs_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
static __initdata unsigned long dhash_entries;
static int __init set_dhash_entries(char *str)
{
diff --git a/fs/proc/root.c b/fs/proc/root.c
index ef9fa8e..e4d4983 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -18,6 +18,7 @@
#include <linux/bitops.h>
#include <linux/mount.h>
#include <linux/pid_namespace.h>
+#include <linux/dcache.h>
#include "internal.h"
@@ -133,6 +134,8 @@ void __init proc_root_init(void)
proc_device_tree_init();
#endif
proc_mkdir("bus", NULL);
+
+ proc_create("dentry_mobs", S_IRUGO, NULL, &proc_dentry_mobs_fops);
proc_sys_init();
}
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 7b1fdc1..8a9a5a5 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -53,6 +53,7 @@ struct dentry_mob {
unsigned long nr_dentry_max;
struct list_head dentry_lru;
struct list_head mobs;
+ struct dentry *mob_root;
};
struct dentry;
@@ -64,6 +65,7 @@ struct dentry_mob_stat {
int dcache_new_mob(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);
+extern const struct file_operations proc_dentry_mobs_fops;
/*
* Compare 2 name strings, return 0 if they match, otherwise non-zero.
--
1.5.5.6
next prev parent reply other threads:[~2011-05-03 12:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-03 12:14 [RFC][PATCH 0/13] Per-container dcache management (and a bit more) Pavel Emelyanov
2011-05-03 12:15 ` [PATCH 1/13] vfs: Lighten r/o rename_lock lockers Pavel Emelyanov
2011-05-03 12:15 ` [PATCH 2/13] vfs: Factor out rename_lock locking Pavel Emelyanov
2011-05-03 12:16 ` [PATCH 3/13] vfs: Make the rename_lock per-sb Pavel Emelyanov
2011-05-03 12:16 ` [PATCH 4/13] vfs: Factor out tree (of four) shrinkers code Pavel Emelyanov
2011-05-03 12:17 ` [PATCH 5/13] vfs: Make dentry LRU list global Pavel Emelyanov
2011-05-03 12:17 ` [PATCH 6/13] vfs: Turn the nr_dentry into percpu_counter Pavel Emelyanov
2011-05-03 12:18 ` [PATCH 7/13] vfs: Limit the number of dentries globally Pavel Emelyanov
2011-05-03 12:18 ` [PATCH 8/13] vfs: Introduce the dentry mobs Pavel Emelyanov
2011-06-18 13:40 ` Andrea Arcangeli
2011-05-03 12:18 ` [PATCH 9/13] vfs: More than one mob management Pavel Emelyanov
2011-05-03 12:19 ` [PATCH 10/13] vfs: Routnes for setting mob size and getting stats Pavel Emelyanov
2011-05-03 12:19 ` [PATCH 11/13] vfs: Make shrink_dcache_memory prune dcache from all mobs Pavel Emelyanov
2011-05-03 12:20 ` [PATCH 12/13] vfs: Mobs creation and mgmt API Pavel Emelyanov
2011-05-03 12:20 ` Pavel Emelyanov [this message]
2011-05-06 1:05 ` [RFC][PATCH 0/13] Per-container dcache management (and a bit more) Dave Chinner
2011-05-06 12:15 ` Pavel Emelyanov
2011-05-07 0:01 ` Dave Chinner
2011-05-10 11:18 ` Pavel Emelyanov
2011-06-18 13:30 ` Andrea Arcangeli
2011-06-20 0:49 ` Dave Chinner
2011-07-04 5:32 ` Pavel Emelyanov
2011-05-23 6:43 ` Pavel Emelyanov
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=4DBFF30E.8000409@parallels.com \
--to=xemul@parallels.com \
--cc=aarcange@redhat.com \
--cc=dave@linux.vnet.ibm.com \
--cc=hughd@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=npiggin@kernel.dk \
--cc=riel@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.