1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun========================== 4*4882a593SmuzhiyunGeneral Filesystem Caching 5*4882a593Smuzhiyun========================== 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunOverview 8*4882a593Smuzhiyun======== 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunThis facility is a general purpose cache for network filesystems, though it 11*4882a593Smuzhiyuncould be used for caching other things such as ISO9660 filesystems too. 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunFS-Cache mediates between cache backends (such as CacheFS) and network 14*4882a593Smuzhiyunfilesystems:: 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun +---------+ 17*4882a593Smuzhiyun | | +--------------+ 18*4882a593Smuzhiyun | NFS |--+ | | 19*4882a593Smuzhiyun | | | +-->| CacheFS | 20*4882a593Smuzhiyun +---------+ | +----------+ | | /dev/hda5 | 21*4882a593Smuzhiyun | | | | +--------------+ 22*4882a593Smuzhiyun +---------+ +-->| | | 23*4882a593Smuzhiyun | | | |--+ 24*4882a593Smuzhiyun | AFS |----->| FS-Cache | 25*4882a593Smuzhiyun | | | |--+ 26*4882a593Smuzhiyun +---------+ +-->| | | 27*4882a593Smuzhiyun | | | | +--------------+ 28*4882a593Smuzhiyun +---------+ | +----------+ | | | 29*4882a593Smuzhiyun | | | +-->| CacheFiles | 30*4882a593Smuzhiyun | ISOFS |--+ | /var/cache | 31*4882a593Smuzhiyun | | +--------------+ 32*4882a593Smuzhiyun +---------+ 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunOr to look at it another way, FS-Cache is a module that provides a caching 35*4882a593Smuzhiyunfacility to a network filesystem such that the cache is transparent to the 36*4882a593Smuzhiyunuser:: 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun +---------+ 39*4882a593Smuzhiyun | | 40*4882a593Smuzhiyun | Server | 41*4882a593Smuzhiyun | | 42*4882a593Smuzhiyun +---------+ 43*4882a593Smuzhiyun | NETWORK 44*4882a593Smuzhiyun ~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 45*4882a593Smuzhiyun | 46*4882a593Smuzhiyun | +----------+ 47*4882a593Smuzhiyun V | | 48*4882a593Smuzhiyun +---------+ | | 49*4882a593Smuzhiyun | | | | 50*4882a593Smuzhiyun | NFS |----->| FS-Cache | 51*4882a593Smuzhiyun | | | |--+ 52*4882a593Smuzhiyun +---------+ | | | +--------------+ +--------------+ 53*4882a593Smuzhiyun | | | | | | | | 54*4882a593Smuzhiyun V +----------+ +-->| CacheFiles |-->| Ext3 | 55*4882a593Smuzhiyun +---------+ | /var/cache | | /dev/sda6 | 56*4882a593Smuzhiyun | | +--------------+ +--------------+ 57*4882a593Smuzhiyun | VFS | ^ ^ 58*4882a593Smuzhiyun | | | | 59*4882a593Smuzhiyun +---------+ +--------------+ | 60*4882a593Smuzhiyun | KERNEL SPACE | | 61*4882a593Smuzhiyun ~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~|~~~~ 62*4882a593Smuzhiyun | USER SPACE | | 63*4882a593Smuzhiyun V | | 64*4882a593Smuzhiyun +---------+ +--------------+ 65*4882a593Smuzhiyun | | | | 66*4882a593Smuzhiyun | Process | | cachefilesd | 67*4882a593Smuzhiyun | | | | 68*4882a593Smuzhiyun +---------+ +--------------+ 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun 71*4882a593SmuzhiyunFS-Cache does not follow the idea of completely loading every netfs file 72*4882a593Smuzhiyunopened in its entirety into a cache before permitting it to be accessed and 73*4882a593Smuzhiyunthen serving the pages out of that cache rather than the netfs inode because: 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun (1) It must be practical to operate without a cache. 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun (2) The size of any accessible file must not be limited to the size of the 78*4882a593Smuzhiyun cache. 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun (3) The combined size of all opened files (this includes mapped libraries) 81*4882a593Smuzhiyun must not be limited to the size of the cache. 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun (4) The user should not be forced to download an entire file just to do a 84*4882a593Smuzhiyun one-off access of a small portion of it (such as might be done with the 85*4882a593Smuzhiyun "file" program). 86*4882a593Smuzhiyun 87*4882a593SmuzhiyunIt instead serves the cache out in PAGE_SIZE chunks as and when requested by 88*4882a593Smuzhiyunthe netfs('s) using it. 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun 91*4882a593SmuzhiyunFS-Cache provides the following facilities: 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun (1) More than one cache can be used at once. Caches can be selected 94*4882a593Smuzhiyun explicitly by use of tags. 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun (2) Caches can be added / removed at any time. 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun (3) The netfs is provided with an interface that allows either party to 99*4882a593Smuzhiyun withdraw caching facilities from a file (required for (2)). 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun (4) The interface to the netfs returns as few errors as possible, preferring 102*4882a593Smuzhiyun rather to let the netfs remain oblivious. 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun (5) Cookies are used to represent indices, files and other objects to the 105*4882a593Smuzhiyun netfs. The simplest cookie is just a NULL pointer - indicating nothing 106*4882a593Smuzhiyun cached there. 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun (6) The netfs is allowed to propose - dynamically - any index hierarchy it 109*4882a593Smuzhiyun desires, though it must be aware that the index search function is 110*4882a593Smuzhiyun recursive, stack space is limited, and indices can only be children of 111*4882a593Smuzhiyun indices. 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun (7) Data I/O is done direct to and from the netfs's pages. The netfs 114*4882a593Smuzhiyun indicates that page A is at index B of the data-file represented by cookie 115*4882a593Smuzhiyun C, and that it should be read or written. The cache backend may or may 116*4882a593Smuzhiyun not start I/O on that page, but if it does, a netfs callback will be 117*4882a593Smuzhiyun invoked to indicate completion. The I/O may be either synchronous or 118*4882a593Smuzhiyun asynchronous. 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun (8) Cookies can be "retired" upon release. At this point FS-Cache will mark 121*4882a593Smuzhiyun them as obsolete and the index hierarchy rooted at that point will get 122*4882a593Smuzhiyun recycled. 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun (9) The netfs provides a "match" function for index searches. In addition to 125*4882a593Smuzhiyun saying whether a match was made or not, this can also specify that an 126*4882a593Smuzhiyun entry should be updated or deleted. 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun(10) As much as possible is done asynchronously. 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun 131*4882a593SmuzhiyunFS-Cache maintains a virtual indexing tree in which all indices, files, objects 132*4882a593Smuzhiyunand pages are kept. Bits of this tree may actually reside in one or more 133*4882a593Smuzhiyuncaches:: 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun FSDEF 136*4882a593Smuzhiyun | 137*4882a593Smuzhiyun +------------------------------------+ 138*4882a593Smuzhiyun | | 139*4882a593Smuzhiyun NFS AFS 140*4882a593Smuzhiyun | | 141*4882a593Smuzhiyun +--------------------------+ +-----------+ 142*4882a593Smuzhiyun | | | | 143*4882a593Smuzhiyun homedir mirror afs.org redhat.com 144*4882a593Smuzhiyun | | | 145*4882a593Smuzhiyun +------------+ +---------------+ +----------+ 146*4882a593Smuzhiyun | | | | | | 147*4882a593Smuzhiyun 00001 00002 00007 00125 vol00001 vol00002 148*4882a593Smuzhiyun | | | | | 149*4882a593Smuzhiyun +---+---+ +-----+ +---+ +------+------+ +-----+----+ 150*4882a593Smuzhiyun | | | | | | | | | | | | | 151*4882a593Smuzhiyun PG0 PG1 PG2 PG0 XATTR PG0 PG1 DIRENT DIRENT DIRENT R/W R/O Bak 152*4882a593Smuzhiyun | | 153*4882a593Smuzhiyun PG0 +-------+ 154*4882a593Smuzhiyun | | 155*4882a593Smuzhiyun 00001 00003 156*4882a593Smuzhiyun | 157*4882a593Smuzhiyun +---+---+ 158*4882a593Smuzhiyun | | | 159*4882a593Smuzhiyun PG0 PG1 PG2 160*4882a593Smuzhiyun 161*4882a593SmuzhiyunIn the example above, you can see two netfs's being backed: NFS and AFS. These 162*4882a593Smuzhiyunhave different index hierarchies: 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun * The NFS primary index contains per-server indices. Each server index is 165*4882a593Smuzhiyun indexed by NFS file handles to get data file objects. Each data file 166*4882a593Smuzhiyun objects can have an array of pages, but may also have further child 167*4882a593Smuzhiyun objects, such as extended attributes and directory entries. Extended 168*4882a593Smuzhiyun attribute objects themselves have page-array contents. 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun * The AFS primary index contains per-cell indices. Each cell index contains 171*4882a593Smuzhiyun per-logical-volume indices. Each of volume index contains up to three 172*4882a593Smuzhiyun indices for the read-write, read-only and backup mirrors of those volumes. 173*4882a593Smuzhiyun Each of these contains vnode data file objects, each of which contains an 174*4882a593Smuzhiyun array of pages. 175*4882a593Smuzhiyun 176*4882a593SmuzhiyunThe very top index is the FS-Cache master index in which individual netfs's 177*4882a593Smuzhiyunhave entries. 178*4882a593Smuzhiyun 179*4882a593SmuzhiyunAny index object may reside in more than one cache, provided it only has index 180*4882a593Smuzhiyunchildren. Any index with non-index object children will be assumed to only 181*4882a593Smuzhiyunreside in one cache. 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun 184*4882a593SmuzhiyunThe netfs API to FS-Cache can be found in: 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun Documentation/filesystems/caching/netfs-api.rst 187*4882a593Smuzhiyun 188*4882a593SmuzhiyunThe cache backend API to FS-Cache can be found in: 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun Documentation/filesystems/caching/backend-api.rst 191*4882a593Smuzhiyun 192*4882a593SmuzhiyunA description of the internal representations and object state machine can be 193*4882a593Smuzhiyunfound in: 194*4882a593Smuzhiyun 195*4882a593Smuzhiyun Documentation/filesystems/caching/object.rst 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun 198*4882a593SmuzhiyunStatistical Information 199*4882a593Smuzhiyun======================= 200*4882a593Smuzhiyun 201*4882a593SmuzhiyunIf FS-Cache is compiled with the following options enabled:: 202*4882a593Smuzhiyun 203*4882a593Smuzhiyun CONFIG_FSCACHE_STATS=y 204*4882a593Smuzhiyun CONFIG_FSCACHE_HISTOGRAM=y 205*4882a593Smuzhiyun 206*4882a593Smuzhiyunthen it will gather certain statistics and display them through a number of 207*4882a593Smuzhiyunproc files. 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun/proc/fs/fscache/stats 210*4882a593Smuzhiyun---------------------- 211*4882a593Smuzhiyun 212*4882a593Smuzhiyun This shows counts of a number of events that can happen in FS-Cache: 213*4882a593Smuzhiyun 214*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 215*4882a593Smuzhiyun|CLASS |EVENT |MEANING | 216*4882a593Smuzhiyun+==============+=======+=======================================================+ 217*4882a593Smuzhiyun|Cookies |idx=N |Number of index cookies allocated | 218*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 219*4882a593Smuzhiyun| |dat=N |Number of data storage cookies allocated | 220*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 221*4882a593Smuzhiyun| |spc=N |Number of special cookies allocated | 222*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 223*4882a593Smuzhiyun|Objects |alc=N |Number of objects allocated | 224*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 225*4882a593Smuzhiyun| |nal=N |Number of object allocation failures | 226*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 227*4882a593Smuzhiyun| |avl=N |Number of objects that reached the available state | 228*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 229*4882a593Smuzhiyun| |ded=N |Number of objects that reached the dead state | 230*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 231*4882a593Smuzhiyun|ChkAux |non=N |Number of objects that didn't have a coherency check | 232*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 233*4882a593Smuzhiyun| |ok=N |Number of objects that passed a coherency check | 234*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 235*4882a593Smuzhiyun| |upd=N |Number of objects that needed a coherency data update | 236*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 237*4882a593Smuzhiyun| |obs=N |Number of objects that were declared obsolete | 238*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 239*4882a593Smuzhiyun|Pages |mrk=N |Number of pages marked as being cached | 240*4882a593Smuzhiyun| |unc=N |Number of uncache page requests seen | 241*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 242*4882a593Smuzhiyun|Acquire |n=N |Number of acquire cookie requests seen | 243*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 244*4882a593Smuzhiyun| |nul=N |Number of acq reqs given a NULL parent | 245*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 246*4882a593Smuzhiyun| |noc=N |Number of acq reqs rejected due to no cache available | 247*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 248*4882a593Smuzhiyun| |ok=N |Number of acq reqs succeeded | 249*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 250*4882a593Smuzhiyun| |nbf=N |Number of acq reqs rejected due to error | 251*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 252*4882a593Smuzhiyun| |oom=N |Number of acq reqs failed on ENOMEM | 253*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 254*4882a593Smuzhiyun|Lookups |n=N |Number of lookup calls made on cache backends | 255*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 256*4882a593Smuzhiyun| |neg=N |Number of negative lookups made | 257*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 258*4882a593Smuzhiyun| |pos=N |Number of positive lookups made | 259*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 260*4882a593Smuzhiyun| |crt=N |Number of objects created by lookup | 261*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 262*4882a593Smuzhiyun| |tmo=N |Number of lookups timed out and requeued | 263*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 264*4882a593Smuzhiyun|Updates |n=N |Number of update cookie requests seen | 265*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 266*4882a593Smuzhiyun| |nul=N |Number of upd reqs given a NULL parent | 267*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 268*4882a593Smuzhiyun| |run=N |Number of upd reqs granted CPU time | 269*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 270*4882a593Smuzhiyun|Relinqs |n=N |Number of relinquish cookie requests seen | 271*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 272*4882a593Smuzhiyun| |nul=N |Number of rlq reqs given a NULL parent | 273*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 274*4882a593Smuzhiyun| |wcr=N |Number of rlq reqs waited on completion of creation | 275*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 276*4882a593Smuzhiyun|AttrChg |n=N |Number of attribute changed requests seen | 277*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 278*4882a593Smuzhiyun| |ok=N |Number of attr changed requests queued | 279*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 280*4882a593Smuzhiyun| |nbf=N |Number of attr changed rejected -ENOBUFS | 281*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 282*4882a593Smuzhiyun| |oom=N |Number of attr changed failed -ENOMEM | 283*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 284*4882a593Smuzhiyun| |run=N |Number of attr changed ops given CPU time | 285*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 286*4882a593Smuzhiyun|Allocs |n=N |Number of allocation requests seen | 287*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 288*4882a593Smuzhiyun| |ok=N |Number of successful alloc reqs | 289*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 290*4882a593Smuzhiyun| |wt=N |Number of alloc reqs that waited on lookup completion | 291*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 292*4882a593Smuzhiyun| |nbf=N |Number of alloc reqs rejected -ENOBUFS | 293*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 294*4882a593Smuzhiyun| |int=N |Number of alloc reqs aborted -ERESTARTSYS | 295*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 296*4882a593Smuzhiyun| |ops=N |Number of alloc reqs submitted | 297*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 298*4882a593Smuzhiyun| |owt=N |Number of alloc reqs waited for CPU time | 299*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 300*4882a593Smuzhiyun| |abt=N |Number of alloc reqs aborted due to object death | 301*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 302*4882a593Smuzhiyun|Retrvls |n=N |Number of retrieval (read) requests seen | 303*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 304*4882a593Smuzhiyun| |ok=N |Number of successful retr reqs | 305*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 306*4882a593Smuzhiyun| |wt=N |Number of retr reqs that waited on lookup completion | 307*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 308*4882a593Smuzhiyun| |nod=N |Number of retr reqs returned -ENODATA | 309*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 310*4882a593Smuzhiyun| |nbf=N |Number of retr reqs rejected -ENOBUFS | 311*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 312*4882a593Smuzhiyun| |int=N |Number of retr reqs aborted -ERESTARTSYS | 313*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 314*4882a593Smuzhiyun| |oom=N |Number of retr reqs failed -ENOMEM | 315*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 316*4882a593Smuzhiyun| |ops=N |Number of retr reqs submitted | 317*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 318*4882a593Smuzhiyun| |owt=N |Number of retr reqs waited for CPU time | 319*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 320*4882a593Smuzhiyun| |abt=N |Number of retr reqs aborted due to object death | 321*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 322*4882a593Smuzhiyun|Stores |n=N |Number of storage (write) requests seen | 323*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 324*4882a593Smuzhiyun| |ok=N |Number of successful store reqs | 325*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 326*4882a593Smuzhiyun| |agn=N |Number of store reqs on a page already pending storage | 327*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 328*4882a593Smuzhiyun| |nbf=N |Number of store reqs rejected -ENOBUFS | 329*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 330*4882a593Smuzhiyun| |oom=N |Number of store reqs failed -ENOMEM | 331*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 332*4882a593Smuzhiyun| |ops=N |Number of store reqs submitted | 333*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 334*4882a593Smuzhiyun| |run=N |Number of store reqs granted CPU time | 335*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 336*4882a593Smuzhiyun| |pgs=N |Number of pages given store req processing time | 337*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 338*4882a593Smuzhiyun| |rxd=N |Number of store reqs deleted from tracking tree | 339*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 340*4882a593Smuzhiyun| |olm=N |Number of store reqs over store limit | 341*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 342*4882a593Smuzhiyun|VmScan |nos=N |Number of release reqs against pages with no | 343*4882a593Smuzhiyun| | |pending store | 344*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 345*4882a593Smuzhiyun| |gon=N |Number of release reqs against pages stored by | 346*4882a593Smuzhiyun| | |time lock granted | 347*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 348*4882a593Smuzhiyun| |bsy=N |Number of release reqs ignored due to in-progress store| 349*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 350*4882a593Smuzhiyun| |can=N |Number of page stores cancelled due to release req | 351*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 352*4882a593Smuzhiyun|Ops |pend=N |Number of times async ops added to pending queues | 353*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 354*4882a593Smuzhiyun| |run=N |Number of times async ops given CPU time | 355*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 356*4882a593Smuzhiyun| |enq=N |Number of times async ops queued for processing | 357*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 358*4882a593Smuzhiyun| |can=N |Number of async ops cancelled | 359*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 360*4882a593Smuzhiyun| |rej=N |Number of async ops rejected due to object | 361*4882a593Smuzhiyun| | |lookup/create failure | 362*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 363*4882a593Smuzhiyun| |ini=N |Number of async ops initialised | 364*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 365*4882a593Smuzhiyun| |dfr=N |Number of async ops queued for deferred release | 366*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 367*4882a593Smuzhiyun| |rel=N |Number of async ops released | 368*4882a593Smuzhiyun| | |(should equal ini=N when idle) | 369*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 370*4882a593Smuzhiyun| |gc=N |Number of deferred-release async ops garbage collected | 371*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 372*4882a593Smuzhiyun|CacheOp |alo=N |Number of in-progress alloc_object() cache ops | 373*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 374*4882a593Smuzhiyun| |luo=N |Number of in-progress lookup_object() cache ops | 375*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 376*4882a593Smuzhiyun| |luc=N |Number of in-progress lookup_complete() cache ops | 377*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 378*4882a593Smuzhiyun| |gro=N |Number of in-progress grab_object() cache ops | 379*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 380*4882a593Smuzhiyun| |upo=N |Number of in-progress update_object() cache ops | 381*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 382*4882a593Smuzhiyun| |dro=N |Number of in-progress drop_object() cache ops | 383*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 384*4882a593Smuzhiyun| |pto=N |Number of in-progress put_object() cache ops | 385*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 386*4882a593Smuzhiyun| |syn=N |Number of in-progress sync_cache() cache ops | 387*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 388*4882a593Smuzhiyun| |atc=N |Number of in-progress attr_changed() cache ops | 389*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 390*4882a593Smuzhiyun| |rap=N |Number of in-progress read_or_alloc_page() cache ops | 391*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 392*4882a593Smuzhiyun| |ras=N |Number of in-progress read_or_alloc_pages() cache ops | 393*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 394*4882a593Smuzhiyun| |alp=N |Number of in-progress allocate_page() cache ops | 395*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 396*4882a593Smuzhiyun| |als=N |Number of in-progress allocate_pages() cache ops | 397*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 398*4882a593Smuzhiyun| |wrp=N |Number of in-progress write_page() cache ops | 399*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 400*4882a593Smuzhiyun| |ucp=N |Number of in-progress uncache_page() cache ops | 401*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 402*4882a593Smuzhiyun| |dsp=N |Number of in-progress dissociate_pages() cache ops | 403*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 404*4882a593Smuzhiyun|CacheEv |nsp=N |Number of object lookups/creations rejected due to | 405*4882a593Smuzhiyun| | |lack of space | 406*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 407*4882a593Smuzhiyun| |stl=N |Number of stale objects deleted | 408*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 409*4882a593Smuzhiyun| |rtr=N |Number of objects retired when relinquished | 410*4882a593Smuzhiyun+ +-------+-------------------------------------------------------+ 411*4882a593Smuzhiyun| |cul=N |Number of objects culled | 412*4882a593Smuzhiyun+--------------+-------+-------------------------------------------------------+ 413*4882a593Smuzhiyun 414*4882a593Smuzhiyun 415*4882a593Smuzhiyun 416*4882a593Smuzhiyun/proc/fs/fscache/histogram 417*4882a593Smuzhiyun-------------------------- 418*4882a593Smuzhiyun 419*4882a593Smuzhiyun :: 420*4882a593Smuzhiyun 421*4882a593Smuzhiyun cat /proc/fs/fscache/histogram 422*4882a593Smuzhiyun JIFS SECS OBJ INST OP RUNS OBJ RUNS RETRV DLY RETRIEVLS 423*4882a593Smuzhiyun ===== ===== ========= ========= ========= ========= ========= 424*4882a593Smuzhiyun 425*4882a593Smuzhiyun This shows the breakdown of the number of times each amount of time 426*4882a593Smuzhiyun between 0 jiffies and HZ-1 jiffies a variety of tasks took to run. The 427*4882a593Smuzhiyun columns are as follows: 428*4882a593Smuzhiyun 429*4882a593Smuzhiyun ========= ======================================================= 430*4882a593Smuzhiyun COLUMN TIME MEASUREMENT 431*4882a593Smuzhiyun ========= ======================================================= 432*4882a593Smuzhiyun OBJ INST Length of time to instantiate an object 433*4882a593Smuzhiyun OP RUNS Length of time a call to process an operation took 434*4882a593Smuzhiyun OBJ RUNS Length of time a call to process an object event took 435*4882a593Smuzhiyun RETRV DLY Time between an requesting a read and lookup completing 436*4882a593Smuzhiyun RETRIEVLS Time between beginning and end of a retrieval 437*4882a593Smuzhiyun ========= ======================================================= 438*4882a593Smuzhiyun 439*4882a593Smuzhiyun Each row shows the number of events that took a particular range of times. 440*4882a593Smuzhiyun Each step is 1 jiffy in size. The JIFS column indicates the particular 441*4882a593Smuzhiyun jiffy range covered, and the SECS field the equivalent number of seconds. 442*4882a593Smuzhiyun 443*4882a593Smuzhiyun 444*4882a593Smuzhiyun 445*4882a593SmuzhiyunObject List 446*4882a593Smuzhiyun=========== 447*4882a593Smuzhiyun 448*4882a593SmuzhiyunIf CONFIG_FSCACHE_OBJECT_LIST is enabled, the FS-Cache facility will maintain a 449*4882a593Smuzhiyunlist of all the objects currently allocated and allow them to be viewed 450*4882a593Smuzhiyunthrough:: 451*4882a593Smuzhiyun 452*4882a593Smuzhiyun /proc/fs/fscache/objects 453*4882a593Smuzhiyun 454*4882a593SmuzhiyunThis will look something like:: 455*4882a593Smuzhiyun 456*4882a593Smuzhiyun [root@andromeda ~]# head /proc/fs/fscache/objects 457*4882a593Smuzhiyun OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS EM EV F S | NETFS_COOKIE_DEF TY FL NETFS_DATA OBJECT_KEY, AUX_DATA 458*4882a593Smuzhiyun ======== ======== ==== ===== === === === == ===== == == = = | ================ == == ================ ================ 459*4882a593Smuzhiyun 17e4b 2 ACTV 0 0 0 0 0 0 7b 4 0 0 | NFS.fh DT 0 ffff88001dd82820 010006017edcf8bbc93b43298fdfbe71e50b57b13a172c0117f38472, e567634700000000000000000000000063f2404a000000000000000000000000c9030000000000000000000063f2404a 460*4882a593Smuzhiyun 1693a 2 ACTV 0 0 0 0 0 0 7b 4 0 0 | NFS.fh DT 0 ffff88002db23380 010006017edcf8bbc93b43298fdfbe71e50b57b1e0162c01a2df0ea6, 420ebc4a000000000000000000000000420ebc4a0000000000000000000000000e1801000000000000000000420ebc4a 461*4882a593Smuzhiyun 462*4882a593Smuzhiyunwhere the first set of columns before the '|' describe the object: 463*4882a593Smuzhiyun 464*4882a593Smuzhiyun ======= =============================================================== 465*4882a593Smuzhiyun COLUMN DESCRIPTION 466*4882a593Smuzhiyun ======= =============================================================== 467*4882a593Smuzhiyun OBJECT Object debugging ID (appears as OBJ%x in some debug messages) 468*4882a593Smuzhiyun PARENT Debugging ID of parent object 469*4882a593Smuzhiyun STAT Object state 470*4882a593Smuzhiyun CHLDN Number of child objects of this object 471*4882a593Smuzhiyun OPS Number of outstanding operations on this object 472*4882a593Smuzhiyun OOP Number of outstanding child object management operations 473*4882a593Smuzhiyun IPR 474*4882a593Smuzhiyun EX Number of outstanding exclusive operations 475*4882a593Smuzhiyun READS Number of outstanding read operations 476*4882a593Smuzhiyun EM Object's event mask 477*4882a593Smuzhiyun EV Events raised on this object 478*4882a593Smuzhiyun F Object flags 479*4882a593Smuzhiyun S Object work item busy state mask (1:pending 2:running) 480*4882a593Smuzhiyun ======= =============================================================== 481*4882a593Smuzhiyun 482*4882a593Smuzhiyunand the second set of columns describe the object's cookie, if present: 483*4882a593Smuzhiyun 484*4882a593Smuzhiyun ================ ====================================================== 485*4882a593Smuzhiyun COLUMN DESCRIPTION 486*4882a593Smuzhiyun ================ ====================================================== 487*4882a593Smuzhiyun NETFS_COOKIE_DEF Name of netfs cookie definition 488*4882a593Smuzhiyun TY Cookie type (IX - index, DT - data, hex - special) 489*4882a593Smuzhiyun FL Cookie flags 490*4882a593Smuzhiyun NETFS_DATA Netfs private data stored in the cookie 491*4882a593Smuzhiyun OBJECT_KEY Object key } 1 column, with separating comma 492*4882a593Smuzhiyun AUX_DATA Object aux data } presence may be configured 493*4882a593Smuzhiyun ================ ====================================================== 494*4882a593Smuzhiyun 495*4882a593SmuzhiyunThe data shown may be filtered by attaching the a key to an appropriate keyring 496*4882a593Smuzhiyunbefore viewing the file. Something like:: 497*4882a593Smuzhiyun 498*4882a593Smuzhiyun keyctl add user fscache:objlist <restrictions> @s 499*4882a593Smuzhiyun 500*4882a593Smuzhiyunwhere <restrictions> are a selection of the following letters: 501*4882a593Smuzhiyun 502*4882a593Smuzhiyun == ========================================================= 503*4882a593Smuzhiyun K Show hexdump of object key (don't show if not given) 504*4882a593Smuzhiyun A Show hexdump of object aux data (don't show if not given) 505*4882a593Smuzhiyun == ========================================================= 506*4882a593Smuzhiyun 507*4882a593Smuzhiyunand the following paired letters: 508*4882a593Smuzhiyun 509*4882a593Smuzhiyun == ========================================================= 510*4882a593Smuzhiyun C Show objects that have a cookie 511*4882a593Smuzhiyun c Show objects that don't have a cookie 512*4882a593Smuzhiyun B Show objects that are busy 513*4882a593Smuzhiyun b Show objects that aren't busy 514*4882a593Smuzhiyun W Show objects that have pending writes 515*4882a593Smuzhiyun w Show objects that don't have pending writes 516*4882a593Smuzhiyun R Show objects that have outstanding reads 517*4882a593Smuzhiyun r Show objects that don't have outstanding reads 518*4882a593Smuzhiyun S Show objects that have work queued 519*4882a593Smuzhiyun s Show objects that don't have work queued 520*4882a593Smuzhiyun == ========================================================= 521*4882a593Smuzhiyun 522*4882a593SmuzhiyunIf neither side of a letter pair is given, then both are implied. For example: 523*4882a593Smuzhiyun 524*4882a593Smuzhiyun keyctl add user fscache:objlist KB @s 525*4882a593Smuzhiyun 526*4882a593Smuzhiyunshows objects that are busy, and lists their object keys, but does not dump 527*4882a593Smuzhiyuntheir auxiliary data. It also implies "CcWwRrSs", but as 'B' is given, 'b' is 528*4882a593Smuzhiyunnot implied. 529*4882a593Smuzhiyun 530*4882a593SmuzhiyunBy default all objects and all fields will be shown. 531*4882a593Smuzhiyun 532*4882a593Smuzhiyun 533*4882a593SmuzhiyunDebugging 534*4882a593Smuzhiyun========= 535*4882a593Smuzhiyun 536*4882a593SmuzhiyunIf CONFIG_FSCACHE_DEBUG is enabled, the FS-Cache facility can have runtime 537*4882a593Smuzhiyundebugging enabled by adjusting the value in:: 538*4882a593Smuzhiyun 539*4882a593Smuzhiyun /sys/module/fscache/parameters/debug 540*4882a593Smuzhiyun 541*4882a593SmuzhiyunThis is a bitmask of debugging streams to enable: 542*4882a593Smuzhiyun 543*4882a593Smuzhiyun ======= ======= =============================== ======================= 544*4882a593Smuzhiyun BIT VALUE STREAM POINT 545*4882a593Smuzhiyun ======= ======= =============================== ======================= 546*4882a593Smuzhiyun 0 1 Cache management Function entry trace 547*4882a593Smuzhiyun 1 2 Function exit trace 548*4882a593Smuzhiyun 2 4 General 549*4882a593Smuzhiyun 3 8 Cookie management Function entry trace 550*4882a593Smuzhiyun 4 16 Function exit trace 551*4882a593Smuzhiyun 5 32 General 552*4882a593Smuzhiyun 6 64 Page handling Function entry trace 553*4882a593Smuzhiyun 7 128 Function exit trace 554*4882a593Smuzhiyun 8 256 General 555*4882a593Smuzhiyun 9 512 Operation management Function entry trace 556*4882a593Smuzhiyun 10 1024 Function exit trace 557*4882a593Smuzhiyun 11 2048 General 558*4882a593Smuzhiyun ======= ======= =============================== ======================= 559*4882a593Smuzhiyun 560*4882a593SmuzhiyunThe appropriate set of values should be OR'd together and the result written to 561*4882a593Smuzhiyunthe control file. For example:: 562*4882a593Smuzhiyun 563*4882a593Smuzhiyun echo $((1|8|64)) >/sys/module/fscache/parameters/debug 564*4882a593Smuzhiyun 565*4882a593Smuzhiyunwill turn on all function entry debugging. 566