From patchwork Sun Sep 23 12:56:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 1495481 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CA624E006E for ; Sun, 23 Sep 2012 13:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753739Ab2IWM6S (ORCPT ); Sun, 23 Sep 2012 08:58:18 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:48033 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753803Ab2IWM5Q (ORCPT ); Sun, 23 Sep 2012 08:57:16 -0400 Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 23 Sep 2012 06:57:15 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 23 Sep 2012 06:57:12 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 979461FF0039; Sun, 23 Sep 2012 06:57:08 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8NCvC7P219618; Sun, 23 Sep 2012 06:57:12 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8NCvAjG007823; Sun, 23 Sep 2012 06:57:11 -0600 Received: from us.ibm.com (f15.cn.ibm.com [9.115.122.154]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q8NCv5ZQ007677; Sun, 23 Sep 2012 06:57:06 -0600 Received: by us.ibm.com (sSMTP sendmail emulation); Sun, 23 Sep 2012 20:56:55 +0800 From: zwu.kernel@gmail.com To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linuxram@linux.vnet.ibm.com, viro@zeniv.linux.org.uk, cmm@us.ibm.com, tytso@mit.edu, marco.stornelli@gmail.com, david@fromorbit.com, stroetmann@ontolinux.com, diegocg@gmail.com, chris@csamuel.org, Zhi Yong Wu Subject: [RFC v2 03/10] vfs: add one new mount option '-o hottrack' Date: Sun, 23 Sep 2012 20:56:28 +0800 Message-Id: <1348404995-14372-4-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1348404995-14372-1-git-send-email-zwu.kernel@gmail.com> References: <1348404995-14372-1-git-send-email-zwu.kernel@gmail.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12092312-7408-0000-0000-000008BA2488 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Zhi Yong Wu 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 --- fs/hot_tracking.c | 34 ++++++++++++++++++++++++++++++++++ fs/hot_tracking.h | 1 + fs/super.c | 5 +++++ include/linux/hot_tracking.h | 7 +++++++ 4 files changed, 47 insertions(+), 0 deletions(-) diff --git a/fs/hot_tracking.c b/fs/hot_tracking.c index 52ed926..f97e8a6 100644 --- a/fs/hot_tracking.c +++ b/fs/hot_tracking.c @@ -465,6 +465,40 @@ void hot_rb_update_freqs(struct inode *inode, u64 start, } /* + * 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_tracking.h b/fs/hot_tracking.h index 2ba29e4..6bd09eb 100644 --- a/fs/hot_tracking.h +++ b/fs/hot_tracking.h @@ -37,6 +37,7 @@ void hot_rb_free_hot_inode_item(struct hot_inode_item *he); void hot_rb_update_freqs(struct inode *inode, u64 start, u64 len, int rw); +bool hot_track_parse_options(char *options); void __init hot_track_cache_init(void); #endif /* __HOT_TRACKING__ */ diff --git a/fs/super.c b/fs/super.c index 0902cfa..7eb3b0c 100644 --- a/fs/super.c +++ b/fs/super.c @@ -34,6 +34,7 @@ #include #include #include +#include "hot_tracking.h" #include "internal.h" @@ -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_tracking.h b/include/linux/hot_tracking.h index a566f91..bb2a41c 100644 --- a/include/linux/hot_tracking.h +++ b/include/linux/hot_tracking.h @@ -20,6 +20,11 @@ #include #include +/* + * 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,8 @@ 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; };