Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) CacheFiles: CACHE ON ALREADY MOUNTED FILESYSTEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) .. Contents:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  (*) Overview.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  (*) Requirements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  (*) Configuration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  (*) Starting the cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  (*) Things to avoid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  (*) Cache culling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  (*) Cache structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  (*) Security model and SELinux.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  (*) A note on security.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  (*) Statistical information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  (*) Debugging.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) Overview
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) CacheFiles is a caching backend that's meant to use as a cache a directory on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) an already mounted filesystem of a local type (such as Ext3).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) CacheFiles uses a userspace daemon to do some of the cache management - such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) reaping stale nodes and culling.  This is called cachefilesd and lives in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /sbin.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) The filesystem and data integrity of the cache are only as good as those of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) filesystem providing the backing services.  Note that CacheFiles does not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) attempt to journal anything since the journalling interfaces of the various
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) filesystems are very specific in nature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) CacheFiles creates a misc character device - "/dev/cachefiles" - that is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) to communication with the daemon.  Only one thing may have this open at once,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) and while it is open, a cache is at least partially in existence.  The daemon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) opens this and sends commands down it to control the cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) CacheFiles is currently limited to a single cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) CacheFiles attempts to maintain at least a certain percentage of free space on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) the filesystem, shrinking the cache by culling the objects it contains to make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) space if necessary - see the "Cache Culling" section.  This means it can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) placed on the same medium as a live set of data, and will expand to make use of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) spare space and automatically contract when the set of data requires more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) Requirements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) The use of CacheFiles and its daemon requires the following features to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) available in the system and in the cache filesystem:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	- dnotify.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	- extended attributes (xattrs).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	- openat() and friends.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	- bmap() support on files in the filesystem (FIBMAP ioctl).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	- The use of bmap() to detect a partial page at the end of the file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) It is strongly recommended that the "dir_index" option is enabled on Ext3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) filesystems being used as a cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) Configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) The cache is configured by a script in /etc/cachefilesd.conf.  These commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) set up cache ready for use.  The following script commands are available:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  brun <N>%, bcull <N>%, bstop <N>%, frun <N>%, fcull <N>%, fstop <N>%
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	Configure the culling limits.  Optional.  See the section on culling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	The defaults are 7% (run), 5% (cull) and 1% (stop) respectively.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	The commands beginning with a 'b' are file space (block) limits, those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	beginning with an 'f' are file count limits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  dir <path>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	Specify the directory containing the root of the cache.  Mandatory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  tag <name>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	Specify a tag to FS-Cache to use in distinguishing multiple caches.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	Optional.  The default is "CacheFiles".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  debug <mask>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	Specify a numeric bitmask to control debugging in the kernel module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	Optional.  The default is zero (all off).  The following values can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	OR'd into the mask to collect various information:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		==	=================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		1	Turn on trace of function entry (_enter() macros)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		2	Turn on trace of function exit (_leave() macros)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		4	Turn on trace of internal debug points (_debug())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		==	=================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	This mask can also be set through sysfs, eg::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		echo 5 >/sys/modules/cachefiles/parameters/debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) Starting the Cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) The cache is started by running the daemon.  The daemon opens the cache device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) configures the cache and tells it to begin caching.  At that point the cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) binds to fscache and the cache becomes live.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) The daemon is run as follows::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	/sbin/cachefilesd [-d]* [-s] [-n] [-f <configfile>]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) The flags are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  ``-d``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	Increase the debugging level.  This can be specified multiple times and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	is cumulative with itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  ``-s``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	Send messages to stderr instead of syslog.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  ``-n``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	Don't daemonise and go into background.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  ``-f <configfile>``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	Use an alternative configuration file rather than the default one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) Things to Avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) Do not mount other things within the cache as this will cause problems.  The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) kernel module contains its own very cut-down path walking facility that ignores
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) mountpoints, but the daemon can't avoid them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) Do not create, rename or unlink files and directories in the cache while the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) cache is active, as this may cause the state to become uncertain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) Renaming files in the cache might make objects appear to be other objects (the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) filename is part of the lookup key).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) Do not change or remove the extended attributes attached to cache files by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) cache as this will cause the cache state management to get confused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) Do not create files or directories in the cache, lest the cache get confused or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) serve incorrect data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) Do not chmod files in the cache.  The module creates things with minimal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) permissions to prevent random users being able to access them directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) Cache Culling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) The cache may need culling occasionally to make space.  This involves
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) discarding objects from the cache that have been used less recently than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) anything else.  Culling is based on the access time of data objects.  Empty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) directories are culled if not in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) Cache culling is done on the basis of the percentage of blocks and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) percentage of files available in the underlying filesystem.  There are six
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) "limits":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  brun, frun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)      If the amount of free space and the number of available files in the cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)      rises above both these limits, then culling is turned off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  bcull, fcull
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)      If the amount of available space or the number of available files in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)      cache falls below either of these limits, then culling is started.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  bstop, fstop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)      If the amount of available space or the number of available files in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)      cache falls below either of these limits, then no further allocation of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)      disk space or files is permitted until culling has raised things above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)      these limits again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) These must be configured thusly::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	0 <= bstop < bcull < brun < 100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	0 <= fstop < fcull < frun < 100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) Note that these are percentages of available space and available files, and do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) _not_ appear as 100 minus the percentage displayed by the "df" program.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) The userspace daemon scans the cache to build up a table of cullable objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) These are then culled in least recently used order.  A new scan of the cache is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) started as soon as space is made in the table.  Objects will be skipped if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) their atimes have changed or if the kernel module says it is still using them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) Cache Structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) The CacheFiles module will create two directories in the directory it was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) given:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  * cache/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * graveyard/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) The active cache objects all reside in the first directory.  The CacheFiles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) kernel module moves any retired or culled objects that it can't simply unlink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) to the graveyard from which the daemon will actually delete them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) The daemon uses dnotify to monitor the graveyard directory, and will delete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) anything that appears therein.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) The module represents index objects as directories with the filename "I..." or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) "J...".  Note that the "cache/" directory is itself a special index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) Data objects are represented as files if they have no children, or directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if they do.  Their filenames all begin "D..." or "E...".  If represented as a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) directory, data objects will have a file in the directory called "data" that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) actually holds the data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) Special objects are similar to data objects, except their filenames begin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) "S..." or "T...".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) If an object has children, then it will be represented as a directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) Immediately in the representative directory are a collection of directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) named for hash values of the child object keys with an '@' prepended.  Into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) this directory, if possible, will be placed the representations of the child
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) objects::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	 /INDEX    /INDEX     /INDEX                            /DATA FILES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	/=========/==========/=================================/================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...DB1ry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...N22ry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...FP1ry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) If the key is so long that it exceeds NAME_MAX with the decorations added on to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) it, then it will be cut into pieces, the first few of which will be used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) make a nest of directories, and the last one of which will be the objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) inside the last directory.  The names of the intermediate directories will have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) '+' prepended::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	J1223/@23/+xy...z/+kl...m/Epqr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) Note that keys are raw data, and not only may they exceed NAME_MAX in size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) they may also contain things like '/' and NUL characters, and so they may not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) be suitable for turning directly into a filename.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) To handle this, CacheFiles will use a suitably printable filename directly and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) "base-64" encode ones that aren't directly suitable.  The two versions of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) object filenames indicate the encoding:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	===============	===============	===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	OBJECT TYPE	PRINTABLE	ENCODED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	===============	===============	===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	Index		"I..."		"J..."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	Data		"D..."		"E..."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	Special		"S..."		"T..."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	===============	===============	===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) Intermediate directories are always "@" or "+" as appropriate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) Each object in the cache has an extended attribute label that holds the object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) type ID (required to distinguish special objects) and the auxiliary data from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) the netfs.  The latter is used to detect stale objects in the cache and update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) or retire them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) Note that CacheFiles will erase from the cache any file it doesn't recognise or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) any file of an incorrect type (such as a FIFO file or a device file).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) Security Model and SELinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) CacheFiles is implemented to deal properly with the LSM security features of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) the Linux kernel and the SELinux facility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) One of the problems that CacheFiles faces is that it is generally acting on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) behalf of a process, and running in that process's context, and that includes a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) security context that is not appropriate for accessing the cache - either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) because the files in the cache are inaccessible to that process, or because if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) the process creates a file in the cache, that file may be inaccessible to other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) processes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) The way CacheFiles works is to temporarily change the security context (fsuid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) fsgid and actor security label) that the process acts as - without changing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) security context of the process when it the target of an operation performed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) some other process (so signalling and suchlike still work correctly).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) When the CacheFiles module is asked to bind to its cache, it:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  (1) Finds the security label attached to the root cache directory and uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)      that as the security label with which it will create files.  By default,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)      this is::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	cachefiles_var_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)  (2) Finds the security label of the process which issued the bind request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)      (presumed to be the cachefilesd daemon), which by default will be::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	cachefilesd_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)      and asks LSM to supply a security ID as which it should act given the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)      daemon's label.  By default, this will be::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	cachefiles_kernel_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)      SELinux transitions the daemon's security ID to the module's security ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)      based on a rule of this form in the policy::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	type_transition <daemon's-ID> kernel_t : process <module's-ID>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)      For instance::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	type_transition cachefilesd_t kernel_t : process cachefiles_kernel_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) The module's security ID gives it permission to create, move and remove files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) and directories in the cache, to find and access directories and files in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) cache, to set and access extended attributes on cache objects, and to read and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) write files in the cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) The daemon's security ID gives it only a very restricted set of permissions: it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) may scan directories, stat files and erase files and directories.  It may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) not read or write files in the cache, and so it is precluded from accessing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) data cached therein; nor is it permitted to create new files in the cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) There are policy source files available in:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	https://people.redhat.com/~dhowells/fscache/cachefilesd-0.8.tar.bz2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) and later versions.  In that tarball, see the files::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	cachefilesd.te
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	cachefilesd.fc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	cachefilesd.if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) They are built and installed directly by the RPM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) If a non-RPM based system is being used, then copy the above files to their own
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) directory and run::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	make -f /usr/share/selinux/devel/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	semodule -i cachefilesd.pp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) You will need checkpolicy and selinux-policy-devel installed prior to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) build.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) By default, the cache is located in /var/fscache, but if it is desirable that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) it should be elsewhere, than either the above policy files must be altered, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) an auxiliary policy must be installed to label the alternate location of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) For instructions on how to add an auxiliary policy to enable the cache to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) located elsewhere when SELinux is in enforcing mode, please see::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	/usr/share/doc/cachefilesd-*/move-cache.txt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) When the cachefilesd rpm is installed; alternatively, the document can be found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) in the sources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) A Note on Security
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) CacheFiles makes use of the split security in the task_struct.  It allocates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) its own task_security structure, and redirects current->cred to point to it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) when it acts on behalf of another process, in that process's context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) The reason it does this is that it calls vfs_mkdir() and suchlike rather than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) bypassing security and calling inode ops directly.  Therefore the VFS and LSM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) may deny the CacheFiles access to the cache data because under some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) circumstances the caching code is running in the security context of whatever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) process issued the original syscall on the netfs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) Furthermore, should CacheFiles create a file or directory, the security
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) parameters with that object is created (UID, GID, security label) would be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) derived from that process that issued the system call, thus potentially
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) preventing other processes from accessing the cache - including CacheFiles's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) cache management daemon (cachefilesd).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) What is required is to temporarily override the security of the process that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) issued the system call.  We can't, however, just do an in-place change of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) security data as that affects the process as an object, not just as a subject.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) This means it may lose signals or ptrace events for example, and affects what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) the process looks like in /proc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) So CacheFiles makes use of a logical split in the security between the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) objective security (task->real_cred) and the subjective security (task->cred).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) The objective security holds the intrinsic security properties of a process and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) is never overridden.  This is what appears in /proc, and is what is used when a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) process is the target of an operation by some other process (SIGKILL for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) example).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) The subjective security holds the active security properties of a process, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) may be overridden.  This is not seen externally, and is used whan a process
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) acts upon another object, for example SIGKILLing another process or opening a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) LSM hooks exist that allow SELinux (or Smack or whatever) to reject a request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) for CacheFiles to run in a context of a specific security label, or to create
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) files and directories with another security label.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) Statistical Information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) If FS-Cache is compiled with the following option enabled::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	CONFIG_CACHEFILES_HISTOGRAM=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) then it will gather certain statistics and display them through a proc file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)  /proc/fs/cachefiles/histogram
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)      ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	cat /proc/fs/cachefiles/histogram
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	JIFS  SECS  LOOKUPS   MKDIRS    CREATES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	===== ===== ========= ========= =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)      This shows the breakdown of the number of times each amount of time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)      between 0 jiffies and HZ-1 jiffies a variety of tasks took to run.  The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)      columns are as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	=======		=======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	COLUMN		TIME MEASUREMENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	=======		=======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	LOOKUPS		Length of time to perform a lookup on the backing fs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	MKDIRS		Length of time to perform a mkdir on the backing fs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	CREATES		Length of time to perform a create on the backing fs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	=======		=======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)      Each row shows the number of events that took a particular range of times.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)      Each step is 1 jiffy in size.  The JIFS column indicates the particular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)      jiffy range covered, and the SECS field the equivalent number of seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) Debugging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) If CONFIG_CACHEFILES_DEBUG is enabled, the CacheFiles facility can have runtime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) debugging enabled by adjusting the value in::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	/sys/module/cachefiles/parameters/debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) This is a bitmask of debugging streams to enable:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	=======	=======	===============================	=======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	BIT	VALUE	STREAM				POINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	=======	=======	===============================	=======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	0	1	General				Function entry trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	1	2					Function exit trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	2	4					General
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	=======	=======	===============================	=======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) The appropriate set of values should be OR'd together and the result written to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) the control file.  For example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	echo $((1|4|8)) >/sys/module/cachefiles/parameters/debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) will turn on all function entry debugging.