ubifs - master node

来源:互联网 发布:交通数据采集标准规范 编辑:程序博客网 时间:2024/06/14 05:21

master node

-存储经常更改的数据

-LEB1和LEB2用来存储两份相同的master node

-拥有最大序列号的master node是最后更新的信息

-每个inode numer只用一次


一个master node,占用512字节。


fs/ubifs/ubifs-media.h

/**
 * struct ubifs_mst_node - master node.
 */
struct ubifs_mst_node {
struct ubifs_ch ch;              // * @ch: common header
__le64 highest_inum;       // * @inode序列号,最大数有效,每创建一个新文件就会加1
__le64 cmt_no;                   // * @cmt_no: 系统最后commit 序列号
__le32 flags;                       // * @flags: various flags (%UBIFS_MST_DIRTY, etc)
__le32 log_lnum;               //* @log_lnum: start of the log
__le32 root_lnum;              // * @root_lnum: LEB number of the root indexing node
__le32 root_offs;                // * @root_offs: offset within @root_lnum(root inode在leb内的偏移)
__le32 root_len;                 //* @root_len: root indexing node length
__le32 gc_lnum;                // * @gc_lnum: LEB reserved for garbage collection (%-1 value means the LEB was  not reserved and should be reserved on mount)
__le32 ihead_lnum;          //* @ 记录可写入index node的LEB number,ihead_lnum存在的目的是区分index node与non-index node

__le32 ihead_offs;            // * @ihead_offs: offset of index head
__le64 index_size;            // * @index_size: size of index on flash
__le64 total_free;               // * @total_free: total free space in bytes
__le64 total_dirty;              // * @total_dirty: total dirty space in bytes
__le64 total_used;            // * @total_used: total used space in bytes (includes only data LEBs)
__le64 total_dead;            // * @total_dead: total dead space in bytes (includes only data LEBs)
__le64 total_dark;              // * @total_dark: total dark space in bytes (includes only data LEBs)
__le32 lpt_lnum;               // * @lpt_lnum: LEB number of LPT root nnode
__le32 lpt_offs;                  // * @lpt_offs: offset of LPT root nnode
__le32 nhead_lnum;         // * @nhead_lnum: LEB number of LPT head
__le32 nhead_offs;          // * @nhead_offs: offset of LPT head
__le32 ltab_lnum;             // * @ltab_lnum: LEB number of LPT's own lprops table
__le32 ltab_offs;                // * @ltab_offs: offset of LPT's own lprops table
__le32 lsave_lnum;          // * @lsave_lnum: LEB number of LPT's save table (big model only)
__le32 lsave_offs;             // * @lsave_offs: offset of LPT's save table (big model only)
__le32 lscan_lnum;          // * @lscan_lnum: LEB number of last LPT scan
__le32 empty_lebs;          // * @empty_lebs: number of empty logical eraseblocks
__le32 idx_lebs;                // * @idx_lebs: number of indexing logical eraseblocks
__le32 leb_cnt;                  // * @leb_cnt: count of LEBs used by file-system
__u8 padding[344];           // * @padding: reserved for future, zeroes
} __packed;


更新master mode过程

1, 在LEB1中紧随最后一个master node写一个新的,直到空间用完

2,,如果没有空间,就remap LEB1,从offset 0位置写一个新的。

3,按照上述步骤更新LEB2的master node。


查找leb1、leb2来找到master node。

0 0
原创粉丝点击