{"id":433,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:39","modified_gmt":"2020-08-22T20:26:39","slug":"this-is-the-page-title-toplevel-266","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=433","title":{"rendered":"The Directory Cache"},"content":{"rendered":"\n<title>The Directory Cache<\/title>\n<p>\nTo speed up accesses to commonly used directories, the VFS maintains a cache of\ndirectory entries.\n<p>\nAs directories are looked up by the real file systems their details are added into\nthe directory <glossary>cache<\/glossary>.\nThe next time the same directory is looked up, for example to list it or open a\nfile within it, then it will be found in the directory cache.\nOnly short directory entries (up to 15 characters long)  are cached but this is\nreasonable as the shorter directory names are the most commonly used ones.\nFor example, <directory>\/usr\/X11R6\/bin<\/directory> is very commonly accessed when the X server is\nrunning.\n<p>\nThe directory cache consists of a hash table, each entry of which points at\na list of directory cache entries that have the same hash value.\nThe hash function uses the device number of the device holding the file system and\nthe directory&#8217;s name to calculate the offset, or index, into the hash table.\nIt allows cached directory entries to be quickly found.\nIt is no use having a cache when lookups within the cache take too long to find entries,\nor even not to find them.\n<p>\nIn an effort to keep the caches valid and up to date the VFS keeps lists of\nLeast Recently Used (LRU) directory cache entries.\nWhen a directory entry is first put into the cache, which is when it is first\nlooked up, it is added onto the end of the first level LRU list.\nIn a full cache this will displace an existing entry from the front of the\nLRU list.\nAs the directory entry is accessed again it is promoted to the back of the\nsecond LRU cache list.\nAgain, this may displace a cached level two directory entry at the front of\nthe level two LRU cache list.\nThis displacing of entries at the front of the level one and level two LRU lists\nis fine.\nThe only reason that entries are at the front of the lists is that they have not\nbeen recently accessed.\nIf they had, they would be nearer the back of the lists.\nThe entries in the second level LRU cache list are safer than entries in the level one\nLRU cache list.\nThis is the intention as these entries have not only been looked up but also\nthey have been repeatedly referenced.\n<p>\n<!-- REVIEW NOTE: Do we need a diagram for this? -->\n","protected":false},"excerpt":{"rendered":"<p>The Directory Cache To speed up accesses to commonly used directories, the VFS maintains a cache of directory entries. As directories are looked up by the real file systems their details are added into the directory cache. The next time &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=433\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-433","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=433"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/433\/revisions"}],"predecessor-version":[{"id":739,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/433\/revisions\/739"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}