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

  • 相关阅读:
    DEBUG_PRINT
    FFMpeg的解码流程
    解决Cannot open the disk 'E:\my Ubuntu\Ubuntu000001.vmdk' or one of the snapshot disks it depends on.(虚拟机突然断电之后)
    关于mov.c的demuxer
    dts
    fprintf
    H264学习(1)
    如何安装不能识别的驱动错误代码为10
    mplayer先播视频后播音频的解决方法
    团队作业(二) IS191x
  • 原文地址:https://www.cnblogs.com/honpey/p/4946128.html
Copyright © 2011-2022 走看看