-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 140196 b: refs/heads/master c: 06b3db1 h: refs/heads/master v: v3
- Loading branch information
David Howells
committed
Apr 3, 2009
1 parent
68d2fc0
commit 88870c8
Showing
7 changed files
with
278 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 0dfc41d1efcc4180abfd32f68f0ade540e636ff6 | ||
refs/heads/master: 06b3db1b9bccdc8c2c743122a89745279e5ecc46 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# | ||
# Makefile for general filesystem caching code | ||
# | ||
|
||
fscache-y := \ | ||
main.o | ||
|
||
obj-$(CONFIG_FSCACHE) := fscache.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |