f2fs源码解析(五) node管理结构梳理

 node是f2fs重要的管理结构, 它非常重要! 系统挂载完毕后, 会有一个f2fs_nm_info结构的node管理器来管理node的分配. f2fs_nm_info中最让人疑惑的是几颗基数树:

 490 struct f2fs_nm_info {
 491     block_t nat_blkaddr;        /* base disk address of NAT */
 492     nid_t max_nid;          /* maximum possible node ids */
 494     nid_t next_scan_nid;        /* the next nid to be scanned */
 497     /* NAT cache management */
 498     struct radix_tree_root nat_root;/* root of the nat entry cache */
 499     struct radix_tree_root nat_set_root;/* root of the nat set cache */
 501     struct list_head nat_entries;   /* cached nat entry list (clean) */
 502     unsigned int nat_cnt;       /* the # of cached nat entries */
 503     unsigned int dirty_nat_cnt; /* total num of nat entries in set */
 505     /* free node ids management */
 506     struct radix_tree_root free_nid_root;/* root of the free_nid cache */
 507     struct list_head free_nid_list; /* a list for free nids */
 509     unsigned int fcnt;      /* the number of free node id */
 512     /* for checkpoint */
 513     char *nat_bitmap;       /* NAT bitmap pointer */
 514     int bitmap_size;        /* bitmap size */
 515 };

三棵基数树分别是: nat_root, nat_set_root, free_nid_root;

首先, 对于整个node管理器来说, 一个核心的结构体是node_info:

 46 struct node_info {
 47     nid_t nid;      /* node id */
 48     nid_t ino;      /* inode number of the node's owner */
 49     block_t blk_addr;   /* block address of the node */
 50     unsigned char version;  /* version of the node */
 51     unsigned char flag; /* for node information bits */
 52 };   
 53 
 54 struct nat_entry {
 55     struct list_head list;  /* for clean or dirty nat list */
 56     struct node_info ni;    /* in-memory node information */
 57 };

发现node_info和f2fs_nat_entry【磁盘上的存储】长得太像了, 甚至比 struct f2fs_nat_entry 还要多出来一个flag 位来表示这个节点的一些属性!

266 struct f2fs_nat_entry {
267
__u8 version; /* latest version of cached nat entry */ 268 __le32 ino; /* inode number */ 269 __le32 block_addr; /* block address */ 270 } __packed;

这个core数据结构被两个结构控制:一个是基数树【负责索引】,一个是链表。

转载于:https://www.cnblogs.com/honpey/p/4946128.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值