sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget2/translations/zh_CN/filesystems/caching/cachefilesmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget2/translations/zh_TW/filesystems/caching/cachefilesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget2/translations/it_IT/filesystems/caching/cachefilesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget2/translations/ja_JP/filesystems/caching/cachefilesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget2/translations/ko_KR/filesystems/caching/cachefilesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget2/translations/sp_SP/filesystems/caching/cachefilesmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhL/var/lib/git/docbuild/linux/Documentation/filesystems/caching/cachefiles.rsthKubhsection)}(hhh](htitle)}(h#Cache on Already Mounted Filesystemh]h#Cache on Already Mounted Filesystem}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hXContents: (*) Overview. (*) Requirements. (*) Configuration. (*) Starting the cache. (*) Things to avoid. (*) Cache culling. (*) Cache structure. (*) Security model and SELinux. (*) A note on security. (*) Statistical information. (*) Debugging. (*) On-demand Read.h]hXContents: (*) Overview. (*) Requirements. (*) Configuration. (*) Starting the cache. (*) Things to avoid. (*) Cache culling. (*) Cache structure. (*) Security model and SELinux. (*) A note on security. (*) Statistical information. (*) Debugging. (*) On-demand Read.}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhK!ubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK#ubh paragraph)}(hCacheFiles is a caching backend that's meant to use as a cache a directory on an already mounted filesystem of a local type (such as Ext3).h]hCacheFiles is a caching backend that’s meant to use as a cache a directory on an already mounted filesystem of a local type (such as Ext3).}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hhhhubh)}(hCacheFiles uses a userspace daemon to do some of the cache management - such as reaping stale nodes and culling. This is called cachefilesd and lives in /sbin.h]hCacheFiles uses a userspace daemon to do some of the cache management - such as reaping stale nodes and culling. This is called cachefilesd and lives in /sbin.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hhhhubh)}(hXThe filesystem and data integrity of the cache are only as good as those of the filesystem providing the backing services. Note that CacheFiles does not attempt to journal anything since the journalling interfaces of the various filesystems are very specific in nature.h]hXThe filesystem and data integrity of the cache are only as good as those of the filesystem providing the backing services. Note that CacheFiles does not attempt to journal anything since the journalling interfaces of the various filesystems are very specific in nature.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK,hhhhubh)}(hX%CacheFiles creates a misc character device - "/dev/cachefiles" - that is used to communication with the daemon. Only one thing may have this open at once, and while it is open, a cache is at least partially in existence. The daemon opens this and sends commands down it to control the cache.h]hX)CacheFiles creates a misc character device - “/dev/cachefiles” - that is used to communication with the daemon. Only one thing may have this open at once, and while it is open, a cache is at least partially in existence. The daemon opens this and sends commands down it to control the cache.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hhhhubh)}(h2CacheFiles is currently limited to a single cache.h]h2CacheFiles is currently limited to a single cache.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hhhhubh)}(hXCacheFiles attempts to maintain at least a certain percentage of free space on the filesystem, shrinking the cache by culling the objects it contains to make space if necessary - see the "Cache Culling" section. This means it can be placed on the same medium as a live set of data, and will expand to make use of spare space and automatically contract when the set of data requires more space.h]hXCacheFiles attempts to maintain at least a certain percentage of free space on the filesystem, shrinking the cache by culling the objects it contains to make space if necessary - see the “Cache Culling” section. This means it can be placed on the same medium as a live set of data, and will expand to make use of spare space and automatically contract when the set of data requires more space.}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hhhhubeh}(h]overviewah ]h"]overviewah$]h&]uh1hhhhhhhhK#ubh)}(hhh](h)}(h Requirementsh]h Requirements}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjFhhhhhKBubh)}(hThe use of CacheFiles and its daemon requires the following features to be available in the system and in the cache filesystem:h]hThe use of CacheFiles and its daemon requires the following features to be available in the system and in the cache filesystem:}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhjFhhubh block_quote)}(h- dnotify. - extended attributes (xattrs). - openat() and friends. - bmap() support on files in the filesystem (FIBMAP ioctl). - The use of bmap() to detect a partial page at the end of the file. h]h bullet_list)}(hhh](h list_item)}(h dnotify. h]h)}(hdnotify.h]hdnotify.}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhjrubah}(h]h ]h"]h$]h&]uh1jphjmubjq)}(hextended attributes (xattrs). h]h)}(hextended attributes (xattrs).h]hextended attributes (xattrs).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKIhjubah}(h]h ]h"]h$]h&]uh1jphjmubjq)}(hopenat() and friends. h]h)}(hopenat() and friends.h]hopenat() and friends.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjubah}(h]h ]h"]h$]h&]uh1jphjmubjq)}(h:bmap() support on files in the filesystem (FIBMAP ioctl). h]h)}(h9bmap() support on files in the filesystem (FIBMAP ioctl).h]h9bmap() support on files in the filesystem (FIBMAP ioctl).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKMhjubah}(h]h ]h"]h$]h&]uh1jphjmubjq)}(hCThe use of bmap() to detect a partial page at the end of the file. h]h)}(hBThe use of bmap() to detect a partial page at the end of the file.h]hBThe use of bmap() to detect a partial page at the end of the file.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjubah}(h]h ]h"]h$]h&]uh1jphjmubeh}(h]h ]h"]h$]h&]bullet-uh1jkhhhKGhjgubah}(h]h ]h"]h$]h&]uh1jehhhKGhjFhhubh)}(hlIt is strongly recommended that the "dir_index" option is enabled on Ext3 filesystems being used as a cache.h]hpIt is strongly recommended that the “dir_index” option is enabled on Ext3 filesystems being used as a cache.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjFhhubeh}(h] requirementsah ]h"] requirementsah$]h&]uh1hhhhhhhhKBubh)}(hhh](h)}(h Configurationh]h Configuration}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKVubh)}(hThe cache is configured by a script in /etc/cachefilesd.conf. These commands set up cache ready for use. The following script commands are available:h]hThe cache is configured by a script in /etc/cachefilesd.conf. These commands set up cache ready for use. The following script commands are available:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKXhjhhubjf)}(hXbrun %, bcull %, bstop %, frun %, fcull %, fstop % Configure the culling limits. Optional. See the section on culling The defaults are 7% (run), 5% (cull) and 1% (stop) respectively. The commands beginning with a 'b' are file space (block) limits, those beginning with an 'f' are file count limits. dir Specify the directory containing the root of the cache. Mandatory. tag Specify a tag to FS-Cache to use in distinguishing multiple caches. Optional. The default is "CacheFiles". debug Specify a numeric bitmask to control debugging in the kernel module. Optional. The default is zero (all off). The following values can be OR'd into the mask to collect various information: == ================================================= 1 Turn on trace of function entry (_enter() macros) 2 Turn on trace of function exit (_leave() macros) 4 Turn on trace of internal debug points (_debug()) == ================================================= This mask can also be set through sysfs, eg:: echo 5 > /sys/module/cachefiles/parameters/debug h]hdefinition_list)}(hhh](hdefinition_list_item)}(hX@brun %, bcull %, bstop %, frun %, fcull %, fstop % Configure the culling limits. Optional. See the section on culling The defaults are 7% (run), 5% (cull) and 1% (stop) respectively. The commands beginning with a 'b' are file space (block) limits, those beginning with an 'f' are file count limits. h](hterm)}(hDbrun %, bcull %, bstop %, frun %, fcull %, fstop %h]hDbrun %, bcull %, bstop %, frun %, fcull %, fstop %}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1j<hhhK`hj8ubh definition)}(hhh](h)}(hConfigure the culling limits. Optional. See the section on culling The defaults are 7% (run), 5% (cull) and 1% (stop) respectively.h]hConfigure the culling limits. Optional. See the section on culling The defaults are 7% (run), 5% (cull) and 1% (stop) respectively.}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjNubh)}(hsThe commands beginning with a 'b' are file space (block) limits, those beginning with an 'f' are file count limits.h]h{The commands beginning with a ‘b’ are file space (block) limits, those beginning with an ‘f’ are file count limits.}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hjNubeh}(h]h ]h"]h$]h&]uh1jLhj8ubeh}(h]h ]h"]h$]h&]uh1j6hhhK`hj3ubj7)}(hOdir Specify the directory containing the root of the cache. Mandatory. h](j=)}(h dir h]h dir }(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1j<hhhKchjyubjM)}(hhh]h)}(hCSpecify the directory containing the root of the cache. Mandatory.h]hCSpecify the directory containing the root of the cache. Mandatory.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchjubah}(h]h ]h"]h$]h&]uh1jLhjyubeh}(h]h ]h"]h$]h&]uh1j6hhhKchj3ubj7)}(hwtag Specify a tag to FS-Cache to use in distinguishing multiple caches. Optional. The default is "CacheFiles". h](j=)}(h tag h]h tag }(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hhhKghjubjM)}(hhh]h)}(hkSpecify a tag to FS-Cache to use in distinguishing multiple caches. Optional. The default is "CacheFiles".h]hoSpecify a tag to FS-Cache to use in distinguishing multiple caches. Optional. The default is “CacheFiles”.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjubah}(h]h ]h"]h$]h&]uh1jLhjubeh}(h]h ]h"]h$]h&]uh1j6hhhKghj3ubj7)}(hXdebug Specify a numeric bitmask to control debugging in the kernel module. Optional. The default is zero (all off). The following values can be OR'd into the mask to collect various information: == ================================================= 1 Turn on trace of function entry (_enter() macros) 2 Turn on trace of function exit (_leave() macros) 4 Turn on trace of internal debug points (_debug()) == ================================================= This mask can also be set through sysfs, eg:: echo 5 > /sys/module/cachefiles/parameters/debug h](j=)}(h debug h]h debug }(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hhhKwhjubjM)}(hhh](h)}(hSpecify a numeric bitmask to control debugging in the kernel module. Optional. The default is zero (all off). The following values can be OR'd into the mask to collect various information:h]hSpecify a numeric bitmask to control debugging in the kernel module. Optional. The default is zero (all off). The following values can be OR’d into the mask to collect various information:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKjhjubjf)}(hX!== ================================================= 1 Turn on trace of function entry (_enter() macros) 2 Turn on trace of function exit (_leave() macros) 4 Turn on trace of internal debug points (_debug()) == ================================================= h]htable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj )}(hhh]h}(h]h ]h"]h$]h&]colwidthK1uh1jhjubhtbody)}(hhh](hrow)}(hhh](hentry)}(hhh]h)}(h1h]h1}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKohj*ubah}(h]h ]h"]h$]h&]uh1j(hj%ubj))}(hhh]h)}(h1Turn on trace of function entry (_enter() macros)h]h1Turn on trace of function entry (_enter() macros)}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKohjAubah}(h]h ]h"]h$]h&]uh1j(hj%ubeh}(h]h ]h"]h$]h&]uh1j#hj ubj$)}(hhh](j))}(hhh]h)}(h2h]h2}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjaubah}(h]h ]h"]h$]h&]uh1j(hj^ubj))}(hhh]h)}(h0Turn on trace of function exit (_leave() macros)h]h0Turn on trace of function exit (_leave() macros)}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjxubah}(h]h ]h"]h$]h&]uh1j(hj^ubeh}(h]h ]h"]h$]h&]uh1j#hj ubj$)}(hhh](j))}(hhh]h)}(h4h]h4}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKqhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(h1Turn on trace of internal debug points (_debug())h]h1Turn on trace of internal debug points (_debug())}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKqhjubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]uh1j#hj ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]colsKuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jehhhKnhjubh)}(h-This mask can also be set through sysfs, eg::h]h,This mask can also be set through sysfs, eg:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKthjubh literal_block)}(h0echo 5 > /sys/module/cachefiles/parameters/debugh]h0echo 5 > /sys/module/cachefiles/parameters/debug}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKvhjubeh}(h]h ]h"]h$]h&]uh1jLhjubeh}(h]h ]h"]h$]h&]uh1j6hhhKwhj3ubeh}(h]h ]h"]h$]h&]uh1j1hj-ubah}(h]h ]h"]h$]h&]uh1jehhhK[hjhhubeh}(h] configurationah ]h"] configurationah$]h&]uh1hhhhhhhhKVubh)}(hhh](h)}(hStarting the Cacheh]hStarting the Cache}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj#hhhhhKzubh)}(hThe cache is started by running the daemon. The daemon opens the cache device, configures the cache and tells it to begin caching. At that point the cache binds to fscache and the cache becomes live.h]hThe cache is started by running the daemon. The daemon opens the cache device, configures the cache and tells it to begin caching. At that point the cache binds to fscache and the cache becomes live.}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK|hj#hhubh)}(hThe daemon is run as follows::h]hThe daemon is run as follows:}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj#hhubj)}(h3/sbin/cachefilesd [-d]* [-s] [-n] [-f ]h]h3/sbin/cachefilesd [-d]* [-s] [-n] [-f ]}hjPsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj#hhubh)}(hThe flags are:h]hThe flags are:}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj#hhubjf)}(hXI``-d`` Increase the debugging level. This can be specified multiple times and is cumulative with itself. ``-s`` Send messages to stderr instead of syslog. ``-n`` Don't daemonise and go into background. ``-f `` Use an alternative configuration file rather than the default one. h]j2)}(hhh](j7)}(hj``-d`` Increase the debugging level. This can be specified multiple times and is cumulative with itself. h](j=)}(h``-d``h]hliteral)}(hjyh]h-d}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjwubah}(h]h ]h"]h$]h&]uh1j<hhhKhjsubjM)}(hhh]h)}(hbIncrease the debugging level. This can be specified multiple times and is cumulative with itself.h]hbIncrease the debugging level. This can be specified multiple times and is cumulative with itself.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jLhjsubeh}(h]h ]h"]h$]h&]uh1j6hhhKhjpubj7)}(h2``-s`` Send messages to stderr instead of syslog. h](j=)}(h``-s``h]j|)}(hjh]h-s}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubah}(h]h ]h"]h$]h&]uh1j<hhhKhjubjM)}(hhh]h)}(h*Send messages to stderr instead of syslog.h]h*Send messages to stderr instead of syslog.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jLhjubeh}(h]h ]h"]h$]h&]uh1j6hhhKhjpubj7)}(h/``-n`` Don't daemonise and go into background. h](j=)}(h``-n``h]j|)}(hjh]h-n}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubah}(h]h ]h"]h$]h&]uh1j<hhhKhjubjM)}(hhh]h)}(h'Don't daemonise and go into background.h]h)Don’t daemonise and go into background.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jLhjubeh}(h]h ]h"]h$]h&]uh1j6hhhKhjpubj7)}(hX``-f `` Use an alternative configuration file rather than the default one. h](j=)}(h``-f ``h]j|)}(hj#h]h-f }(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1j{hj!ubah}(h]h ]h"]h$]h&]uh1j<hhhKhjubjM)}(hhh]h)}(hBUse an alternative configuration file rather than the default one.h]hBUse an alternative configuration file rather than the default one.}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj8ubah}(h]h ]h"]h$]h&]uh1jLhjubeh}(h]h ]h"]h$]h&]uh1j6hhhKhjpubeh}(h]h ]h"]h$]h&]uh1j1hjlubah}(h]h ]h"]h$]h&]uh1jehhhKhj#hhubeh}(h]starting-the-cacheah ]h"]starting the cacheah$]h&]uh1hhhhhhhhKzubh)}(hhh](h)}(hThings to Avoidh]hThings to Avoid}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjihhhhhKubh)}(hDo not mount other things within the cache as this will cause problems. The kernel module contains its own very cut-down path walking facility that ignores mountpoints, but the daemon can't avoid them.h]hDo not mount other things within the cache as this will cause problems. The kernel module contains its own very cut-down path walking facility that ignores mountpoints, but the daemon can’t avoid them.}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(hDo not create, rename or unlink files and directories in the cache while the cache is active, as this may cause the state to become uncertain.h]hDo not create, rename or unlink files and directories in the cache while the cache is active, as this may cause the state to become uncertain.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(hsRenaming files in the cache might make objects appear to be other objects (the filename is part of the lookup key).h]hsRenaming files in the cache might make objects appear to be other objects (the filename is part of the lookup key).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(hDo not change or remove the extended attributes attached to cache files by the cache as this will cause the cache state management to get confused.h]hDo not change or remove the extended attributes attached to cache files by the cache as this will cause the cache state management to get confused.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(heDo not create files or directories in the cache, lest the cache get confused or serve incorrect data.h]heDo not create files or directories in the cache, lest the cache get confused or serve incorrect data.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubh)}(hDo not chmod files in the cache. The module creates things with minimal permissions to prevent random users being able to access them directly.h]hDo not chmod files in the cache. The module creates things with minimal permissions to prevent random users being able to access them directly.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjihhubeh}(h]things-to-avoidah ]h"]things to avoidah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Cache Cullingh]h Cache Culling}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXThe cache may need culling occasionally to make space. This involves discarding objects from the cache that have been used less recently than anything else. Culling is based on the access time of data objects. Empty directories are culled if not in use.h]hXThe cache may need culling occasionally to make space. This involves discarding objects from the cache that have been used less recently than anything else. Culling is based on the access time of data objects. Empty directories are culled if not in use.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hCache culling is done on the basis of the percentage of blocks and the percentage of files available in the underlying filesystem. There are six "limits":h]hCache culling is done on the basis of the percentage of blocks and the percentage of files available in the underlying filesystem. There are six “limits”:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjf)}(hXEbrun, frun If the amount of free space and the number of available files in the cache rises above both these limits, then culling is turned off. bcull, fcull If the amount of available space or the number of available files in the cache falls below either of these limits, then culling is started. bstop, fstop If the amount of available space or the number of available files in the cache falls below either of these limits, then no further allocation of disk space or files is permitted until culling has raised things above these limits again. h]j2)}(hhh](j7)}(hbrun, frun If the amount of free space and the number of available files in the cache rises above both these limits, then culling is turned off. h](j=)}(h brun, frunh]h brun, frun}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hhhKhj ubjM)}(hhh]h)}(hIf the amount of free space and the number of available files in the cache rises above both these limits, then culling is turned off.h]hIf the amount of free space and the number of available files in the cache rises above both these limits, then culling is turned off.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jLhj ubeh}(h]h ]h"]h$]h&]uh1j6hhhKhjubj7)}(hbcull, fcull If the amount of available space or the number of available files in the cache falls below either of these limits, then culling is started. h](j=)}(h bcull, fcullh]h bcull, fcull}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1j<hhhKhj9ubjM)}(hhh]h)}(hIf the amount of available space or the number of available files in the cache falls below either of these limits, then culling is started.h]hIf the amount of available space or the number of available files in the cache falls below either of these limits, then culling is started.}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjKubah}(h]h ]h"]h$]h&]uh1jLhj9ubeh}(h]h ]h"]h$]h&]uh1j6hhhKhjubj7)}(hbstop, fstop If the amount of available space or the number of available files in the cache falls below either of these limits, then no further allocation of disk space or files is permitted until culling has raised things above these limits again. h](j=)}(h bstop, fstoph]h bstop, fstop}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hhhKhjhubjM)}(hhh]h)}(hIf the amount of available space or the number of available files in the cache falls below either of these limits, then no further allocation of disk space or files is permitted until culling has raised things above these limits again.h]hIf the amount of available space or the number of available files in the cache falls below either of these limits, then no further allocation of disk space or files is permitted until culling has raised things above these limits again.}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjzubah}(h]h ]h"]h$]h&]uh1jLhjhubeh}(h]h ]h"]h$]h&]uh1j6hhhKhjubeh}(h]h ]h"]h$]h&]uh1j1hjubah}(h]h ]h"]h$]h&]uh1jehhhKhjhhubh)}(h!These must be configured thusly::h]h These must be configured thusly:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h?0 <= bstop < bcull < brun < 100 0 <= fstop < fcull < frun < 100h]h?0 <= bstop < bcull < brun < 100 0 <= fstop < fcull < frun < 100}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubh)}(hNote that these are percentages of available space and available files, and do _not_ appear as 100 minus the percentage displayed by the "df" program.h]hNote that these are percentages of available space and available files, and do _not_ appear as 100 minus the percentage displayed by the “df” program.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hX7The userspace daemon scans the cache to build up a table of cullable objects. These are then culled in least recently used order. A new scan of the cache is started as soon as space is made in the table. Objects will be skipped if their atimes have changed or if the kernel module says it is still using them.h]hX7The userspace daemon scans the cache to build up a table of cullable objects. These are then culled in least recently used order. A new scan of the cache is started as soon as space is made in the table. Objects will be skipped if their atimes have changed or if the kernel module says it is still using them.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h] cache-cullingah ]h"] cache cullingah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hCache Structureh]hCache Structure}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hPThe CacheFiles module will create two directories in the directory it was given:h]hPThe CacheFiles module will create two directories in the directory it was given:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjf)}(h* cache/ * graveyard/ h]jl)}(hhh](jq)}(hcache/h]h)}(hj h]hcache/}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(h graveyard/ h]h)}(h graveyard/h]h graveyard/}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jphjubeh}(h]h ]h"]h$]h&]j*uh1jkhhhKhjubah}(h]h ]h"]h$]h&]uh1jehhhKhjhhubh)}(hThe active cache objects all reside in the first directory. The CacheFiles kernel module moves any retired or culled objects that it can't simply unlink to the graveyard from which the daemon will actually delete them.h]hThe active cache objects all reside in the first directory. The CacheFiles kernel module moves any retired or culled objects that it can’t simply unlink to the graveyard from which the daemon will actually delete them.}(hjEhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hjThe daemon uses dnotify to monitor the graveyard directory, and will delete anything that appears therein.h]hjThe daemon uses dnotify to monitor the graveyard directory, and will delete anything that appears therein.}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe module represents index objects as directories with the filename "I..." or "J...". Note that the "cache/" directory is itself a special index.h]hThe module represents index objects as directories with the filename “I...” or “J...”. Note that the “cache/” directory is itself a special index.}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXData objects are represented as files if they have no children, or directories if they do. Their filenames all begin "D..." or "E...". If represented as a directory, data objects will have a file in the directory called "data" that actually holds the data.h]hXData objects are represented as files if they have no children, or directories if they do. Their filenames all begin “D...” or “E...”. If represented as a directory, data objects will have a file in the directory called “data” that actually holds the data.}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h[Special objects are similar to data objects, except their filenames begin "S..." or "T...".h]hcSpecial objects are similar to data objects, except their filenames begin “S...” or “T...”.}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hX5If an object has children, then it will be represented as a directory. Immediately in the representative directory are a collection of directories named for hash values of the child object keys with an '@' prepended. Into this directory, if possible, will be placed the representations of the child objects::h]hX8If an object has children, then it will be represented as a directory. Immediately in the representative directory are a collection of directories named for hash values of the child object keys with an ‘@’ prepended. Into this directory, if possible, will be placed the representations of the child objects:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hX /INDEX /INDEX /INDEX /DATA FILES /=========/==========/=================================/================ cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400 cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...DB1ry cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...N22ry cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...FP1ryh]hX /INDEX /INDEX /INDEX /DATA FILES /=========/==========/=================================/================ cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400 cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...DB1ry cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...N22ry cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...FP1ry}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubh)}(hXEIf the key is so long that it exceeds NAME_MAX with the decorations added on to it, then it will be cut into pieces, the first few of which will be used to make a nest of directories, and the last one of which will be the objects inside the last directory. The names of the intermediate directories will have '+' prepended::h]hXHIf the key is so long that it exceeds NAME_MAX with the decorations added on to it, then it will be cut into pieces, the first few of which will be used to make a nest of directories, and the last one of which will be the objects inside the last directory. The names of the intermediate directories will have ‘+’ prepended:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hJ1223/@23/+xy...z/+kl...m/Epqrh]hJ1223/@23/+xy...z/+kl...m/Epqr}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhMhjhhubh)}(hNote that keys are raw data, and not only may they exceed NAME_MAX in size, they may also contain things like '/' and NUL characters, and so they may not be suitable for turning directly into a filename.h]hNote that keys are raw data, and not only may they exceed NAME_MAX in size, they may also contain things like ‘/’ and NUL characters, and so they may not be suitable for turning directly into a filename.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hTo handle this, CacheFiles will use a suitably printable filename directly and "base-64" encode ones that aren't directly suitable. The two versions of object filenames indicate the encoding:h]hTo handle this, CacheFiles will use a suitably printable filename directly and “base-64” encode ones that aren’t directly suitable. The two versions of object filenames indicate the encoding:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubjf)}(hX-=============== =============== =============== OBJECT TYPE PRINTABLE ENCODED =============== =============== =============== Index "I..." "J..." Data "D..." "E..." Special "S..." "T..." =============== =============== =============== h]j)}(hhh]j)}(hhh](j )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubhthead)}(hhh]j$)}(hhh](j))}(hhh]h)}(h OBJECT TYPEh]h OBJECT TYPE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hj ubj))}(hhh]h)}(h PRINTABLEh]h PRINTABLE}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj&ubah}(h]h ]h"]h$]h&]uh1j(hj ubj))}(hhh]h)}(hENCODEDh]hENCODED}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj=ubah}(h]h ]h"]h$]h&]uh1j(hj ubeh}(h]h ]h"]h$]h&]uh1j#hj ubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j$)}(hhh](j))}(hhh]h)}(hIndexh]hIndex}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjfubah}(h]h ]h"]h$]h&]uh1j(hjcubj))}(hhh]h)}(h"I..."h]h “I...”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj}ubah}(h]h ]h"]h$]h&]uh1j(hjcubj))}(hhh]h)}(h"J..."h]h “J...”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjcubeh}(h]h ]h"]h$]h&]uh1j#hj`ubj$)}(hhh](j))}(hhh]h)}(hDatah]hData}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(h"D..."h]h “D...”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(h"E..."h]h “E...”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]uh1j#hj`ubj$)}(hhh](j))}(hhh]h)}(hSpecialh]hSpecial}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(h"S..."h]h “S...”}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(h"T..."h]h “T...”}(hj3 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj0 ubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]uh1j#hj`ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]colsKuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jehhhMhjhhubh)}(h>Intermediate directories are always "@" or "+" as appropriate.h]hFIntermediate directories are always “@” or “+” as appropriate.}(hjf hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hEach object in the cache has an extended attribute label that holds the object type ID (required to distinguish special objects) and the auxiliary data from the netfs. The latter is used to detect stale objects in the cache and update or retire them.h]hEach object in the cache has an extended attribute label that holds the object type ID (required to distinguish special objects) and the auxiliary data from the netfs. The latter is used to detect stale objects in the cache and update or retire them.}(hjt hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hNote that CacheFiles will erase from the cache any file it doesn't recognise or any file of an incorrect type (such as a FIFO file or a device file).h]hNote that CacheFiles will erase from the cache any file it doesn’t recognise or any file of an incorrect type (such as a FIFO file or a device file).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubeh}(h]cache-structureah ]h"]cache structureah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hSecurity Model and SELinuxh]hSecurity Model and SELinux}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhM%ubh)}(hwCacheFiles is implemented to deal properly with the LSM security features of the Linux kernel and the SELinux facility.h]hwCacheFiles is implemented to deal properly with the LSM security features of the Linux kernel and the SELinux facility.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM'hj hhubh)}(hXOne of the problems that CacheFiles faces is that it is generally acting on behalf of a process, and running in that process's context, and that includes a security context that is not appropriate for accessing the cache - either because the files in the cache are inaccessible to that process, or because if the process creates a file in the cache, that file may be inaccessible to other processes.h]hXOne of the problems that CacheFiles faces is that it is generally acting on behalf of a process, and running in that process’s context, and that includes a security context that is not appropriate for accessing the cache - either because the files in the cache are inaccessible to that process, or because if the process creates a file in the cache, that file may be inaccessible to other processes.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM*hj hhubh)}(hX4The way CacheFiles works is to temporarily change the security context (fsuid, fsgid and actor security label) that the process acts as - without changing the security context of the process when it the target of an operation performed by some other process (so signalling and suchlike still work correctly).h]hX4The way CacheFiles works is to temporarily change the security context (fsuid, fsgid and actor security label) that the process acts as - without changing the security context of the process when it the target of an operation performed by some other process (so signalling and suchlike still work correctly).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM1hj hhubh)}(h=When the CacheFiles module is asked to bind to its cache, it:h]h=When the CacheFiles module is asked to bind to its cache, it:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM7hj hhubjf)}(hX)(1) Finds the security label attached to the root cache directory and uses that as the security label with which it will create files. By default, this is:: cachefiles_var_t (2) Finds the security label of the process which issued the bind request (presumed to be the cachefilesd daemon), which by default will be:: cachefilesd_t and asks LSM to supply a security ID as which it should act given the daemon's label. By default, this will be:: cachefiles_kernel_t SELinux transitions the daemon's security ID to the module's security ID based on a rule of this form in the policy:: type_transition kernel_t : process ; For instance:: type_transition cachefilesd_t kernel_t : process cachefiles_kernel_t; h]henumerated_list)}(hhh](jq)}(hFinds the security label attached to the root cache directory and uses that as the security label with which it will create files. By default, this is:: cachefiles_var_t h](h)}(hFinds the security label attached to the root cache directory and uses that as the security label with which it will create files. By default, this is::h]hFinds the security label attached to the root cache directory and uses that as the security label with which it will create files. By default, this is:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hj ubj)}(hcachefiles_var_th]hcachefiles_var_t}hj sbah}(h]h ]h"]h$]h&]hhuh1jhhhM=hj ubeh}(h]h ]h"]h$]h&]uh1jphj ubjq)}(hX=Finds the security label of the process which issued the bind request (presumed to be the cachefilesd daemon), which by default will be:: cachefilesd_t and asks LSM to supply a security ID as which it should act given the daemon's label. By default, this will be:: cachefiles_kernel_t SELinux transitions the daemon's security ID to the module's security ID based on a rule of this form in the policy:: type_transition kernel_t : process ; For instance:: type_transition cachefilesd_t kernel_t : process cachefiles_kernel_t; h](h)}(hFinds the security label of the process which issued the bind request (presumed to be the cachefilesd daemon), which by default will be::h]hFinds the security label of the process which issued the bind request (presumed to be the cachefilesd daemon), which by default will be:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM?hj ubj)}(h cachefilesd_th]h cachefilesd_t}hj" sbah}(h]h ]h"]h$]h&]hhuh1jhhhMBhj ubh)}(hqand asks LSM to supply a security ID as which it should act given the daemon's label. By default, this will be::h]hrand asks LSM to supply a security ID as which it should act given the daemon’s label. By default, this will be:}(hj0 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMDhj ubj)}(hcachefiles_kernel_th]hcachefiles_kernel_t}hj> sbah}(h]h ]h"]h$]h&]hhuh1jhhhMGhj ubh)}(huSELinux transitions the daemon's security ID to the module's security ID based on a rule of this form in the policy::h]hxSELinux transitions the daemon’s security ID to the module’s security ID based on a rule of this form in the policy:}(hjL hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMIhj ubj)}(h?type_transition kernel_t : process ;h]h?type_transition kernel_t : process ;}hjZ sbah}(h]h ]h"]h$]h&]hhuh1jhhhMLhj ubh)}(hFor instance::h]h For instance:}(hjh hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMNhj ubj)}(hEtype_transition cachefilesd_t kernel_t : process cachefiles_kernel_t;h]hEtype_transition cachefilesd_t kernel_t : process cachefiles_kernel_t;}hjv sbah}(h]h ]h"]h$]h&]hhuh1jhhhMPhj ubeh}(h]h ]h"]h$]h&]uh1jphj ubeh}(h]h ]h"]h$]h&]enumtypearabicprefix(suffix)uh1j hj ubah}(h]h ]h"]h$]h&]uh1jehhhM9hj hhubh)}(hXThe module's security ID gives it permission to create, move and remove files and directories in the cache, to find and access directories and files in the cache, to set and access extended attributes on cache objects, and to read and write files in the cache.h]hXThe module’s security ID gives it permission to create, move and remove files and directories in the cache, to find and access directories and files in the cache, to set and access extended attributes on cache objects, and to read and write files in the cache.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShj hhubh)}(hX4The daemon's security ID gives it only a very restricted set of permissions: it may scan directories, stat files and erase files and directories. It may not read or write files in the cache, and so it is precluded from accessing the data cached therein; nor is it permitted to create new files in the cache.h]hX6The daemon’s security ID gives it only a very restricted set of permissions: it may scan directories, stat files and erase files and directories. It may not read or write files in the cache, and so it is precluded from accessing the data cached therein; nor is it permitted to create new files in the cache.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMXhj hhubh)}(h+There are policy source files available in:h]h+There are policy source files available in:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM^hj hhubjf)}(hDhttps://people.redhat.com/~dhowells/fscache/cachefilesd-0.8.tar.bz2 h]h)}(hChttps://people.redhat.com/~dhowells/fscache/cachefilesd-0.8.tar.bz2h]h reference)}(hj h]hChttps://people.redhat.com/~dhowells/fscache/cachefilesd-0.8.tar.bz2}(hj hhhNhNubah}(h]h ]h"]h$]h&]refurij uh1j hj ubah}(h]h ]h"]h$]h&]uh1hhhhM`hj ubah}(h]h ]h"]h$]h&]uh1jehhhM`hj hhubh)}(h5and later versions. In that tarball, see the files::h]h4and later versions. In that tarball, see the files:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMbhj hhubj)}(h,cachefilesd.te cachefilesd.fc cachefilesd.ifh]h,cachefilesd.te cachefilesd.fc cachefilesd.if}hj sbah}(h]h ]h"]h$]h&]hhuh1jhhhMdhj hhubh)}(h1They are built and installed directly by the RPM.h]h1They are built and installed directly by the RPM.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhhj hhubh)}(hcIf a non-RPM based system is being used, then copy the above files to their own directory and run::h]hbIf a non-RPM based system is being used, then copy the above files to their own directory and run:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMjhj hhubj)}(hDmake -f /usr/share/selinux/devel/Makefile semodule -i cachefilesd.pph]hDmake -f /usr/share/selinux/devel/Makefile semodule -i cachefilesd.pp}hj" sbah}(h]h ]h"]h$]h&]hhuh1jhhhMmhj hhubh)}(hPYou will need checkpolicy and selinux-policy-devel installed prior to the build.h]hPYou will need checkpolicy and selinux-policy-devel installed prior to the build.}(hj0 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMphj hhubh)}(hBy default, the cache is located in /var/fscache, but if it is desirable that it should be elsewhere, than either the above policy files must be altered, or an auxiliary policy must be installed to label the alternate location of the cache.h]hBy default, the cache is located in /var/fscache, but if it is desirable that it should be elsewhere, than either the above policy files must be altered, or an auxiliary policy must be installed to label the alternate location of the cache.}(hj> hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMthj hhubh)}(hFor instructions on how to add an auxiliary policy to enable the cache to be located elsewhere when SELinux is in enforcing mode, please see::h]hFor instructions on how to add an auxiliary policy to enable the cache to be located elsewhere when SELinux is in enforcing mode, please see:}(hjL hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMyhj hhubj)}(h+/usr/share/doc/cachefilesd-*/move-cache.txth]h+/usr/share/doc/cachefilesd-*/move-cache.txt}hjZ sbah}(h]h ]h"]h$]h&]hhuh1jhhhM|hj hhubh)}(h_When the cachefilesd rpm is installed; alternatively, the document can be found in the sources.h]h_When the cachefilesd rpm is installed; alternatively, the document can be found in the sources.}(hjh hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM~hj hhubeh}(h]security-model-and-selinuxah ]h"]security model and selinuxah$]h&]uh1hhhhhhhhM%ubh)}(hhh](h)}(hA Note on Securityh]hA Note on Security}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj~ hhhhhMubh)}(hCacheFiles makes use of the split security in the task_struct. It allocates its own task_security structure, and redirects current->cred to point to it when it acts on behalf of another process, in that process's context.h]hCacheFiles makes use of the split security in the task_struct. It allocates its own task_security structure, and redirects current->cred to point to it when it acts on behalf of another process, in that process’s context.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj~ hhubh)}(hX_The reason it does this is that it calls vfs_mkdir() and suchlike rather than bypassing security and calling inode ops directly. Therefore the VFS and LSM may deny the CacheFiles access to the cache data because under some circumstances the caching code is running in the security context of whatever process issued the original syscall on the netfs.h]hX_The reason it does this is that it calls vfs_mkdir() and suchlike rather than bypassing security and calling inode ops directly. Therefore the VFS and LSM may deny the CacheFiles access to the cache data because under some circumstances the caching code is running in the security context of whatever process issued the original syscall on the netfs.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj~ hhubh)}(hXNFurthermore, should CacheFiles create a file or directory, the security parameters with that object is created (UID, GID, security label) would be derived from that process that issued the system call, thus potentially preventing other processes from accessing the cache - including CacheFiles's cache management daemon (cachefilesd).h]hXPFurthermore, should CacheFiles create a file or directory, the security parameters with that object is created (UID, GID, security label) would be derived from that process that issued the system call, thus potentially preventing other processes from accessing the cache - including CacheFiles’s cache management daemon (cachefilesd).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj~ hhubh)}(hXXWhat is required is to temporarily override the security of the process that issued the system call. We can't, however, just do an in-place change of the security data as that affects the process as an object, not just as a subject. This means it may lose signals or ptrace events for example, and affects what the process looks like in /proc.h]hXZWhat is required is to temporarily override the security of the process that issued the system call. We can’t, however, just do an in-place change of the security data as that affects the process as an object, not just as a subject. This means it may lose signals or ptrace events for example, and affects what the process looks like in /proc.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj~ hhubh)}(hXSo CacheFiles makes use of a logical split in the security between the objective security (task->real_cred) and the subjective security (task->cred). The objective security holds the intrinsic security properties of a process and is never overridden. This is what appears in /proc, and is what is used when a process is the target of an operation by some other process (SIGKILL for example).h]hXSo CacheFiles makes use of a logical split in the security between the objective security (task->real_cred) and the subjective security (task->cred). The objective security holds the intrinsic security properties of a process and is never overridden. This is what appears in /proc, and is what is used when a process is the target of an operation by some other process (SIGKILL for example).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj~ hhubh)}(hThe subjective security holds the active security properties of a process, and may be overridden. This is not seen externally, and is used when a process acts upon another object, for example SIGKILLing another process or opening a file.h]hThe subjective security holds the active security properties of a process, and may be overridden. This is not seen externally, and is used when a process acts upon another object, for example SIGKILLing another process or opening a file.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj~ hhubh)}(hLSM hooks exist that allow SELinux (or Smack or whatever) to reject a request for CacheFiles to run in a context of a specific security label, or to create files and directories with another security label.h]hLSM hooks exist that allow SELinux (or Smack or whatever) to reject a request for CacheFiles to run in a context of a specific security label, or to create files and directories with another security label.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj~ hhubeh}(h]a-note-on-securityah ]h"]a note on securityah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hStatistical Informationh]hStatistical Information}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(h;If FS-Cache is compiled with the following option enabled::h]h:If FS-Cache is compiled with the following option enabled:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(hCONFIG_CACHEFILES_HISTOGRAM=yh]hCONFIG_CACHEFILES_HISTOGRAM=y}hj sbah}(h]h ]h"]h$]h&]hhuh1jhhhMhj hhubh)}(hLthen it will gather certain statistics and display them through a proc file.h]hLthen it will gather certain statistics and display them through a proc file.}(hj& hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubjf)}(hXE/proc/fs/cachefiles/histogram :: cat /proc/fs/cachefiles/histogram JIFS SECS LOOKUPS MKDIRS CREATES ===== ===== ========= ========= ========= This shows the breakdown of the number of times each amount of time between 0 jiffies and HZ-1 jiffies a variety of tasks took to run. The columns are as follows: ======= ======================================================= COLUMN TIME MEASUREMENT ======= ======================================================= LOOKUPS Length of time to perform a lookup on the backing fs MKDIRS Length of time to perform a mkdir on the backing fs CREATES Length of time to perform a create on the backing fs ======= ======================================================= Each row shows the number of events that took a particular range of times. Each step is 1 jiffy in size. The JIFS column indicates the particular jiffy range covered, and the SECS field the equivalent number of seconds. h](h)}(h/proc/fs/cachefiles/histogramh]h/proc/fs/cachefiles/histogram}(hj8 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4 ubjf)}(hX:: cat /proc/fs/cachefiles/histogram JIFS SECS LOOKUPS MKDIRS CREATES ===== ===== ========= ========= ========= This shows the breakdown of the number of times each amount of time between 0 jiffies and HZ-1 jiffies a variety of tasks took to run. The columns are as follows: ======= ======================================================= COLUMN TIME MEASUREMENT ======= ======================================================= LOOKUPS Length of time to perform a lookup on the backing fs MKDIRS Length of time to perform a mkdir on the backing fs CREATES Length of time to perform a create on the backing fs ======= ======================================================= Each row shows the number of events that took a particular range of times. Each step is 1 jiffy in size. The JIFS column indicates the particular jiffy range covered, and the SECS field the equivalent number of seconds. h](j)}(hscat /proc/fs/cachefiles/histogram JIFS SECS LOOKUPS MKDIRS CREATES ===== ===== ========= ========= =========h]hscat /proc/fs/cachefiles/histogram JIFS SECS LOOKUPS MKDIRS CREATES ===== ===== ========= ========= =========}hjJ sbah}(h]h ]h"]h$]h&]hhuh1jhhhMhjF ubh)}(hThis shows the breakdown of the number of times each amount of time between 0 jiffies and HZ-1 jiffies a variety of tasks took to run. The columns are as follows:h]hThis shows the breakdown of the number of times each amount of time between 0 jiffies and HZ-1 jiffies a variety of tasks took to run. The columns are as follows:}(hjX hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjF ubjf)}(hX======= ======================================================= COLUMN TIME MEASUREMENT ======= ======================================================= LOOKUPS Length of time to perform a lookup on the backing fs MKDIRS Length of time to perform a mkdir on the backing fs CREATES Length of time to perform a create on the backing fs ======= ======================================================= h]j)}(hhh]j)}(hhh](j )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjm ubj )}(hhh]h}(h]h ]h"]h$]h&]colwidthK7uh1jhjm ubj)}(hhh]j$)}(hhh](j))}(hhh]h)}(hCOLUMNh]hCOLUMN}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubj))}(hhh]h)}(hTIME MEASUREMENTh]hTIME MEASUREMENT}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubeh}(h]h ]h"]h$]h&]uh1j#hj ubah}(h]h ]h"]h$]h&]uh1jhjm ubj)}(hhh](j$)}(hhh](j))}(hhh]h)}(hLOOKUPSh]hLOOKUPS}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubj))}(hhh]h)}(h4Length of time to perform a lookup on the backing fsh]h4Length of time to perform a lookup on the backing fs}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubeh}(h]h ]h"]h$]h&]uh1j#hj ubj$)}(hhh](j))}(hhh]h)}(hMKDIRSh]hMKDIRS}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubj))}(hhh]h)}(h3Length of time to perform a mkdir on the backing fsh]h3Length of time to perform a mkdir on the backing fs}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubeh}(h]h ]h"]h$]h&]uh1j#hj ubj$)}(hhh](j))}(hhh]h)}(hCREATESh]hCREATES}(hj; hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj8 ubah}(h]h ]h"]h$]h&]uh1j(hj5 ubj))}(hhh]h)}(h4Length of time to perform a create on the backing fsh]h4Length of time to perform a create on the backing fs}(hjR hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjO ubah}(h]h ]h"]h$]h&]uh1j(hj5 ubeh}(h]h ]h"]h$]h&]uh1j#hj ubeh}(h]h ]h"]h$]h&]uh1jhjm ubeh}(h]h ]h"]h$]h&]colsKuh1jhjj ubah}(h]h ]h"]h$]h&]uh1jhjf ubah}(h]h ]h"]h$]h&]uh1jehhhMhjF ubh)}(hEach row shows the number of events that took a particular range of times. Each step is 1 jiffy in size. The JIFS column indicates the particular jiffy range covered, and the SECS field the equivalent number of seconds.h]hEach row shows the number of events that took a particular range of times. Each step is 1 jiffy in size. The JIFS column indicates the particular jiffy range covered, and the SECS field the equivalent number of seconds.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjF ubeh}(h]h ]h"]h$]h&]uh1jehhhMzhj4 ubeh}(h]h ]h"]h$]h&]uh1jehhhMhj hhubeh}(h]statistical-informationah ]h"]statistical informationah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h Debuggingh]h Debugging}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(h}If CONFIG_CACHEFILES_DEBUG is enabled, the CacheFiles facility can have runtime debugging enabled by adjusting the value in::h]h|If CONFIG_CACHEFILES_DEBUG is enabled, the CacheFiles facility can have runtime debugging enabled by adjusting the value in:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(h'/sys/module/cachefiles/parameters/debugh]h'/sys/module/cachefiles/parameters/debug}hj sbah}(h]h ]h"]h$]h&]hhuh1jhhhMhj hhubh)}(h1This is a bitmask of debugging streams to enable:h]h1This is a bitmask of debugging streams to enable:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubjf)}(hX======= ======= =============================== ======================= BIT VALUE STREAM POINT ======= ======= =============================== ======================= 0 1 General Function entry trace 1 2 Function exit trace 2 4 General ======= ======= =============================== ======================= h]j)}(hhh]j)}(hhh](j )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhj ubj )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhj ubj )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhj ubj )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhj ubj)}(hhh]j$)}(hhh](j))}(hhh]h)}(hBITh]hBIT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(hVALUEh]hVALUE}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj1ubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(hSTREAMh]hSTREAM}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjHubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(hPOINTh]hPOINT}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj_ubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]uh1j#hjubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh](j$)}(hhh](j))}(hhh]h)}(h0h]h0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(hj/h]h1}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(hGeneralh]hGeneral}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(hFunction entry traceh]hFunction entry trace}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hhh](j))}(hhh]h)}(hj/h]h1}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(hjfh]h2}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhh]h)}(hFunction exit traceh]hFunction exit trace}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj!ubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]uh1j#hjubj$)}(hhh](j))}(hhh]h)}(hjfh]h2}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjAubah}(h]h ]h"]h$]h&]uh1j(hj>ubj))}(hhh]h)}(hjh]h4}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjWubah}(h]h ]h"]h$]h&]uh1j(hj>ubj))}(hhh]h}(h]h ]h"]h$]h&]uh1j(hj>ubj))}(hhh]h)}(hGeneralh]hGeneral}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjvubah}(h]h ]h"]h$]h&]uh1j(hj>ubeh}(h]h ]h"]h$]h&]uh1j#hjubeh}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]colsKuh1jhj ubah}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1jehhhMhj hhubh)}(hpThe appropriate set of values should be OR'd together and the result written to the control file. For example::h]hqThe appropriate set of values should be OR’d together and the result written to the control file. For example:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(h8echo $((1|4|8)) >/sys/module/cachefiles/parameters/debugh]h8echo $((1|4|8)) >/sys/module/cachefiles/parameters/debug}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhMhj hhubh)}(h*will turn on all function entry debugging.h]h*will turn on all function entry debugging.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h] debuggingah ]h"] debuggingah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hOn-demand Readh]hOn-demand Read}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hWhen working in its original mode, CacheFiles serves as a local cache for a remote networking fs - while in on-demand read mode, CacheFiles can boost the scenario where on-demand read semantics are needed, e.g. container image distribution.h]hWhen working in its original mode, CacheFiles serves as a local cache for a remote networking fs - while in on-demand read mode, CacheFiles can boost the scenario where on-demand read semantics are needed, e.g. container image distribution.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hX)The essential difference between these two modes is seen when a cache miss occurs: In the original mode, the netfs will fetch the data from the remote server and then write it to the cache file; in on-demand read mode, fetching the data and writing it into the cache is delegated to a user daemon.h]hX)The essential difference between these two modes is seen when a cache miss occurs: In the original mode, the netfs will fetch the data from the remote server and then write it to the cache file; in on-demand read mode, fetching the data and writing it into the cache is delegated to a user daemon.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hP``CONFIG_CACHEFILES_ONDEMAND`` should be enabled to support on-demand read mode.h](j|)}(h``CONFIG_CACHEFILES_ONDEMAND``h]hCONFIG_CACHEFILES_ONDEMAND}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hj ubh2 should be enabled to support on-demand read mode.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hhh](h)}(hProtocol Communicationh]hProtocol Communication}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj'hhhhhMubh)}(hThe on-demand read mode uses a simple protocol for communication between kernel and user daemon. The protocol can be modeled as::h]hThe on-demand read mode uses a simple protocol for communication between kernel and user daemon. The protocol can be modeled as:}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj'hhubj)}(h5kernel --[request]--> user daemon --[reply]--> kernelh]h5kernel --[request]--> user daemon --[reply]--> kernel}hjFsbah}(h]h ]h"]h$]h&]hhuh1jhhhMhj'hhubh)}(hCacheFiles will send requests to the user daemon when needed. The user daemon should poll the devnode ('/dev/cachefiles') to check if there's a pending request to be processed. A POLLIN event will be returned when there's a pending request.h]hCacheFiles will send requests to the user daemon when needed. The user daemon should poll the devnode (‘/dev/cachefiles’) to check if there’s a pending request to be processed. A POLLIN event will be returned when there’s a pending request.}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj'hhubh)}(hThe user daemon then reads the devnode to fetch a request to process. It should be noted that each read only gets one request. When it has finished processing the request, the user daemon should write the reply to the devnode.h]hThe user daemon then reads the devnode to fetch a request to process. It should be noted that each read only gets one request. When it has finished processing the request, the user daemon should write the reply to the devnode.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj'hhubh)}(h7Each request starts with a message header of the form::h]h6Each request starts with a message header of the form:}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj'hhubj)}(hstruct cachefiles_msg { __u32 msg_id; __u32 opcode; __u32 len; __u32 object_id; __u8 data[]; };h]hstruct cachefiles_msg { __u32 msg_id; __u32 opcode; __u32 len; __u32 object_id; __u8 data[]; };}hj~sbah}(h]h ]h"]h$]h&]hhuh1jhhhM hj'hhubh)}(hwhere:h]hwhere:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj'hhubjf)}(hXt* ``msg_id`` is a unique ID identifying this request among all pending requests. * ``opcode`` indicates the type of this request. * ``object_id`` is a unique ID identifying the cache file operated on. * ``data`` indicates the payload of this request. * ``len`` indicates the whole length of this request, including the header and following type-specific payload. h]jl)}(hhh](jq)}(hO``msg_id`` is a unique ID identifying this request among all pending requests. h]h)}(hN``msg_id`` is a unique ID identifying this request among all pending requests.h](j|)}(h ``msg_id``h]hmsg_id}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubhD is a unique ID identifying this request among all pending requests.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(h/``opcode`` indicates the type of this request. h]h)}(h.``opcode`` indicates the type of this request.h](j|)}(h ``opcode``h]hopcode}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh$ indicates the type of this request.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(hE``object_id`` is a unique ID identifying the cache file operated on. h]h)}(hD``object_id`` is a unique ID identifying the cache file operated on.h](j|)}(h ``object_id``h]h object_id}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh7 is a unique ID identifying the cache file operated on.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(h0``data`` indicates the payload of this request. h]h)}(h/``data`` indicates the payload of this request.h](j|)}(h``data``h]hdata}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh' indicates the payload of this request.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(ho``len`` indicates the whole length of this request, including the header and following type-specific payload. h]h)}(hm``len`` indicates the whole length of this request, including the header and following type-specific payload.h](j|)}(h``len``h]hlen}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hj=ubhf indicates the whole length of this request, including the header and following type-specific payload.}(hj=hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj9ubah}(h]h ]h"]h$]h&]uh1jphjubeh}(h]h ]h"]h$]h&]jj>uh1jkhhhMhjubah}(h]h ]h"]h$]h&]uh1jehhhMhj'hhubeh}(h]protocol-communicationah ]h"]protocol communicationah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hTurning on On-demand Modeh]hTurning on On-demand Mode}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjshhhhhM#ubh)}(h?An optional parameter becomes available to the "bind" command::h]hBAn optional parameter becomes available to the “bind” command:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hjshhubj)}(hbind [ondemand]h]hbind [ondemand]}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhM'hjshhubh)}(hWhen the "bind" command is given no argument, it defaults to the original mode. When it is given the "ondemand" argument, i.e. "bind ondemand", on-demand read mode will be enabled.h]hWhen the “bind” command is given no argument, it defaults to the original mode. When it is given the “ondemand” argument, i.e. “bind ondemand”, on-demand read mode will be enabled.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM)hjshhubeh}(h]turning-on-on-demand-modeah ]h"]turning on on-demand modeah$]h&]uh1hhjhhhhhM#ubh)}(hhh](h)}(hThe OPEN Requesth]hThe OPEN Request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM/ubh)}(hWhen the netfs opens a cache file for the first time, a request with the CACHEFILES_OP_OPEN opcode, a.k.a an OPEN request will be sent to the user daemon. The payload format is of the form::h]hWhen the netfs opens a cache file for the first time, a request with the CACHEFILES_OP_OPEN opcode, a.k.a an OPEN request will be sent to the user daemon. The payload format is of the form:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM1hjhhubj)}(hstruct cachefiles_open { __u32 volume_key_size; __u32 cookie_key_size; __u32 fd; __u32 flags; __u8 data[]; };h]hstruct cachefiles_open { __u32 volume_key_size; __u32 cookie_key_size; __u32 fd; __u32 flags; __u8 data[]; };}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhM5hjhhubh)}(hwhere:h]hwhere:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM=hjhhubjf)}(hX* ``data`` contains the volume_key followed directly by the cookie_key. The volume key is a NUL-terminated string; the cookie key is binary data. * ``volume_key_size`` indicates the size of the volume key in bytes. * ``cookie_key_size`` indicates the size of the cookie key in bytes. * ``fd`` indicates an anonymous fd referring to the cache file, through which the user daemon can perform write/llseek file operations on the cache file. h]jl)}(hhh](jq)}(h``data`` contains the volume_key followed directly by the cookie_key. The volume key is a NUL-terminated string; the cookie key is binary data. h]h)}(h``data`` contains the volume_key followed directly by the cookie_key. The volume key is a NUL-terminated string; the cookie key is binary data.h](j|)}(h``data``h]hdata}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh contains the volume_key followed directly by the cookie_key. The volume key is a NUL-terminated string; the cookie key is binary data.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM?hjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(hC``volume_key_size`` indicates the size of the volume key in bytes. h]h)}(hB``volume_key_size`` indicates the size of the volume key in bytes.h](j|)}(h``volume_key_size``h]hvolume_key_size}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1j{hj"ubh/ indicates the size of the volume key in bytes.}(hj"hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMChjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(hC``cookie_key_size`` indicates the size of the cookie key in bytes. h]h)}(hB``cookie_key_size`` indicates the size of the cookie key in bytes.h](j|)}(h``cookie_key_size``h]hcookie_key_size}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjHubh/ indicates the size of the cookie key in bytes.}(hjHhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMEhjDubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(h``fd`` indicates an anonymous fd referring to the cache file, through which the user daemon can perform write/llseek file operations on the cache file. h]h)}(h``fd`` indicates an anonymous fd referring to the cache file, through which the user daemon can perform write/llseek file operations on the cache file.h](j|)}(h``fd``h]hfd}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjnubh indicates an anonymous fd referring to the cache file, through which the user daemon can perform write/llseek file operations on the cache file.}(hjnhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMGhjjubah}(h]h ]h"]h$]h&]uh1jphjubeh}(h]h ]h"]h$]h&]jj>uh1jkhhhM?hjubah}(h]h ]h"]h$]h&]uh1jehhhM?hjhhubh)}(hXThe user daemon can use the given (volume_key, cookie_key) pair to distinguish the requested cache file. With the given anonymous fd, the user daemon can fetch the data and write it to the cache file in the background, even when kernel has not triggered a cache miss yet.h]hXThe user daemon can use the given (volume_key, cookie_key) pair to distinguish the requested cache file. With the given anonymous fd, the user daemon can fetch the data and write it to the cache file in the background, even when kernel has not triggered a cache miss yet.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMLhjhhubh)}(hXMBe noted that each cache file has a unique object_id, while it may have multiple anonymous fds. The user daemon may duplicate anonymous fds from the initial anonymous fd indicated by the @fd field through dup(). Thus each object_id can be mapped to multiple anonymous fds, while the usr daemon itself needs to maintain the mapping.h]hXMBe noted that each cache file has a unique object_id, while it may have multiple anonymous fds. The user daemon may duplicate anonymous fds from the initial anonymous fd indicated by the @fd field through dup(). Thus each object_id can be mapped to multiple anonymous fds, while the usr daemon itself needs to maintain the mapping.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMQhjhhubh)}(hX When implementing a user daemon, please be careful of RLIMIT_NOFILE, ``/proc/sys/fs/nr_open`` and ``/proc/sys/fs/file-max``. Typically these needn't be huge since they're related to the number of open device blobs rather than open files of each individual filesystem.h](hEWhen implementing a user daemon, please be careful of RLIMIT_NOFILE, }(hjhhhNhNubj|)}(h``/proc/sys/fs/nr_open``h]h/proc/sys/fs/nr_open}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh and }(hjhhhNhNubj|)}(h``/proc/sys/fs/file-max``h]h/proc/sys/fs/file-max}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh. Typically these needn’t be huge since they’re related to the number of open device blobs rather than open files of each individual filesystem.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMWhjhhubh)}(hkThe user daemon should reply the OPEN request by issuing a "copen" (complete open) command on the devnode::h]hnThe user daemon should reply the OPEN request by issuing a “copen” (complete open) command on the devnode:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM\hjhhubj)}(hcopen ,h]hcopen ,}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhM_hjhhubh)}(hwhere:h]hwhere:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMahjhhubjf)}(h* ``msg_id`` must match the msg_id field of the OPEN request. * When >= 0, ``cache_size`` indicates the size of the cache file; when < 0, ``cache_size`` indicates any error code encountered by the user daemon. h]jl)}(hhh](jq)}(h<``msg_id`` must match the msg_id field of the OPEN request. h]h)}(h;``msg_id`` must match the msg_id field of the OPEN request.h](j|)}(h ``msg_id``h]hmsg_id}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh1 must match the msg_id field of the OPEN request.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMchjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(hWhen >= 0, ``cache_size`` indicates the size of the cache file; when < 0, ``cache_size`` indicates any error code encountered by the user daemon. h]h)}(hWhen >= 0, ``cache_size`` indicates the size of the cache file; when < 0, ``cache_size`` indicates any error code encountered by the user daemon.h](h When >= 0, }(hjEhhhNhNubj|)}(h``cache_size``h]h cache_size}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjEubh1 indicates the size of the cache file; when < 0, }(hjEhhhNhNubj|)}(h``cache_size``h]h cache_size}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjEubh9 indicates any error code encountered by the user daemon.}(hjEhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMehjAubah}(h]h ]h"]h$]h&]uh1jphjubeh}(h]h ]h"]h$]h&]jj>uh1jkhhhMchjubah}(h]h ]h"]h$]h&]uh1jehhhMchjhhubeh}(h]the-open-requestah ]h"]the open requestah$]h&]uh1hhjhhhhhM/ubh)}(hhh](h)}(hThe CLOSE Requesth]hThe CLOSE Request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMkubh)}(hXWhen a cookie withdrawn, a CLOSE request (opcode CACHEFILES_OP_CLOSE) will be sent to the user daemon. This tells the user daemon to close all anonymous fds associated with the given object_id. The CLOSE request has no extra payload, and shouldn't be replied.h]hXWhen a cookie withdrawn, a CLOSE request (opcode CACHEFILES_OP_CLOSE) will be sent to the user daemon. This tells the user daemon to close all anonymous fds associated with the given object_id. The CLOSE request has no extra payload, and shouldn’t be replied.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMmhjhhubeh}(h]the-close-requestah ]h"]the close requestah$]h&]uh1hhjhhhhhMkubh)}(hhh](h)}(hThe READ Requesth]hThe READ Request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMtubh)}(hWhen a cache miss is encountered in on-demand read mode, CacheFiles will send a READ request (opcode CACHEFILES_OP_READ) to the user daemon. This tells the user daemon to fetch the contents of the requested file range. The payload is of the form::h]hWhen a cache miss is encountered in on-demand read mode, CacheFiles will send a READ request (opcode CACHEFILES_OP_READ) to the user daemon. This tells the user daemon to fetch the contents of the requested file range. The payload is of the form:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMvhjhhubj)}(hAstruct cachefiles_read { __u64 off; __u64 len; };h]hAstruct cachefiles_read { __u64 off; __u64 len; };}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhM{hjhhubh)}(hwhere:h]hwhere:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjf)}(h* ``off`` indicates the starting offset of the requested file range. * ``len`` indicates the length of the requested file range. h]jl)}(hhh](jq)}(hC``off`` indicates the starting offset of the requested file range. h]h)}(hB``off`` indicates the starting offset of the requested file range.h](j|)}(h``off``h]hoff}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh; indicates the starting offset of the requested file range.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(h;``len`` indicates the length of the requested file range. h]h)}(h9``len`` indicates the length of the requested file range.h](j|)}(h``len``h]hlen}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1j{hj$ubh2 indicates the length of the requested file range.}(hj$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jphjubeh}(h]h ]h"]h$]h&]jj>uh1jkhhhMhjubah}(h]h ]h"]h$]h&]uh1jehhhMhjhhubh)}(hWhen it receives a READ request, the user daemon should fetch the requested data and write it to the cache file identified by object_id.h]hWhen it receives a READ request, the user daemon should fetch the requested data and write it to the cache file identified by object_id.}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hWhen it has finished processing the READ request, the user daemon should reply by using the CACHEFILES_IOC_READ_COMPLETE ioctl on one of the anonymous fds associated with the object_id given in the READ request. The ioctl is of the form::h]hWhen it has finished processing the READ request, the user daemon should reply by using the CACHEFILES_IOC_READ_COMPLETE ioctl on one of the anonymous fds associated with the object_id given in the READ request. The ioctl is of the form:}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h0ioctl(fd, CACHEFILES_IOC_READ_COMPLETE, msg_id);h]h0ioctl(fd, CACHEFILES_IOC_READ_COMPLETE, msg_id);}hjnsbah}(h]h ]h"]h$]h&]hhuh1jhhhMhjhhubh)}(hwhere:h]hwhere:}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjf)}(h* ``fd`` is one of the anonymous fds associated with the object_id given. * ``msg_id`` must match the msg_id field of the READ request.h]jl)}(hhh](jq)}(hH``fd`` is one of the anonymous fds associated with the object_id given. h]h)}(hG``fd`` is one of the anonymous fds associated with the object_id given.h](j|)}(h``fd``h]hfd}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubhA is one of the anonymous fds associated with the object_id given.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jphjubjq)}(h;``msg_id`` must match the msg_id field of the READ request.h]h)}(hjh](j|)}(h ``msg_id``h]hmsg_id}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j{hjubh1 must match the msg_id field of the READ request.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jphjubeh}(h]h ]h"]h$]h&]jj>uh1jkhhhMhjubah}(h]h ]h"]h$]h&]uh1jehhhMhjhhubeh}(h]the-read-requestah ]h"]the read requestah$]h&]uh1hhjhhhhhMtubeh}(h]on-demand-readah ]h"]on-demand readah$]h&]uh1hhhhhhhhMubeh}(h]#cache-on-already-mounted-filesystemah ]h"]#cache on already mounted filesystemah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksj(footnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj"error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjCj@j jj jjfjcjjjjj j j{ jx j j j j jjjjjpjmjjjjjjjju nametypes}(jjCj j jfjjj j{ j j jjjpjjjjuh}(jhj@hjjFjjjcj#jjijjj jjx j j j~ j j jj jjjmj'jjsjjjjjju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.