<p>目标:</p><p>9点,有材料可用。</p><p><br/></p><p>bucuo dfadfadfd f</p><h2 style="outline: 0px; margin: 1.3em 0px 1em; font-size: 1.4em; line-height: 28px; padding: 0px; color: rgb(51, 51, 51); font-family: arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); border-bottom: 1px solid rgb(238, 238, 238);">dokuwiki</h2><p class="intro" style="margin-top: 1.5em; margin-bottom: 3em; padding: 0px; font-size: 1.5em; color: rgb(51, 51, 51); font-family: Arial, sans-serif; white-space: normal;">Your Download should begin shortly, if not: <a href="https://download.dokuwiki.org/out/dokuwiki-a6b3119b5d16cfdee29a855275c5759f.tgz" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">download via this link</a>.</p><h2 style="padding: 0px; line-height: 1.2; clear: left; margin: 0px 0px 0.666em;">Learn More</h2><ul style="list-style-type: square;" class=" list-paddingleft-2"><li><p>Learn how to <a href="https://www.dokuwiki.org/install" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">install</a> or <a href="https://www.dokuwiki.org/install:upgrade" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">upgrade</a> DokuWiki</p></li><li><p>Read the <a href="https://www.dokuwiki.org/manual" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">DokuWiki manual</a></p></li></ul><h2 style="padding: 0px; line-height: 1.2; clear: left; margin: 0px 0px 0.666em;">Donate ❤️</h2><p style="margin-top: 0px; margin-bottom: 1.4em; padding: 0px;">Say thanks by <a href="https://www.dokuwiki.org/donate" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">donating</a> via</p><ul style="list-style-type: square;" class=" list-paddingleft-2"><li><p><a href="http://donate.dokuwiki.org/" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">Paypal</a>,</p></li><li><p class="intro" style="margin-top: 1.5em; margin-bottom: 3em; padding: 0px; font-size: 1.5em; color: rgb(51, 51, 51); font-family: Arial, sans-serif; white-space: normal;">Your Download should begin shortly, if not: <a href="https://download.dokuwiki.org/out/dokuwiki-a6b3119b5d16cfdee29a855275c5759f.tgz" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">download via this link</a>.</p></li><li><h2 style="padding: 0px; line-height: 1.2; clear: left; margin: 0px 0px 0.666em;">Learn More</h2></li><li><p>Learn how to <a href="https://www.dokuwiki.org/install" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">install</a> or <a href="https://www.dokuwiki.org/install:upgrade" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">upgrade</a> DokuWiki</p></li><li><p>Read the <a href="https://www.dokuwiki.org/manual" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">DokuWiki manual</a></p></li><li><h2 style="padding: 0px; line-height: 1.2; clear: left; margin: 0px 0px 0.666em;">Donate ❤️</h2></li><li><p style="margin-top: 0px; margin-bottom: 1.4em; padding: 0px;">Say thanks by <a href="https://www.dokuwiki.org/donate" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">donating</a> via</p></li><li><p><a href="http://donate.dokuwiki.org/" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">Paypal</a>,</p></li><li><p><a href="https://www.patreon.com/dokuwiki" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">Patreon</a>,</p></li><li><p><a href="https://github.com/sponsors/splitbrain/" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">Github Sponsors</a> or</p></li><li><p><a href="bitcoin:1Dokuw1Ki8dGk4p2hAWZv4TwGj8Ax1Vcqz" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">Bitcoin</a>.</p></li><li><p style="margin-top: 0px; margin-bottom: 1.4em; padding: 0px;">You may also want to check out the shop</p></li><li><p><a href="https://www.patreon.com/dokuwiki" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">Patreon</a>,</p></li><li><p><a href="https://github.com/sponsors/splitbrain/" target="blank" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">Github Sponsors</a> or</p></li><li><p><a href="bitcoin:1Dokuw1Ki8dGk4p2hAWZv4TwGj8Ax1Vcqz" style="outline: none; text-decoration-line: none; color: rgb(43, 115, 183);">Bitcoin</a>.</p></li></ul><p style="margin-top: 0px; margin-bottom: 1.4em; padding: 0px;">You may also want to check out the shop</p><h3 class="c-title t t tts-title" style="margin: 0px 0px 4px; padding: 0px; list-style: none; font-variant-numeric: normal; font-variant-east-asian: normal; font-weight: 400; font-stretch: normal; font-size: 18px; line-height: 22px;"><a class="" href="https://www.baidu.com/link?url=6BF-7AwZEmGty564XxDUWx1Jf9nPOiMTA3geU-2TYrZC3aZC2n6Vh7cLSOWaULpL&wd=&eqid=9b267788004cca930000000263d3b18e" target="blank" style="color: rgb(36, 64, 179); display: inline-block;"><span style="color: rgb(247, 49, 49);">Dokuwiki</span>中文网 | 知识库、开源知识库、免费知识库、wiki…</a></h3><p><span class="content-right8Zs40" style="word-break: break-all;"><span style="color: rgb(247, 49, 49);">DokuWiki</span>可以与多种CMS程序进行整合,例如WordPress、XOOPS、PostNuke等。 ★★★查看<span style="color: rgb(247, 49, 49);">Dokuwiki</span>知识库视频教程★★★ 运行环境 Apache+PHP 应用场景 企业知识库、私人笔记本、…</span></p><p><a href="http://www.baidu.com/link?url=6BF-7AwZEmGty564XxDUWx1Jf9nPOiMTA3geU-2TYrZC3aZC2n6Vh7cLSOWaULpL" target="blank" class="siteLink9TPP3" style="color: rgb(36, 64, 179); text-decoration-line: none;"><span class="c-color-gray" style="color: rgb(98, 102, 117);"><strong>dokuwiki</strong>.com.cn/</span></a></p><p><span class="c-icon iconX09BS" style="background: url("https://pss.bdstatic.com/r/www/cache/static/protocol/https/global/img/icons_441e82f.png") 0px 0px no-repeat; display: inline-block; width: 13px; height: 17px; vertical-align: text-bottom; overflow: visible; -webkit-font-smoothing: antialiased; color: rgba(0, 0, 0, 0.1); font-family: cIconfont !important;"></span></p><p><span class="c-icon recommend-icon-bear-circle-new c-font-normal new-url-right-icon c-gap-right-xsmall" style="background: url("https://pss.bdstatic.com/r/www/cache/static/protocol/https/global/img/icons_441e82f.png") 0px 0px no-repeat rgb(145, 185, 247); display: inline-block; width: 14px; height: 15px; vertical-align: text-bottom; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 16px; line-height: 16px; overflow: visible; margin-bottom: -6px; margin-right: 4px; -webkit-font-smoothing: antialiased; position: relative; top: -3px; text-align: center; color: rgb(255, 255, 255); border-radius: 4px; padding-left: 2px; padding-top: 1px;"></span><span class="c-font-normal" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 13px; line-height: 21px;">为您推荐:</span><a class="recommend-item-a " href="https://www.baidu.com/s?tn=baiduhome_pg&rsv_idx=2&wd=%E7%9F%A5%E8%AF%86%E5%BA%93%E7%BD%91%E7%AB%99%E5%85%8D%E8%B4%B9&rsv_crq=6&bs=dokuwiki" title="知识库网站免费" target="blank" style="color: rgb(36, 64, 179); text-decoration-line: none; font-size: 13px; display: inline-block; height: 24px; line-height: 24px; padding: 0px 6px; background: rgb(245, 245, 246); border-radius: 6px;">知识库网站免费</a><a class="recommend-item-a c-gap-left-middle" href="https://www.baidu.com/s?tn=baiduhome_pg&rsv_idx=2&wd=doukuwiki%E6%BC%8F%E6%B4%9E&rsv_crq=6&bs=dokuwiki" title="doukuwiki漏洞" target="blank" style="color: rgb(36, 64, 179); text-decoration-line: none; font-size: 13px; margin-left: 10px; display: inline-block; height: 24px; line-height: 24px; padding: 0px 6px; background: rgb(245, 245, 246); border-radius: 6px;">doukuwiki漏洞</a><a class="recommend-item-a c-gap-left-middle" href="https://www.baidu.com/s?tn=baiduhome_pg&rsv_idx=2&wd=%E4%B8%AD%E5%8D%8E%E7%9F%A5%E8%AF%86%E5%BA%93&rsv_crq=6&bs=dokuwiki" title="中华知识库" target="blank" style="color: rgb(36, 64, 179); text-decoration-line: none; font-size: 13px; margin-left: 10px; display: inline-block; height: 24px; line-height: 24px; padding: 0px 6px; background: rgb(245, 245, 246); border-radius: 6px;">中华知识库</a></p><p><a class="c-gap-left-middle recommend-item-a" href="https://www.baidu.com/s?tn=baiduhome_pg&rsv_idx=2&wd=wiki%E5%B9%B3%E5%8F%B0&rsv_crq=6&bs=dokuwiki" title="wiki平台" target="blank" style="color: rgb(36, 64, 179); text-decoration-line: none; font-size: 13px; margin-left: 85px; display: inline-block; height: 24px; line-height: 24px; padding: 0px 6px; background: rgb(245, 245, 246); border-radius: 6px;">wiki平台</a><a class="c-gap-left-middle recommend-item-a" href="https://www.baidu.com/s?tn=baiduhome_pg&rsv_idx=2&wd=%E7%9F%A5%E8%AF%86%E5%BA%93%E7%BD%91%E7%AB%99&rsv_crq=6&bs=dokuwiki" title="知识库网站" target="blank" style="color: rgb(36, 64, 179); text-decoration-line: none; font-size: 13px; margin-left: 10px; display: inline-block; height: 24px; line-height: 24px; padding: 0px 6px; background: rgb(245, 245, 246); border-radius: 6px;">知识库网站</a></p><h3 class="t c-line-clamp1" style="margin: 0px 0px 4px; padding: 0px; list-style: none; font-weight: 400; font-size: 18px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"><a href="http://www.baidu.com/link?url=6BF-7AwZEmGty564XxDUWrI7wZFTmVeN2WWKeLLONBUrS5QA1cb4JPWg8BpKty249Nw3CycB5TslPi4IcFA7iI_KYKaDjikw_Xfdzr5lTvbt_wlZZwPVQh9GePb74Rll" target="blank" class="title1KPOI" style="color: rgb(36, 64, 179); display: inline-block;"><span style="color: rgb(247, 49, 49);">dokuwiki</span>使用教程 - 相关博客 - 开发者搜索</a></h3><p><span class="c-color-gray item-viewsOE-5-" style="float: right; color: rgb(98, 102, 117);">2030次阅读</span><a href="http://www.baidu.com/link?url=zJmqKpf6xqLh9e8EEgF1sc0uHrTOCEBcie-8mOsxWq1SPTM3rjZuiAEb_ufbQjlSh32assdmhDZjRmYj2Doq8q" target="blank" class="c-font-medium item-title16G8Y" style="color: rgb(36, 64, 179); text-decoration-line: none; float: left; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: 22px;">信步漫谈之<span style="color: rgb(247, 49, 49);">Wiki</span>知识库——搭建<span style="color: rgb(247, 49, 49);">dokuwiki</span></a></p><p><span class="c-color-gray c-gap-left-small item-site-name3aKAy" style="margin-left: 8px; vertical-align: middle; display: inline-block !important; color: rgb(98, 102, 117);">博客园</span></p><p><span class="c-line-clamp2" style="display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical;">参考资料(感谢). <span style="color: rgb(247, 49, 49);">DokuWiki</span>安装+集成markdown编辑器editor.md · <span style="color: rgb(247, 49, 49);">dokuwiki</span>安装使用教程(支持中文、editor.md、粘贴上传 …</span></p><p><a href="http://www.baidu.com/link?url=H2XktyFfNQtu0on4GE4NG4vie-Vs6eHjAzuHC7rzuyLxTKH5Dul7BJxLrn0cJvs0kC3xtZAExhtdbQt092_1Xa" target="blank" class="c-font-medium item-title16G8Y" style="color: rgb(36, 64, 179); text-decoration-line: none; float: left; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: 22px;"><span style="color: rgb(247, 49, 49);">Dokuwiki</span> 使用技巧整理</a></p><p><span class="c-color-gray c-gap-left-small item-site-name3aKAy" style="margin-left: 8px; vertical-align: middle; display: inline-block !important; color: rgb(98, 102, 117);">Jonathan's Wiki …</span></p><p><span class="c-line-clamp2" style="display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical;">@ID@ , @PAGE@ , @DATE@ , @NAME@ , @NS@ 可參考https://www.<span style="color: rgb(247, 49, 49);">dokuwiki</span>.org/start?id=zh-tw:namespacetemplates - 特定 Name Space 採用自己…</span></p><h2 style="font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 1.2em; line-height: 1.5; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; margin: 0px 0px calc(1.16667em); clear: left; font-synthesis: style; color: rgb(18, 18, 18); white-space: normal; background-color: rgb(255, 255, 255);">前言</h2><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">本文接前两文,继续讲解目录的数据组织结构,我们现在已经知道:</p><ol style="margin-top: 1.4em; margin-bottom: 1.4em; padding: 0px; width: 690px; counter-reset: ol 0; display: table; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);" class=" list-paddingleft-2"><li><p>目录优先使用FMTLOCAL格式的datafork,将数据以short format的格式存储在datafork空间内部。</p></li><li><p>在datafork空间不足后,目录转而使用FMTEXTENTS格式的datafork。在EXTENTS格式下有三种格式的目录组织形式,第一种是Block directory,第二种是Leaf directory,第三种是Node directory。随着数据量的逐渐增加,一步步进阶使用。</p></li></ol><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">那么随着数据量的继续增加,extents越来越多,终于datafork空间不足以extent list的形式存储这些extent records,这时就要采用终极形式——B+tree。我们在前面已经讲了XFS使用过的多种B+tree格式的变种,而且也在前两篇关于目录的文章中介绍了关于目录的众多相关结构。下面我们就要用到这些预备知识来讲解目录的B+tree结构。</p><h2 style="font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 1.2em; line-height: 1.5; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; margin: calc(2.33333em) 0px calc(1.16667em); clear: left; font-synthesis: style; color: rgb(18, 18, 18); white-space: normal; background-color: rgb(255, 255, 255);">目录的B+tree</h2><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">其实我们在前文讲到Node directory的时候已经接触到一个简单的B+tree了,那就是Node block索引Leaf blocks的时候,其实就是一个简单的以hashval为关键字的B+tree了。如果进一步扩展,Node block后面可以再接多层Node blocks,直到Leaf blocks,形成一个B+tree结构,比如如下示意图:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;"> +———-+—————+——+——–+—–+——+——–+
| Node hdr | hash | before | hash | before | … | hash | before |
+———-+—————+——+——–+—–+——+——–+
| | |
+———————–+ +——-+ +——+
| | |
V | V
+———-+—————+—————+—–+ | +————+
Node hdr | hash | before | hash | before | … | | | Node block |
+———-+—————+—————+—–+ | +————+
| | | V |
| | | +————+ V
+—————–+ | | | Node block | …
| | | +————+
V | V |
+———-+————-+—–+ | +————+ +—> …
Leaf hdr | hash | addr | … | | | Leaf block |
+———-+————-+—–+ | +————+
V
+———-+————-+—–+
| Leaf hdr | hash | addr | … |
+———-+————-+—–+</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">所以这里有一个B+tree,用于组织leaf blocks。但是我们知道inode的数据终归是由extent管理,所以如何管理目录的extents是目录组织结构的首要事情。当extents list超过datafork的存储范围后就会变成B+tree结构,和之前讲过的普通文件的extents list变B+tree结构时一样(参考:<a href="https://zhuanlan.zhihu.com/p/357168333" class="internal" style="text-decoration-line: none; border-bottom: 1px solid rgb(128, 128, 128); cursor: pointer;">醉卧沙场:XFS的on-disk组织结构(7)——Inode Datafork of regular file</a>)。一个B+tree directory的数据组织形式大约如下:</p><p><img src="https://pic2.zhimg.com/80/v2-752e4ec555a963fa8c76b15abb27dc4d_720w.webp" class="originimage zh-lightbox-thumb lazy" width="1355" height="1630"/></p><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">首先是datafork变成BMapt BTree结构的头部(bmdr),通过它可以索引到很多bmbt block(上图仅画了1级bmbt)。BMap BTree结构的最终节点就是目录的data block, node block, leaf block以及freeindex block组成的extents。找到这些extents,就可以通过讲解Node directory时用到的方式,利用Node block索引Leaf Blocks,定位Data block的内容。上图画了一个2级的Node-Leaf B+tree。</p><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">也就是说B+Tree directory实际上由inode的BMap BTree以及目录特有的一个Node-leaf blocks B+tree组成。为了便于理解,我们还是举一个实例,下面我创建了一个包含20多万个文件的目录,现在我尝试定位里面一个叫"looooooooooooooooooooooooooooooooooooooooooooooooooooooooooongfile200000"的文件,比如这样:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;"># ls -l /mnt/test/dir0/looooooooooooooooooooooooooooooooooooooooooooooooooooooooooongfile200000
-rw-r–r–. 1 root root 0 Mar 26 15:22 /mnt/test/dir0/looooooooooooooooooooooooooooooooooooooooooooooooooooooooooongfile200000</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">那当我们只知道/mnt/test/dir0/下面有一个叫"looo….oongfile200000"的客体时,我怎么通过B+Tree结构的"dir0",找到其下"looo….oongfile200000"所对应的inode号(从而才能找到其inode块)呢?</p><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">首先我们看目录dir0的datafork的内容:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">xfsdb> inode 131
xfsdb> p
…
core.format = 3 (btree)
core.nblocks = 6130
core.extsize = 0
core.nextents = 2541
…
u3.bmbt.level = 1
u3.bmbt.numrecs = 11
u3.bmbt.keys[1-11] = [startoff]
1:[0]
2:[740]
3:[1498]
4:[2232]
5:[2990]
6:[3734]
7:[4455]
8:[4850]
9:[8388609]
10:[8388882]
11:[8389125]
u3.bmbt.ptrs[1-11] = 1:172 2:3713 3:10160 4:15124 5:20265 6:25313 7:30201 8:35261 9:7293 10:12884 11:24751
…</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">我们可以看到datafork中不是一个extents list了,而是一个level=1的BMap BTree的头部。我们首先要找的是"looo….oongfile200000"对应的Leaf block里的[hashval, address]对,前面我们知道Node/Leaf的偏移地址是32GB,我当前XFS的blocksize=4k,34359738368/4096 = 8388608,所以Node/Leaf区域的第一个block在8388608这个偏移地址处。根据bmbt.keys的内容,我们可以确定8388608在keys[8]~[9]之间,所以就在keys[8]所对应的范围里,那么我们通过bmbt.ptrs[8]来找到bmbt.keys[8]对应的block:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">xfsdb> addr u3.bmbt.ptrs[8]
xfsdb> p
…
173:[5328,36124,4,0]
174:[5332,36152,2,0]
175:[8388608,14,1,0]</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">我们看到这个block里的最后一个record就是8388608偏移地址所在的位置,其在物理地址的第14个block处,并占用1个block,我们下面就去这个位置看一看其内容:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">xfsdb> dblock 8388608
xfsdb> p
nhdr.info.hdr.forw = 0
nhdr.info.hdr.back = 0
nhdr.info.hdr.magic = 0x3ebe
nhdr.info.crc = 0x93bb2608 (correct)
nhdr.info.bno = 112
nhdr.info.lsn = 0x6000051ab
nhdr.info.uuid = ea53b14f-9edd-4cdd-8f37-4d825fd89590
nhdr.info.owner = 131
nhdr.count = 2
nhdr.level = 2
nbtree[0-1] = [hashval,before]
0:[0x795666e9,8389115]
1:[0xffe3e7df,8389114]</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">可以看到这是一个Node block,并且其肯定是root node,而且level=2。所以其下面还得有一级的Node blocks。到此B+Tree的关键字就变为hashval了,所以我们先计算"looo….oongfile200000"的hash值:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">xfsdb> hash looooooooooooooooooooooooooooooooooooooooooooooooooooooooooongfile200000
0x69d667e0</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">得到0x69d667e0这个hash值,我们就可以知道应该去 0:[0x795666e9,8389115] 这个地方去找下一个Node block:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">xfsdb> dblock 8389115
xfsdb> p
nhdr.info.hdr.forw = 8389114
nhdr.info.hdr.back = 0
nhdr.info.hdr.magic = 0x3ebe
nhdr.info.crc = 0x759db2e3 (correct)
nhdr.info.bno = 187104
nhdr.info.lsn = 0x800000b1a
nhdr.info.uuid = ea53b14f-9edd-4cdd-8f37-4d825fd89590
nhdr.info.owner = 131
nhdr.count = 410
nhdr.level = 1
nbtree[0-409] = [hashval,before]
…
367:[0x69b7e37f,8388875]
368:[0x69d424f1,8388890]
369:[0x69d46663,8388684]
370:[0x69d6277b,8388678]
371:[0x69d6a6fa,8388623]
372:[0x69d726e5,8388633]
…</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">我们看到这是一个level=1的Node block,0x69d667e0这个hash值就位于 371:[0x69d6a6fa,8388623]这个block里,因为这里已经是level=1的node了,所以下面就肯定是Leaf block了,我们去这个leaf block里继续找:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">xfsdb> dblock 8388623
xfsdb> p
lhdr.info.hdr.forw = 8388633
lhdr.info.hdr.back = 8388678
lhdr.info.hdr.magic = 0x3dff
lhdr.info.crc = 0xd1116e5b (correct)
lhdr.info.bno = 6256
lhdr.info.lsn = 0x1000044fe
lhdr.info.uuid = ea53b14f-9edd-4cdd-8f37-4d825fd89590
lhdr.info.owner = 131
lhdr.count = 379
lhdr.stale = 0
…
lents[203].hashval = 0x69d6677f
lents[203].address = 0x10fa
lents[204].hashval = 0x69d667e0
lents[204].address = 0x1c9
lents[205].hashval = 0x69d667e1
lents[205].address = 0x24a
…</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">果然,在这里我们找到了lents[204].hashval = 0x69d667e0,其正好和我们要找的文件名的hash值相等,所以我们取其address,得到lents[204].address = 0x1c9,前面我们已经知道这里地址需要乘以8,所以 0x1c9 * 8 = 0xe48 = 3656,比一个directory blocksize还小,说明这个地址就在第0个directory block里。现在我们回到目录的datafork,去找startoff=0的extent在哪:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">u3.bmbt.level = 1
u3.bmbt.numrecs = 11
u3.bmbt.keys[1-11] = [startoff]
1:[0]
2:[740]
3:[1498]
4:[2232]
5:[2990]
6:[3734]
7:[4455]
8:[4850]
9:[8388609]
10:[8388882]
11:[8389125]
u3.bmbt.ptrs[1-11] = 1:172 2:3713 3:10160 4:15124 5:20265 6:25313 7:30201 8:35261 9:7293 10:12884 11:24751</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">所以startoff=0的extent肯定在u3.bmbt.ptrs[1]对应的地址上,我们去这个地址看一下:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">xfsdb> addr u3.bmbt.ptrs[1]
xfsdb> p
magic = 0x424d4133
level = 0
numrecs = 251
leftsib = null
rightsib = 3713
bno = 1376
lsn = 0x200002ce7
uuid = ea53b14f-9edd-4cdd-8f37-4d825fd89590
owner = 131
crc = 0x4f9bc2e (correct)
recs[1-251] = [startoff,startblock,blockcount,extentflag]
1:[0,15,1,0]
2:[1,13,1,0]
3:[2,12,1,0]
…</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">可以看到startoff=0的extent就在1:[0,15,1,0]的位置,我们去这个位置看一下:</p><pre style="margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(246, 246, 246); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;">xfsdb> fsblock 15
xfsdb> type dir3
xfsdb> p
…
du[43].name = "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooongfile200000"
du[43].filetype = 1
du[43].tag = 0xe48
du[44].inumber = 174
du[44].namelen = 73
…</pre><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">果然在其内部找到了我们要找的文件,文件名完全一致,并且我们也找到了其inode号du[44].inumber = 174。根据这个inode号我们就能定位这个文件所对应的inode的位置了。</p><h2 style="font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 1.2em; line-height: 1.5; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; margin: calc(2.33333em) 0px calc(1.16667em); clear: left; font-synthesis: style; color: rgb(18, 18, 18); white-space: normal; background-color: rgb(255, 255, 255);">结语</h2><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">到此所有和XFS目录相关的数据组织结构都讲完了,篇幅较多,且较复杂。本篇是用到了前面四篇讲解inode结构的所有知识点,虽篇幅不长,但是如果没有前面的基础是看不懂的。但是反过来说,如果你能理解到这里,前面的知识你肯定也能很容易的理解了。</p><p style="margin-top: 1.4em; margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", sans-serif; font-size: medium; white-space: normal; background-color: rgb(255, 255, 255);">文件系统最主要的两种文件——普通文件和目录的数据组织方式已经讲完,我们一直在说datafork的部分,下面是时候说一下inode结构的最后一个重要部分,也就是用于存储扩展属性的attrfork相关的内容了。扩展属性的存储结构和目录有很多相似的地方,如果你理解了目录数据的组织方式,理解扩展属性并不难,下一篇文章见。</p><p><br/></p>