From: zwu.kernel@gmail.com
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linuxram@linux.vnet.ibm.com,
viro@zeniv.linux.org.uk, cmm@us.ibm.com, tytso@mit.edu,
Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Subject: [RFC v1 05/11] vfs: add one new mount option '-o hottrack'
Date: Mon, 17 Sep 2012 15:18:39 +0800 [thread overview]
Message-ID: <1347866325-25979-6-git-send-email-zwu.kernel@gmail.com> (raw)
In-Reply-To: <1347866325-25979-1-git-send-email-zwu.kernel@gmail.com>
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Introduce one new mount option '-o hottrack',
and add its parsing support.
Its usage looks like:
mount -o hottrack
mount -o nouser,hottrack
mount -o nouser,hottrack,loop
mount -o hottrack,nouser
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
fs/hot_track.c | 34 ++++++++++++++++++++++++++++++++++
fs/hot_track.h | 1 +
fs/super.c | 5 +++++
include/linux/hot_track.h | 6 ++++++
4 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/fs/hot_track.c b/fs/hot_track.c
index 064c7dc..b3f01a1 100644
--- a/fs/hot_track.c
+++ b/fs/hot_track.c
@@ -16,6 +16,40 @@
#include "hot_track.h"
/*
+ * Regular mount options parser for -hottrack option.
+ * return false if no -hottrack is specified;
+ * otherwise return true. And the -hottrack will be
+ * removed from options.
+ */
+bool hot_track_parse_options(char *options)
+{
+ long len;
+ char *p;
+ static char opts_hot[] = "hottrack";
+
+ if (!options)
+ return false;
+
+ p = strstr(options, opts_hot);
+ if (!p)
+ return false;
+
+ while (p) {
+ len = options + strlen(options) - (p + strlen(opts_hot));
+ if (len == 0) {
+ options[0] = '\0';
+ break;
+ }
+
+ memmove(p, p + strlen(opts_hot) + 1, len);
+ p = strstr(options, opts_hot);
+ }
+
+ printk(KERN_INFO "vfs: turning on hot data tracking\n");
+ return true;
+}
+
+/*
* Initialize kmem cache for hot_inode_item
* and hot_range_item
*/
diff --git a/fs/hot_track.h b/fs/hot_track.h
index 9a52945..a099b43 100644
--- a/fs/hot_track.h
+++ b/fs/hot_track.h
@@ -15,6 +15,7 @@
#include "hot_rb.h"
+bool hot_track_parse_options(char *options);
void __init hot_track_kmem_cache_init(void);
#endif /* __HOT_TRACK__ */
diff --git a/fs/super.c b/fs/super.c
index 0902cfa..d5bc781 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -35,6 +35,7 @@
#include <linux/fsnotify.h>
#include <linux/lockdep.h>
#include "internal.h"
+#include "hot_track.h"
LIST_HEAD(super_blocks);
@@ -1125,6 +1126,7 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
struct dentry *root;
struct super_block *sb;
char *secdata = NULL;
+ bool hottrack = false;
int error = -ENOMEM;
if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) {
@@ -1137,6 +1139,9 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
goto out_free_secdata;
}
+ if (data && hot_track_parse_options(data))
+ hottrack = true;
+
root = type->mount(type, flags, name, data);
if (IS_ERR(root)) {
error = PTR_ERR(root);
diff --git a/include/linux/hot_track.h b/include/linux/hot_track.h
index 2256496..b56a467 100644
--- a/include/linux/hot_track.h
+++ b/include/linux/hot_track.h
@@ -20,6 +20,11 @@
#include <linux/rbtree.h>
#include <linux/kref.h>
+/*
+ * Flags for hot data tracking mount options.
+ */
+#define HOT_MOUNT_HOT_TRACK (1 << 0)
+
/* A tree that sits on the hot_info */
struct hot_inode_tree {
struct rb_root map;
@@ -89,6 +94,7 @@ struct hot_range_item {
};
struct hot_info {
+ unsigned long mount_opt;
/* red-black tree that keeps track of fs-wide hot data */
struct hot_inode_tree hot_inode_tree;
--
1.7.6.5
next prev parent reply other threads:[~2012-09-17 7:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-17 7:18 [RFC v1 00/11] vfs: hot data tracking zwu.kernel
2012-09-17 7:18 ` [RFC v1 01/11] vfs: introduce one structure hot_info zwu.kernel
2012-09-17 7:18 ` [RFC v1 02/11] vfs: introduce one rb tree - hot_inode_tree zwu.kernel
2012-09-17 7:18 ` [RFC v1 03/11] vfs: introduce 2 rb tree items - inode and range zwu.kernel
2012-09-17 7:18 ` [RFC v1 04/11] vfs: add support for updating access frequency zwu.kernel
2012-09-17 7:18 ` zwu.kernel [this message]
2012-09-17 7:18 ` [RFC v1 06/11] vfs: add init and exit support zwu.kernel
2012-09-17 7:18 ` [RFC v1 07/11] vfs: introduce one hash table zwu.kernel
2012-09-17 7:18 ` [RFC v1 08/11] vfs: enable hot data tracking zwu.kernel
2012-09-17 7:18 ` [RFC v1 09/11] vfs: fork one private kthread to update temperature info zwu.kernel
2012-09-17 7:18 ` [RFC v1 10/11] vfs: add 3 new ioctl interfaces zwu.kernel
2012-09-17 7:18 ` [RFC v1 11/11] vfs: add debugfs support zwu.kernel
2012-09-17 9:45 ` [RFC v1 00/11] vfs: hot data tracking Marco Stornelli
2012-09-17 13:24 ` Zhi Yong Wu
2012-09-17 21:30 ` Dave Chinner
2012-09-18 2:24 ` Zhi Yong Wu
2012-09-18 6:20 ` Dave Chinner
2012-09-18 6:44 ` Zhi Yong Wu
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=1347866325-25979-6-git-send-email-zwu.kernel@gmail.com \
--to=zwu.kernel@gmail.com \
--cc=cmm@us.ibm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxram@linux.vnet.ibm.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=wuzhy@linux.vnet.ibm.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.