zoukankan      html  css  js  c++  java
  • 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数据结构被两个结构控制:一个是基数树【负责索引】,一个是链表。

  • 相关阅读:
    sql 将某列转换成一个字符串 for xml path用法
    IAsyncResult 接口异步 和 匿名委托
    存储过程和sql语句的优缺点
    ADO.net中常用的对象有哪些?分别描述一下。
    ASP.Net页面生命周期
    请说明在.net中常用的几种页面间传递参数的方法,并说出他们的优缺点。
    .net常用的传值的方法
    SQL列合并
    程序员的情书!
    程序员的表达!
  • 原文地址:https://www.cnblogs.com/honpey/p/4946128.html
Copyright © 2011-2022 走看看