f2fs 空閒塊的管理

相關數據結構

node manager

記錄空閒塊和數據位圖,在內存中:

struct f2fs_nm_info {
        block_t nat_blkaddr;            /* base disk address of NAT */
        nid_t max_nid;                  /* maximum possible node ids */
        nid_t available_nids;           /* # of available node ids */
        nid_t next_scan_nid;            /* the next nid to be scanned */
        unsigned int ram_thresh;        /* control the memory footprint */
        unsigned int ra_nid_pages;      /* # of nid pages to be readaheaded */
        unsigned int dirty_nats_ratio;  /* control dirty nats ratio threshold */

        /* NAT cache management */
        struct radix_tree_root nat_root;/* root of the nat entry cache */
        struct radix_tree_root nat_set_root;/* root of the nat set cache */
        struct rw_semaphore nat_tree_lock;      /* protect nat_tree_lock */
        struct list_head nat_entries;   /* cached nat entry list (clean) */
        spinlock_t nat_list_lock;       /* protect clean nat entry list */
        unsigned int nat_cnt;           /* the # of cached nat entries */
        unsigned int dirty_nat_cnt;     /* total num of nat entries in set */
        unsigned int nat_blocks;        /* # of nat blocks */

        /* free node ids management */
        struct radix_tree_root free_nid_root;/* root of the free_nid cache */
        struct list_head free_nid_list;         /* list for free nids excluding preallocated nids */
        unsigned int nid_cnt[MAX_NID_STATE];    /* the number of free node id */
        spinlock_t nid_list_lock;       /* protect nid lists ops */
        struct mutex build_lock;        /* lock for build free nids */
        unsigned char **free_nid_bitmap;
        unsigned char *nat_block_bitmap;
        unsigned short *free_nid_count; /* free nid count of NAT block */

        /* for checkpoint */
        char *nat_bitmap;               /* NAT bitmap pointer */

        unsigned int nat_bits_blocks;   /* # of nat bits blocks */
        unsigned char *nat_bits;        /* NAT bits blocks */
        unsigned char *full_nat_bits;   /* full NAT pages */
        unsigned char *empty_nat_bits;  /* empty NAT pages */
#ifdef CONFIG_F2FS_CHECK_FS
        char *nat_bitmap_mir;           /* NAT bitmap mirror */
#endif
        int bitmap_size;                /* bitmap size */
};

全局記錄上述信息的sb_info

struct f2fs_sb_info {
        struct super_block *sb;                 /* pointer to VFS super block */
        struct proc_dir_entry *s_proc;          /* proc entry */
        struct f2fs_super_block *raw_super;     /* raw super block pointer */
        struct rw_semaphore sb_lock;            /* lock for raw super block */
        int valid_super_block;                  /* valid super block no */
        unsigned long s_flag;                           /* flags for sbi */
        struct mutex writepages;                /* mutex for writepages() */

#ifdef CONFIG_BLK_DEV_ZONED
        unsigned int blocks_per_blkz;           /* F2FS blocks per zone */
        unsigned int log_blocks_per_blkz;       /* log2 F2FS blocks per zone */
#endif

        /* for node-related operations */
        struct f2fs_nm_info *nm_info;           /* node manager */
        struct inode *node_inode;               /* cache node blocks */

-----

        /* for segment-related operations */
        struct f2fs_sm_info *sm_info;           /* segment manager */

-----

        /* for bio operations */
        struct f2fs_bio_info *write_io[NR_PAGE_TYPE];   /* for write bios */
        struct mutex wio_mutex[NR_PAGE_TYPE - 1][NR_TEMP_TYPE];
                                                /* bio ordering for NODE/DATA */
        /* keep migration IO order for LFS mode */
        struct rw_semaphore io_order_lock;
        mempool_t *write_io_dummy;              /* Dummy pages */
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章