diff options
| -rw-r--r-- | Documentation/filesystems/caching/cachefiles.txt | 501 | ||||
| -rw-r--r-- | fs/Kconfig | 1 | ||||
| -rw-r--r-- | fs/Makefile | 1 | ||||
| -rw-r--r-- | fs/cachefiles/Kconfig | 39 | ||||
| -rw-r--r-- | fs/cachefiles/Makefile | 18 | ||||
| -rw-r--r-- | fs/cachefiles/bind.c | 286 | ||||
| -rw-r--r-- | fs/cachefiles/daemon.c | 755 | ||||
| -rw-r--r-- | fs/cachefiles/interface.c | 449 | ||||
| -rw-r--r-- | fs/cachefiles/internal.h | 360 | ||||
| -rw-r--r-- | fs/cachefiles/key.c | 159 | ||||
| -rw-r--r-- | fs/cachefiles/main.c | 106 | ||||
| -rw-r--r-- | fs/cachefiles/namei.c | 771 | ||||
| -rw-r--r-- | fs/cachefiles/proc.c | 134 | ||||
| -rw-r--r-- | fs/cachefiles/rdwr.c | 879 | ||||
| -rw-r--r-- | fs/cachefiles/security.c | 116 | ||||
| -rw-r--r-- | fs/cachefiles/xattr.c | 291 |
16 files changed, 4866 insertions, 0 deletions
diff --git a/Documentation/filesystems/caching/cachefiles.txt b/Documentation/filesystems/caching/cachefiles.txt new file mode 100644 index 000000000000..c78a49b7bba6 --- /dev/null +++ b/Documentation/filesystems/caching/cachefiles.txt | |||
| @@ -0,0 +1,501 @@ | |||
| 1 | =============================================== | ||
| 2 | CacheFiles: CACHE ON ALREADY MOUNTED FILESYSTEM | ||
| 3 | =============================================== | ||
| 4 | |||
| 5 | Contents: | ||
| 6 | |||
| 7 | (*) Overview. | ||
| 8 | |||
| 9 | (*) Requirements. | ||
| 10 | |||
| 11 | (*) Configuration. | ||
| 12 | |||
| 13 | (*) Starting the cache. | ||
| 14 | |||
| 15 | (*) Things to avoid. | ||
| 16 | |||
| 17 | (*) Cache culling. | ||
| 18 | |||
| 19 | (*) Cache structure. | ||
| 20 | |||
| 21 | (*) Security model and SELinux. | ||
| 22 | |||
| 23 | (*) A note on security. | ||
| 24 | |||
| 25 | (*) Statistical information. | ||
| 26 | |||
| 27 | (*) Debugging. | ||
| 28 | |||
| 29 | |||
| 30 | ======== | ||
| 31 | OVERVIEW | ||
| 32 | ======== | ||
| 33 | |||
| 34 | CacheFiles is a caching backend that's meant to use as a cache a directory on | ||
| 35 | an already mounted filesystem of a local type (such as Ext3). | ||
| 36 | |||
| 37 | CacheFiles uses a userspace daemon to do some of the cache management - such as | ||
| 38 | reaping stale nodes and culling. This is called cachefilesd and lives in | ||
| 39 | /sbin. | ||
| 40 | |||
| 41 | The filesystem and data integrity of the cache are only as good as those of the | ||
| 42 | filesystem providing the backing services. Note that CacheFiles does not | ||
| 43 | attempt to journal anything since the journalling interfaces of the various | ||
| 44 | filesystems are very specific in nature. | ||
| 45 | |||
| 46 | CacheFiles creates a misc character device - "/dev/cachefiles" - that is used | ||
| 47 | to communication with the daemon. Only one thing may have this open at once, | ||
| 48 | and whilst it is open, a cache is at least partially in existence. The daemon | ||
| 49 | opens this and sends commands down it to control the cache. | ||
| 50 | |||
| 51 | CacheFiles is currently limited to a single cache. | ||
| 52 | |||
| 53 | CacheFiles attempts to maintain at least a certain percentage of free space on | ||
| 54 | the filesystem, shrinking the cache by culling the objects it contains to make | ||
| 55 | space if necessary - see the "Cache Culling" section. This means it can be | ||
| 56 | placed on the same medium as a live set of data, and will expand to make use of | ||
| 57 | spare space and automatically contract when the set of data requires more | ||
| 58 | space. | ||
| 59 | |||
| 60 | |||
| 61 | ============ | ||
| 62 | REQUIREMENTS | ||
| 63 | ============ | ||
| 64 | |||
| 65 | The use of CacheFiles and its daemon requires the following features to be | ||
| 66 | available in the system and in the cache filesystem: | ||
| 67 | |||
| 68 | - dnotify. | ||
| 69 | |||
| 70 | - extended attributes (xattrs). | ||
| 71 | |||
| 72 | - openat() and friends. | ||
| 73 | |||
| 74 | - bmap() support on files in the filesystem (FIBMAP ioctl). | ||
| 75 | |||
| 76 | - The use of bmap() to detect a partial page at the end of the file. | ||
| 77 | |||
| 78 | It is strongly recommended that the "dir_index" option is enabled on Ext3 | ||
| 79 | filesystems being used as a cache. | ||
| 80 | |||
| 81 | |||
| 82 | ============= | ||
| 83 | CONFIGURATION | ||
| 84 | ============= | ||
| 85 | |||
| 86 | The cache is configured by a script in /etc/cachefilesd.conf. These commands | ||
| 87 | set up cache ready for use. The following script commands are available: | ||
| 88 | |||
| 89 | (*) brun <N>% | ||
| 90 | (*) bcull <N>% | ||
| 91 | (*) bstop <N>% | ||
| 92 | (*) frun <N>% | ||
| 93 | (*) fcull <N>% | ||
| 94 | (*) fstop <N>% | ||
| 95 | |||
| 96 | Configure the culling limits. Optional. See the section on culling | ||
| 97 | The defaults are 7% (run), 5% (cull) and 1% (stop) respectively. | ||
| 98 | |||
| 99 | The commands beginning with a 'b' are file space (block) limits, those | ||
| 100 | beginning with an 'f' are file count limits. | ||
| 101 | |||
| 102 | (*) dir <path> | ||
| 103 | |||
| 104 | Specify the directory containing the root of the cache. Mandatory. | ||
| 105 | |||
| 106 | (*) tag <name> | ||
| 107 | |||
| 108 | Specify a tag to FS-Cache to use in distinguishing multiple caches. | ||
| 109 | Optional. The default is "CacheFiles". | ||
| 110 | |||
| 111 | (*) debug <mask> | ||
| 112 | |||
| 113 | Specify a numeric bitmask to control debugging in the kernel module. | ||
| 114 | Optional. The default is zero (all off). The following values can be | ||
| 115 | OR'd into the mask to collect various information: | ||
| 116 | |||
| 117 | 1 Turn on trace of function entry (_enter() macros) | ||
| 118 | 2 Turn on trace of function exit (_leave() macros) | ||
| 119 | 4 Turn on trace of internal debug points (_debug()) | ||
| 120 | |||
| 121 | This mask can also be set through sysfs, eg: | ||
| 122 | |||
| 123 | echo 5 >/sys/modules/cachefiles/parameters/debug | ||
| 124 | |||
| 125 | |||
| 126 | ================== | ||
| 127 | STARTING THE CACHE | ||
| 128 | ================== | ||
| 129 | |||
| 130 | The cache is started by running the daemon. The daemon opens the cache device, | ||
| 131 | configures the cache and tells it to begin caching. At that point the cache | ||
| 132 | binds to fscache and the cache becomes live. | ||
| 133 | |||
| 134 | The daemon is run as follows: | ||
| 135 | |||
| 136 | /sbin/cachefilesd [-d]* [-s] [-n] [-f <configfile>] | ||
| 137 | |||
| 138 | The flags are: | ||
| 139 | |||
| 140 | (*) -d | ||
| 141 | |||
| 142 | Increase the debugging level. This can be specified multiple times and | ||
| 143 | is cumulative with itself. | ||
| 144 | |||
| 145 | (*) -s | ||
| 146 | |||
| 147 | Send messages to stderr instead of syslog. | ||
| 148 | |||
| 149 | (*) -n | ||
| 150 | |||
| 151 | Don't daemonise and go into background. | ||
| 152 | |||
| 153 | (*) -f <configfile> | ||
| 154 | |||
| 155 | Use an alternative configuration file rather than the default one. | ||
| 156 | |||
| 157 | |||
| 158 | =============== | ||
| 159 | THINGS TO AVOID | ||
| 160 | =============== | ||
| 161 | |||
| 162 | Do not mount other things within the cache as this will cause problems. The | ||
| 163 | kernel module contains its own very cut-down path walking facility that ignores | ||
| 164 | mountpoints, but the daemon can't avoid them. | ||
| 165 | |||
| 166 | Do not create, rename or unlink files and directories in the cache whilst the | ||
| 167 | cache is active, as this may cause the state to become uncertain. | ||
| 168 | |||
| 169 | Renaming files in the cache might make objects appe | ||
