简体   繁体   English

了解影子分页以及它与日志文件系统的区别

[英]Understanding shadow paging and how it differs from journaling file systems

I am trying get a good grasp of shadow paging in unix-like file systems;我正在尝试在类 Unix 文件系统中很好地掌握影子分页; something that you might see in ZFS or WAFL .您可能会在ZFSWAFL 中看到的东西。 It seems that in shadow paging, when one wants to make changes to a page, a different page or "shadow page" is written to.似乎在影子分页中,当想要对页面进行更改时,会写入不同的页面或“影子页面”。 Upon completion of the operation(s), ie when everything has been committed, the shadow page is written out, replacing the old page.操作完成后,即当所有内容都已提交时,将写出影子页面,替换旧页面。 Is this a correct (albeit high level) understanding of shadow paging?这是对影子分页的正确(尽管是高级别的)理解吗?

How does shadow paging then differ from journaling file systems?影子分页与日志文件系统有何不同? They seem pretty similar.他们看起来非常相似。

Thank you for your time!感谢您的时间!

Both systems allow you to provide atomicity / consistency via different mechanisms:这两个系统都允许您通过不同的机制提供原子性/一致性:

  • Shadow paging always allocates a new block when you modify something, and when a block is overwritten its old copy becomes free since there will be no references to it from any other live filesystem blocks.当你修改某些东西时,影子分页总是分配一个新块,当一个块被覆盖时,它的旧副本变得空闲,因为任何其他活动文件系统块都不会引用它。 Crash consistency comes through a recursive metadata update up the tree -- you update where the leaf block lives (copied somewhere else during modification), and its parent must be updated (copied somewhere else during modification), etc. The new version of the filesystem with all modifications becomes visible when the entire chain up to the root of the tree has been updated.崩溃一致性通过树上的递归元数据更新来实现——您更新叶块所在的位置(在修改期间复制到其他地方),并且必须更新其父块(在修改期间复制到其他地方)等。 文件系统的新版本当更新到树根的整个链时,所有修改都变得可见。

  • Journaling allows you to modify blocks in place, but you still have to write them twice: once to the journal marking your intent (and providing multi-update atomicity if needed, such as for implementing moving a file from one directory to another), and then once in the log itself.日志允许您就地修改块,但您仍然必须将它们写入两次:一次写入日志以标记您的意图(并在需要时提供多次更新原子性,例如实现将文件从一个目录移动到另一个目录),以及然后一次在日志本身。 Since you're modifying in place, for overwrites of the same block you usually don't have to update many other filesystem tree blocks besides the specific ones you overwrote, because the blocks did not change position when you wrote the new version of them.由于您正在就地修改,对于同一块的覆盖,除了您覆盖的特定块之外,您通常不必更新许多其他文件系统树块,因为在您编写它们的新版本时这些块并没有改变位置。

The biggest difference is that shadow paging / copy on write makes it super easy to implement snapshots in the filesystem -- all you need to do is keep track of an old version of the root of the filesystem tree, and anything it referenced at the time.最大的区别是影子分页/写时复制使得在文件系统中实现快照变得非常容易——你需要做的就是跟踪文件系统树根的旧版本,以及它当时引用的任何东西. In journaling this is much harder because any block can be overwritten at any time, and the journal is not infinite -- usually it's overwritten quite quickly because otherwise it would take up a bunch of space on disk.在日记中,这要困难得多,因为任何块都可以随时被覆盖,而且日记不是无限的——通常它会很快被覆盖,否则它会占用大量磁盘空间。

Probably the biggest downside of copy-on-write, especially for spinning disks, is that it tends to swiss-cheese your data, causing it to become quite fragmented and therefore require more disk seeks during large sequential reads of files that are updated frequently.写时复制的最大缺点,特别是对于旋转磁盘,可能是它倾向于瑞士奶酪你的数据,导致它变得非常碎片化,因此在频繁更新的文件的大量顺序读取期间需要更多的磁盘搜索。 ZFS has this problem, and I think some later copy-on-write systems worked around this by having some intermediate layer mapping logical block addresses to physical addresses to allow the data to be defragmented. ZFS 有这个问题,我认为后来的一些写时复制系统通过一些中间层将逻辑块地址映射到物理地址来解决这个问题,以允许对数据进行碎片整理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM