f2fs的checkpoint

    checkpoint是为了提供一个一致的还原点,所以要记录某个一致的时刻(快照,数据和元数据一致),写到专有的CheckPoint area,持久化。

    进行cp的时机:sync    umount     foreground cleaning

    cp的过程:           1、把pagecache中的脏node和脏dentry block,flush到设备上

                                2、暂停写操作(包括create和mkdir)

                                3、元数据(NAT、SSA、SIT)写回到设备

                  4、把checkpoint pack(包含<1>Header and footer<2>NAT和SIT的bitmaps<3>NAT和SIT的jounal<4>Summary block of active segments<5>orphan blocks)

                                       <1>包含pack的版本号信息<2>pack中包含的块的位图(node块和data块)<3>记录最近更新的                                           NAT和SIT<4>即将写入SSA area的SSA blocks<5>孤儿block信息



Roll-Back Recovery

    突然关机后,F2FS回滚到最新的一致检查点。为了在创建新包时保持至少一个稳定的检查点包,F2FS维护两个检查点包。如果检查点数据包在页眉和页脚中具有相同的内容,则F2FS认为它有效。否则,它被丢弃。同样,F2FS也管理两套NAT和SIT块,由每个检查点包中的NAT和SIT位图区分。当在检查点中写入更新的NAT或SIT块时,F2FS将它们写入两个集合中的一个集合,然后将该位图标记为指向它的新集合。如果少量NAT或SIT条目频繁更新,F2FS将编写多个4KB大小的NAT或SIT块。为了减轻这种开销,F2FS实现了检查点包内的NAT和SIT日志。该技术减少了I / O数量,并相应地减少了检查点延迟。在安装时的恢复过程中,F2FS通过检查页眉和页脚来搜索有效的检查点包。如果两个检查点包都有效,则F2FS通过比较其版本号来选择最新的检查点包。一旦选择了最新的有效检查点包,它将检查是否存在孤立inode块。如果是这样,它将截断它们引用的所有数据块,并最终释放孤立inode。然后,在前滚恢复过程成功完成后,F2FS将使用其位图所引用的一组一致的NAT和SIT块启动文件系统服务,如下所述。


前滚回复

    F2FS implements an efficient roll-forward recovery mechanism to enhance fsync performance. The key idea is to write data blocks and their direct node blocks only, excluding other node or F2FS metadata blocks. In order to find the data blocks selectively after rolling back to the stable checkpoint, F2FS remains a special flag inside direct node blocks.


F2FS performs roll-forward recovery as follows. If we denote the log position of the last stable checkpoint as N, (1) F2FS collects the direct node blocks having the special flag located in N+n, while constructing a list of their node information. n refers to the number of blocks updated since the last checkpoint. (2) By using the node information in the list, it loads the most recently written node blocks, named N-n, into the page cache. (3) Then,

it compares the data indices in between N-n and N+n. (4) If it detects different data indices, then it refreshes the cached node blocks with the new indices stored in N+n, and finally marks them as dirty. Once completing the roll-forward recovery, F2FS performs checkpointing to store the whole in-memory changes to the disk.

    F2FS实现了一个高效的前滚恢复机制来增强fsync的性能。关键的想法是仅写入数据块及其直接节点块,不包括其他节点或F2FS元数据块。为了在回滚到稳定的检查点后有选择地查找数据块,F2FS在直接节点块内保留一个特殊标志。




F2FS按照以下方式执行前滚恢复。如果我们将最新的一个稳定检查点的日志位置表示为N,(1)F2FS收集具有位于N + n中的特殊标志的直接节点块,同时构建它们的节点信息的列表。 n是指自上一个检查点以来更新的块数。 (2)通过使用列表中的节点信息,它将最近写入的名为N-n的节点块加载到页面缓存中。 (3)然后,它比较N-n和N + n之间的数据索引。 (4)如果检测到不同的数据索引,则刷新存储在N + n中的新索引的高速缓存节点块,最后将其标记为脏。一旦完成前滚恢复,F2FS将执行检查点操作以将整个内存中的更改存储到磁盘。

             

猜你喜欢

转载自blog.csdn.net/qwerrfxgj/article/details/79341442