mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: viro@ZenIV.linux.org.uk
Cc: dhowells@redhat.com, nfsv4@linux-nfs.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 09/43] FS-Cache: Add main configuration option, module entry points and debugging [ver #46]
Date: Thu, 02 Apr 2009 00:04:08 +0100	[thread overview]
Message-ID: <20090401230407.28177.44457.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20090401230321.28177.12010.stgit@warthog.procyon.org.uk>

Add the main configuration option, allowing FS-Cache to be selected; the
module entry and exit functions and the debugging stuff used by these patches.

The two configuration options added are:

	CONFIG_FSCACHE
	CONFIG_FSCACHE_DEBUG

The first enables the facility, and the second makes the debugging statements
enableable through the "debug" module parameter.  The value of this parameter
is a bitmask as described in:

	Documentation/filesystems/caching/fscache.txt

The module can be loaded at this point, but all it will do at this point in
the patch series is to start up the slow work facility and shut it down again.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Steve Dickson <steved@redhat.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---

 fs/Kconfig            |    6 ++
 fs/Makefile           |    1 
 fs/fscache/Kconfig    |   22 +++++++
 fs/fscache/Makefile   |    8 ++
 fs/fscache/internal.h |  165 +++++++++++++++++++++++++++++++++++++++++++++++++
 fs/fscache/main.c     |   75 ++++++++++++++++++++++
 6 files changed, 277 insertions(+), 0 deletions(-)
 create mode 100644 fs/fscache/Kconfig
 create mode 100644 fs/fscache/Makefile
 create mode 100644 fs/fscache/internal.h
 create mode 100644 fs/fscache/main.c


diff --git a/fs/Kconfig b/fs/Kconfig
index cef8b18..3942df6 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -66,6 +66,12 @@ config GENERIC_ACL
 	bool
 	select FS_POSIX_ACL
 
+menu "Caches"
+
+source "fs/fscache/Kconfig"
+
+endmenu
+
 if BLOCK
 menu "CD-ROM/DVD Filesystems"
 
diff --git a/fs/Makefile b/fs/Makefile
index 6e82a30..24ce1fe 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_PROFILING)		+= dcookies.o
 obj-$(CONFIG_DLM)		+= dlm/
  
 # Do not add any filesystems before this line
+obj-$(CONFIG_FSCACHE)		+= fscache/
 obj-$(CONFIG_REISERFS_FS)	+= reiserfs/
 obj-$(CONFIG_EXT3_FS)		+= ext3/ # Before ext2 so root fs can be ext3
 obj-$(CONFIG_EXT2_FS)		+= ext2/
diff --git a/fs/fscache/Kconfig b/fs/fscache/Kconfig
new file mode 100644
index 0000000..7c7bccd
--- /dev/null
+++ b/fs/fscache/Kconfig
@@ -0,0 +1,22 @@
+
+config FSCACHE
+	tristate "General filesystem local caching manager"
+	depends on EXPERIMENTAL
+	select SLOW_WORK
+	help
+	  This option enables a generic filesystem caching manager that can be
+	  used by various network and other filesystems to cache data locally.
+	  Different sorts of caches can be plugged in, depending on the
+	  resources available.
+
+	  See Documentation/filesystems/caching/fscache.txt for more information.
+
+config FSCACHE_DEBUG
+	bool "Debug FS-Cache"
+	depends on FSCACHE
+	help
+	  This permits debugging to be dynamically enabled in the local caching
+	  management module.  If this is set, the debugging output may be
+	  enabled by setting bits in /sys/modules/fscache/parameter/debug.
+
+	  See Documentation/filesystems/caching/fscache.txt for more information.
diff --git a/fs/fscache/Makefile b/fs/fscache/Makefile
new file mode 100644
index 0000000..f8038b8
--- /dev/null
+++ b/fs/fscache/Makefile
@@ -0,0 +1,8 @@
+#
+# Makefile for general filesystem caching code
+#
+
+fscache-y := \
+	main.o
+
+obj-$(CONFIG_FSCACHE) := fscache.o
diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
new file mode 100644
index 0000000..95dc92d
--- /dev/null
+++ b/fs/fscache/internal.h
@@ -0,0 +1,165 @@
+/* Internal definitions for FS-Cache
+ *
+ * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@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; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+/*
+ * Lock order, in the order in which multiple locks should be obtained:
+ * - fscache_addremove_sem
+ * - cookie->lock
+ * - cookie->parent->lock
+ * - cache->object_list_lock
+ * - object->lock
+ * - object->parent->lock
+ * - fscache_thread_lock
+ *
+ */
+
+#include <linux/fscache-cache.h>
+#include <linux/sched.h>
+
+#define FSCACHE_MIN_THREADS	4
+#define FSCACHE_MAX_THREADS	32
+
+/*
+ * fsc-main.c
+ */
+extern unsigned fscache_defer_lookup;
+extern unsigned fscache_defer_create;
+extern unsigned fscache_debug;
+extern struct kobject *fscache_root;
+
+/*****************************************************************************/
+/*
+ * debug tracing
+ */
+#define dbgprintk(FMT, ...) \
+	printk(KERN_DEBUG "[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__)
+
+/* make sure we maintain the format strings, even when debugging is disabled */
+static inline __attribute__((format(printf, 1, 2)))
+void _dbprintk(const char *fmt, ...)
+{
+}
+
+#define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
+#define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
+#define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__)
+
+#define kjournal(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__)
+
+#ifdef __KDEBUG
+#define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__)
+#define _leave(FMT, ...) kleave(FMT, ##__VA_ARGS__)
+#define _debug(FMT, ...) kdebug(FMT, ##__VA_ARGS__)
+
+#elif defined(CONFIG_FSCACHE_DEBUG)
+#define _enter(FMT, ...)			\
+do {						\
+	if (__do_kdebug(ENTER))			\
+		kenter(FMT, ##__VA_ARGS__);	\
+} while (0)
+
+#define _leave(FMT, ...)			\
+do {						\
+	if (__do_kdebug(LEAVE))			\
+		kleave(FMT, ##__VA_ARGS__);	\
+} while (0)
+
+#define _debug(FMT, ...)			\
+do {						\
+	if (__do_kdebug(DEBUG))			\
+		kdebug(FMT, ##__VA_ARGS__);	\
+} while (0)
+
+#else
+#define _enter(FMT, ...) _dbprintk("==> %s("FMT")", __func__, ##__VA_ARGS__)
+#define _leave(FMT, ...) _dbprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)
+#define _debug(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__)
+#endif
+
+/*
+ * determine whether a particular optional debugging point should be logged
+ * - we need to go through three steps to persuade cpp to correctly join the
+ *   shorthand in FSCACHE_DEBUG_LEVEL with its prefix
+ */
+#define ____do_kdebug(LEVEL, POINT) \
+	unlikely((fscache_debug & \
+		  (FSCACHE_POINT_##POINT << (FSCACHE_DEBUG_ ## LEVEL * 3))))
+#define ___do_kdebug(LEVEL, POINT) \
+	____do_kdebug(LEVEL, POINT)
+#define __do_kdebug(POINT) \
+	___do_kdebug(FSCACHE_DEBUG_LEVEL, POINT)
+
+#define FSCACHE_DEBUG_CACHE	0
+#define FSCACHE_DEBUG_COOKIE	1
+#define FSCACHE_DEBUG_PAGE	2
+#define FSCACHE_DEBUG_OPERATION	3
+
+#define FSCACHE_POINT_ENTER	1
+#define FSCACHE_POINT_LEAVE	2
+#define FSCACHE_POINT_DEBUG	4
+
+#ifndef FSCACHE_DEBUG_LEVEL
+#define FSCACHE_DEBUG_LEVEL CACHE
+#endif
+
+/*
+ * assertions
+ */
+#if 1 /* defined(__KDEBUGALL) */
+
+#define ASSERT(X)							\
+do {									\
+	if (unlikely(!(X))) {						\
+		printk(KERN_ERR "\n");					\
+		printk(KERN_ERR "FS-Cache: Assertion failed\n");	\
+		BUG();							\
+	}								\
+} while (0)
+
+#define ASSERTCMP(X, OP, Y)						\
+do {									\
+	if (unlikely(!((X) OP (Y)))) {					\
+		printk(KERN_ERR "\n");					\
+		printk(KERN_ERR "FS-Cache: Assertion failed\n");	\
+		printk(KERN_ERR "%lx " #OP " %lx is false\n",		\
+		       (unsigned long)(X), (unsigned long)(Y));		\
+		BUG();							\
+	}								\
+} while (0)
+
+#define ASSERTIF(C, X)							\
+do {									\
+	if (unlikely((C) && !(X))) {					\
+		printk(KERN_ERR "\n");					\
+		printk(KERN_ERR "FS-Cache: Assertion failed\n");	\
+		BUG();							\
+	}								\
+} while (0)
+
+#define ASSERTIFCMP(C, X, OP, Y)					\
+do {									\
+	if (unlikely((C) && !((X) OP (Y)))) {				\
+		printk(KERN_ERR "\n");					\
+		printk(KERN_ERR "FS-Cache: Assertion failed\n");	\
+		printk(KERN_ERR "%lx " #OP " %lx is false\n",		\
+		       (unsigned long)(X), (unsigned long)(Y));		\
+		BUG();							\
+	}								\
+} while (0)
+
+#else
+
+#define ASSERT(X)			do {} while (0)
+#define ASSERTCMP(X, OP, Y)		do {} while (0)
+#define ASSERTIF(C, X)			do {} while (0)
+#define ASSERTIFCMP(C, X, OP, Y)	do {} while (0)
+
+#endif /* assert or not */
diff --git a/fs/fscache/main.c b/fs/fscache/main.c
new file mode 100644
index 0000000..76f7c69
--- /dev/null
+++ b/fs/fscache/main.c
@@ -0,0 +1,75 @@
+/* General filesystem local caching manager
+ *
+ * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@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; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#define FSCACHE_DEBUG_LEVEL CACHE
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/completion.h>
+#include <linux/slab.h>
+#include "internal.h"
+
+MODULE_DESCRIPTION("FS Cache Manager");
+MODULE_AUTHOR("Red Hat, Inc.");
+MODULE_LICENSE("GPL");
+
+unsigned fscache_defer_lookup = 1;
+module_param_named(defer_lookup, fscache_defer_lookup, uint,
+		   S_IWUSR | S_IRUGO);
+MODULE_PARM_DESC(fscache_defer_lookup,
+		 "Defer cookie lookup to background thread");
+
+unsigned fscache_defer_create = 1;
+module_param_named(defer_create, fscache_defer_create, uint,
+		   S_IWUSR | S_IRUGO);
+MODULE_PARM_DESC(fscache_defer_create,
+		 "Defer cookie creation to background thread");
+
+unsigned fscache_debug;
+module_param_named(debug, fscache_debug, uint,
+		   S_IWUSR | S_IRUGO);
+MODULE_PARM_DESC(fscache_debug,
+		 "FS-Cache debugging mask");
+
+struct kobject *fscache_root;
+
+/*
+ * initialise the fs caching module
+ */
+static int __init fscache_init(void)
+{
+	int ret;
+
+	ret = slow_work_register_user();
+	if (ret < 0)
+		goto error_slow_work;
+
+	printk(KERN_NOTICE "FS-Cache: Loaded\n");
+	return 0;
+
+error_slow_work:
+	return ret;
+}
+
+fs_initcall(fscache_init);
+
+/*
+ * clean up on module removal
+ */
+static void __exit fscache_exit(void)
+{
+	_enter("");
+
+	slow_work_unregister_user();
+	printk(KERN_NOTICE "FS-Cache: Unloaded\n");
+}
+
+module_exit(fscache_exit);


  parent reply	other threads:[~2009-04-01 23:10 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200904030051.10644.nickpiggin@yahoo.com.au>
2009-04-01 23:03 ` [PATCH 00/43] Permit filesystem local caching " David Howells
2009-04-01 23:03   ` [PATCH 01/43] Create a dynamically sized pool of threads for doing very slow work items " David Howells
2009-04-01 23:03   ` [PATCH 02/43] Make slow-work thread pool actually dynamic " David Howells
2009-04-01 23:03   ` [PATCH 03/43] Make the slow work pool configurable " David Howells
2009-04-01 23:03   ` [PATCH 04/43] Document the slow work thread pool " David Howells
2009-04-01 23:03   ` [PATCH 05/43] FS-Cache: Release page->private after failed readahead " David Howells
2009-04-02 14:21     ` David Howells
2009-04-02 17:17     ` Rik van Riel
2009-04-01 23:03   ` [PATCH 06/43] FS-Cache: Recruit a couple of page flags for cache management " David Howells
2009-04-02 14:36     ` David Howells
2009-04-02 15:25       ` Nick Piggin
2009-04-02 15:51       ` David Howells
2009-04-02 16:15         ` Nick Piggin
2009-04-02 16:53           ` Nick Piggin
2009-04-02 17:09           ` David Howells
2009-04-02 17:31             ` Nick Piggin
2009-04-02 17:40             ` David Howells
2009-04-02 18:14               ` Nick Piggin
2009-04-02 19:19               ` Trond Myklebust
2009-04-03  1:11               ` David Howells
2009-04-02 16:48         ` What I mean by a 'netfs' when dealing with FS-Cache David Howells
2009-04-02 17:06         ` David Howells
2009-04-02 18:23     ` [PATCH 06/43] FS-Cache: Recruit a couple of page flags for cache management [ver #46] Rik van Riel
2009-04-01 23:03   ` [PATCH 07/43] FS-Cache: Add the FS-Cache netfs API and documentation " David Howells
2009-04-01 23:04   ` [PATCH 08/43] FS-Cache: Add the FS-Cache cache backend " David Howells
2009-04-01 23:04   ` David Howells [this message]
2009-04-01 23:04   ` [PATCH 10/43] FS-Cache: Add use of /proc and presentation of statistics " David Howells
2009-04-01 23:04   ` [PATCH 11/43] FS-Cache: Root index definition " David Howells
2009-04-01 23:04   ` [PATCH 12/43] FS-Cache: Add cache tag handling " David Howells
2009-04-01 23:04   ` [PATCH 13/43] FS-Cache: Add cache management " David Howells
2009-04-01 23:04   ` [PATCH 14/43] FS-Cache: Provide a slab for cookie allocation " David Howells
2009-04-01 23:04   ` [PATCH 15/43] FS-Cache: Add netfs registration " David Howells
2009-04-01 23:04   ` [PATCH 16/43] FS-Cache: Bit waiting helpers " David Howells
2009-04-01 23:04   ` [PATCH 17/43] FS-Cache: Object management state machine " David Howells
2009-04-01 23:04   ` [PATCH 18/43] FS-Cache: Implement the cookie management part of the netfs API " David Howells
2009-04-01 23:04   ` [PATCH 19/43] FS-Cache: Add and document asynchronous operation handling " David Howells
2009-04-01 23:05   ` [PATCH 20/43] FS-Cache: Implement data I/O part of netfs API " David Howells
2009-04-01 23:05   ` [PATCH 21/43] CacheFiles: Be consistent about the use of mapping vs file->f_mapping in Ext3 " David Howells
2009-04-02 18:52     ` Rik van Riel
2009-04-01 23:05   ` [PATCH 22/43] CacheFiles: Add a hook to write a single page of data to an inode " David Howells
2009-04-02 14:55     ` David Howells
2009-04-02 15:32       ` Nick Piggin
2009-04-02 16:37         ` Christoph Hellwig
2009-04-02 16:47           ` Nick Piggin
2009-04-02 16:55             ` Christoph Hellwig
2009-04-02 17:07               ` Nick Piggin
2009-04-02 17:26                 ` Jan Kara
2009-04-02 17:22             ` David Howells
2009-04-02 18:18             ` David Howells
2009-04-02 22:44             ` David Howells
2009-04-03 13:41             ` David Howells
2009-04-02 16:02       ` David Howells
2009-04-02 15:32     ` Peter Staubach
2009-04-02 16:03     ` David Howells
2009-04-02 18:48     ` Rik van Riel
2009-04-01 23:05   ` [PATCH 23/43] CacheFiles: Permit the page lock state to be monitored " David Howells
2009-04-02 15:37     ` Nick Piggin
2009-04-02 16:14     ` David Howells
2009-04-02 16:35       ` Nick Piggin
2009-04-02 17:05       ` David Howells
2009-04-02 18:03         ` Nick Piggin
2009-04-02 18:51     ` Rik van Riel
2009-04-01 23:05   ` [PATCH 24/43] CacheFiles: Export things for CacheFiles " David Howells
2009-04-02 18:53     ` Rik van Riel
2009-04-01 23:05   ` [PATCH 25/43] CacheFiles: A cache that backs onto a mounted filesystem " David Howells
2009-04-01 23:05   ` [PATCH 26/43] FS-Cache: Make kAFS use FS-Cache " David Howells
2009-04-01 23:05   ` [PATCH 27/43] NFS: Add comment banners to some NFS functions " David Howells
2009-04-01 23:05   ` [PATCH 28/43] NFS: Add FS-Cache option bit and debug bit " David Howells
2009-04-01 23:05   ` [PATCH 29/43] NFS: Permit local filesystem caching to be enabled for NFS " David Howells
2009-04-01 23:05   ` [PATCH 30/43] NFS: Register NFS for caching and retrieve the top-level index " David Howells
2009-04-01 23:06   ` [PATCH 31/43] NFS: Define and create server-level objects " David Howells
2009-04-01 23:06   ` [PATCH 32/43] NFS: Define and create superblock-level " David Howells
2009-04-01 23:06   ` [PATCH 33/43] NFS: Define and create inode-level cache " David Howells
2009-04-01 23:06   ` [PATCH 34/43] NFS: Use local disk inode cache " David Howells
2009-04-01 23:06   ` [PATCH 35/43] NFS: Invalidate FsCache page flags when cache removed " David Howells
2009-04-01 23:06   ` [PATCH 36/43] NFS: Add some new I/O counters for FS-Cache doing things for NFS " David Howells
2009-04-01 23:06   ` [PATCH 37/43] NFS: FS-Cache page management " David Howells
2009-04-01 23:06   ` [PATCH 38/43] NFS: Add read context retention for FS-Cache to call back with " David Howells
2009-04-01 23:06   ` [PATCH 39/43] NFS: nfs_readpage_async() needs to be accessible as a fallback for local caching " David Howells
2009-04-01 23:06   ` [PATCH 40/43] NFS: Read pages from FS-Cache into an NFS inode " David Howells
2009-04-01 23:06   ` [PATCH 41/43] NFS: Store pages from an NFS inode into a local cache " David Howells
2009-04-01 23:06   ` [PATCH 42/43] NFS: Display local caching state " David Howells
2009-04-01 23:07   ` [PATCH 43/43] NFS: Add mount options to enable local caching on NFS " David Howells

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=20090401230407.28177.44457.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nfsv4@linux-nfs.org \
    --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

all inboxes | Powered by JetHome®