ubifs- Wandering Tree

原创译文:

JFFS2 和 UBIFS的最大区别在于UBIFS将索引节点(index)存储在flash上,而JFFS2只将index 存储在内存中,在文件系统mount 的时候重新构建(rebuilding)。JFFS2的这一特点无疑限制了JFFS2文件系统的大小,因为文件系统的挂载时间和内存使用量随着flash 的容量增大而剧增。


UBIFS 文件系统就是为了解决这一限制而设计的。不幸的是,将索引(index)存储在flash 上非常的复杂,因为索引本身也要out-of-place update。


当一部分索引被 out-of-place 更新了,其他索引了这些更新了的index的index 也要随着更新。 如此一来,索引了这些索引更新了的index的index的index 也要更新。这样,看起来就是一个无尽的层叠更新,解决方案是采用 魔幻树(Wandering Tree)。


UBIFS 采用的魔幻树(其实是B+ 树),只有树的叶子包含文件信息。这棵树中间的元素都是索引节点(index node),只包含对它们子节点的索引。
UBIFS 魔幻树分为两部分:
1). 上部分包含索引节点,这些索引节点构建了这棵树的结构;
2). 下部分包含真正含有文件数据的叶子节点。


上部分可以简单认为是索引。 更新文件系统包含创建一个叶子节点,将其添加或者替换到魔幻树中。
同时,父索引节点也必须被更新,之后父索引节点的父索引节点,直到这棵树的根节点。需要替换的索引节点数量等于这个树的高度。这样,唯一剩下的问题就是如何获取这棵树的根。在UBIFS中,根索引节点存储在主节点(Master Node)中。


The big difference between JFFS2 and UBIFS is that UBIFS stores the index on flash whereasJFFS2 stores the index only in main memory, rebuilding it when the file system is mounted.

Potentially that places a limit on the maximum size of a JFFS2 file system, because the mount time and memory usage grow linearly with the size of the flash.

UBIFS was designed specifically to overcome that limitation.Unfortunately, storing the index on flash is very complex because the index itself must be updated out-of-place.

When one part of the index is updated out-of-place, then any other parts of the index that reference the updated part, must also be updated. And then, in turn, the parts that reference those parts must be updated.

The solution to this seemingly never-ending cascade of updates is to use awandering tree.


In the case of the UBIFS wandering tree (which is technically aB+tree), only the leaves of the tree contain file information. They are valid nodes of the file system.

The internal elements of the tree are index nodes and contain only references to their children. That is, an index node records the on- flash position of its child nodes.

So the UBIFS wandering tree can be viewed as having two parts:

A top part consisting of index nodes that create the structure of the tree

A bottom part  consisting of leaf nodes that hold the actual file data

The top part is referred to simply as the index. An update to the file system  consists of creating a new leaf node and adding it, or replacing it into the wandering tree.

In order to do that, the parent index node must also be replaced, and its parent, and so on up to the root of the tree. The number of index nodes that have to be replaced is equal to the height of the tree.

There just remains the question of how to know where the root of the tree is. In UBIFS, the position of the root index node is stored in the master node.


由于flash memory 文件系统使用的out-of-place update 机制,UBIFS 又把index 存储在 flash 中,从而导致了index 也是要out-of-place update. 这样更新一个文件的node 就会很繁琐,不像将index 存储在RAM 中的文件系统,RAM 是可以直接写入操作的,更新一个node 只需要找到原先的那个node in-place update就行了。index 根本都不需要变化,更新。

既然 UBIFS 决定使用 on-flash index 解决 flash 容量剧增的问题,就必须解决掉 out-of-place update 带来的这种层叠的更新问题,无非就是找到一种算法可以实现管理这种层叠更新的机制,需要能实现,并且高效, Wandering Tree (B+ Tree) 被选做了UBIFS 针对这一问题的方案,算法。

在这棵Wandering Tree 中,只有最顶层的叶子节点是文件系统的有效数据,也就是用户真正存储的数据,其它上层的节点都是index 索引。(文件系统真不是吹的,算法开始出来了,不像驱动啊。。。)



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值