Chinaunix首页 | 论坛 | 博客
  • 博客访问: 402924
  • 博文数量: 48
  • 博客积分: 764
  • 博客等级: 上士
  • 技术积分: 1133
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-17 13:29
文章分类

全部博文(48)

文章存档

2014年(5)

2013年(34)

2012年(9)

分类: LINUX

2013-01-06 12:16:24


Reference




#define INLINE_EXTENT_BUFFER_PAGES 16

#define MAX_INLINE_EXTENT_BUFFER_SIZE (INLINE_EXTENT_BUFFER_PAGES * PAGE_CACHE_SIZE)

struct extent_buffer {

u64 start;       //Indicates the start address of extent in RAM

unsigned long len;  // The length of extent in RAM

unsigned long map_start;

unsigned long map_len;

unsigned long bflags;

struct extent_io_tree *tree;

spinlock_t refs_lock;

atomic_t refs;

atomic_t io_pages;

int read_mirror;

struct list_head leak_list;

struct rcu_head rcu_head;

pid_t lock_owner;


/* count of read lock holders on the extent buffer */

atomic_t write_locks;

atomic_t read_locks;

atomic_t blocking_writers;

atomic_t blocking_readers;

atomic_t spinning_readers;

atomic_t spinning_writers;

int lock_nested;


/* protects write locks */

rwlock_t lock;


/* readers use lock_wq while they wait for the write

 * lock holders to unlock

 */

wait_queue_head_t write_lock_wq;


/* writers use read_lock_wq while they wait for readers

 * to unlock

 */

wait_queue_head_t read_lock_wq;

wait_queue_head_t lock_wq;

struct page *inline_pages[INLINE_EXTENT_BUFFER_PAGES];

struct page **pages;   // These pages store the contents of extent.

};



/*

 * btrfs_paths remember the path taken from the root down to the leaf.

 * level 0 is always the leaf, and nodes[1...BTRFS_MAX_LEVEL] will point

 * to any other levels that are present.

 *

 * The slots array records the index of the item or block pointer

 * used while walking the tree.

 */

struct btrfs_path {

struct extent_buffer *nodes[BTRFS_MAX_LEVEL];

int slots[BTRFS_MAX_LEVEL];

/* if there is real range locking, this locks field will change */

int locks[BTRFS_MAX_LEVEL];  //store the lock for each level

int reada;

/* keep some upper locks as we walk down */

int lowest_level;


/*

 * set by btrfs_split_item, tells search_slot to keep all locks

 * and to force calls to keep space in the nodes

 */

unsigned int search_for_split:1;

unsigned int keep_locks:1;       

unsigned int skip_locking:1;   //Ignore  lock

unsigned int leave_spinning:1;

unsigned int search_commit_root:1;

};



/*

 * every tree block (leaf or node) starts with this header.

 */

struct btrfs_header {

/* these first four must match the super block */

u8 csum[BTRFS_CSUM_SIZE];

u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */

                           //In RAM

__le64 bytenr; /* which block this node is supposed to live in */

__le64 flags;


/* allowed to be different from the super from here on down */

u8 chunk_tree_uuid[BTRFS_UUID_SIZE];

__le64 generation;

__le64 owner;

__le32 nritems;

u8 level;



/*

 * in ram representation of the tree.  extent_root is used for all allocations

 * and for the extent tree extent_root root.

 */

struct btrfs_root {

struct extent_buffer *node;

         //期待理解commit_roxxot

struct extent_buffer *commit_root; 

         // 比如这个root 是extent_root.那么root_item就是btrfs_root_item in tree_root data.

        //不是btrfs_extent_item  和btrfs_item. 这里面保存了描述root_item的信息。

//如果是tree_root , 那么root_item的 root_dirid 就是BTRFS_ROOT_TREE_DIR_OBJECTID

//see details in btrfs_make_root_dir()      

//对于fs_root来说,root_item 的root_dirid就是BTRFS_FIRST_FREE_OBJECTID

//同上

struct btrfs_root_item root_item;

        //类似上面,就是btrfs_item 中的那个key,details in btrfs_find_last_root()

   

struct btrfs_key root_key;

struct btrfs_fs_info *fs_info;

u64 objectid;

u64 last_trans;


/* data allocations are done in sectorsize units */

u32 sectorsize;


/* node allocations are done in nodesize units */

u32 nodesize;


/* leaf allocations are done in leafsize units */

u32 leafsize;


/* leaf allocations are done in leafsize units */

u32 stripesize;


int ref_cows;

int track_dirty;


u32 type;

u64 highest_inode;

u64 last_inode_alloc;


/* the dirty list is only used by non-reference counted roots */

struct list_head dirty_list;

struct cache_extent cache;

};



struct btrfs_block_group_item {

//in btrfs_make_block_group() is btrfs_super_bytes_used(&root->fs_info->super_copy);

__le64 used; 

//BTRFS_FIRST_CHUNK_TREE_OBJECTID

__le64 chunk_objectid;

//in btrfs_make_block_group() is BTRFS_BLOCK_GROUP_SYSTEM

__le64 flags;



struct btrfs_block_group_cache {

struct cache_extent cache;


//objectid: address of start  group chunk_offset, maybe 0

//offset: length of group , maybe BTRFS_MKFS_SYSTEM_GROUP_SIZE = 4M

//type:BTRFS_BLOCK_GROUP_ITEM_KEY

//BTW: this key is same as  key in the btrfs_item  used to found blow btrfs_block_group_item

// key and item will be insertd extent-tree details in btrfs_make_block_group

struct btrfs_key key;

struct btrfs_block_group_item item;

struct btrfs_space_info *space_info;

u64 pinned;

u64 flags;

int cached;

int ro;

};




struct extent_io_tree { // For example fs_info->block_group_cache;

         //Record extent state, cache  extent

struct cache_tree state;

           // cache   

struct cache_tree cache;

struct list_head lru;

u64 cache_size;

};




struct extent_state {

struct cache_extent cache_node;

u64 start;

u64 end;

int refs;

unsigned long state;

//point to btrfs_block_group_cache inserted in extent_root details in btrfs_make_block_group

u64 private;

};



struct btrfs_bio_stripe {


//pointer to the device that extent allocated from

struct btrfs_device *dev; 

// Start position that  at that device

u64 physical; 

};




struct map_lookup {

struct cache_extent ce;

u64 type;

int io_align;

int io_width;

int stripe_len;

int sector_size;

int num_stripes;

int sub_stripes;   

//This array is used when striping data ,see details in  btrfs_alloc_chunk()

struct btrfs_bio_stripe stripes[]; 

};




struct btrfs_chunk {

/* size of this chunk in bytes */

//In btrfs_alloc_chunk, we can find that the length do not inculde  the copy size

// I think that is to make RAID mechnism opaque.

__le64 length;


/* objectid of the root referencing this chunk */

__le64 owner;


__le64 stripe_len;

__le64 type;


/* optimal io alignment for this chunk */

__le32 io_align;


/* optimal io width for this chunk */

__le32 io_width;


/* minimal io size for this chunk */

__le32 sector_size;


/* 2^16 stripes is quite a lot, a second limit is the size of a single

 * item in the btree

 */

__le16 num_stripes;


/* sub stripes only matter for raid10 */

__le16 sub_stripes;

//In btrfs_alloc_chunk(), we can find it was the same as map_lookup->stripes

//but stripes in map_lookup is btrfs_bio_stripe that only has two memmebrs

// devid and physical. Tere is only devid adn physical address and not include  len.

//Is it stripe_len 64KB currently in btrfs.

struct btrfs_stripe stripe;

/* additional stripes go here */


struct cache_extent {

struct rb_node rb_node;

//不确定用途,是disk 地址吧。应该是。

u64 start;

u64 size;

};














阅读(1494) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~