页高速缓存的核心结构就address_space对象,他是一个嵌入在页所有者的索引节点对象中的数据结构。高速缓存中的许多页都可能属于一个所有者,从而可能被链接到同一个address_space对象。该对象还在所有者的页和对这些页的操作之间建立起链接关系。
412 struct address_space { 413 struct inode *host; /* owner: inode, block_device */ 414 struct radix_tree_root page_tree; /* radix tree of all pages */ 415 spinlock_t tree_lock; /* and lock protecting it */ 416 unsigned int i_mmap_writable;/* count VM_SHARED mappings */ 417 struct rb_root i_mmap; /* tree of private and shared mappings */ 418 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 419 struct mutex i_mmap_mutex; /* protect tree, count, list */ 420 /* Protected by tree_lock together with the radix tree */ 421 unsigned long nrpages; /* number of total pages */ 422 pgoff_t writeback_index;/* writeback starts here */ 423 const struct address_space_operations *a_ops; /* methods */ 424 unsigned long flags; /* error bits/gfp mask */ 425 struct backing_dev_info *backing_dev_info; /* device readahead, etc */ 426 spinlock_t private_lock; /* for use by the address_space */ 427 struct list_head private_list; /* ditto */ 428 void *private_data; /* ditto */ 429 } __attribute__((aligned(sizeof(long))));struct address_space
--413-->这个address_space对象所属的inode对象
--414-->这个address_space对象拥有的radix_tree_root对象
--425-->指向backing_dev_info对象,这个对象描述了所有者的数据所在的块设备,通常嵌入在块设备的请求队列描述符中。
描述一个radix树的根,内核使用这个数据结构快速的查找增删一个inode拥有的页高速缓存页
64 struct radix_tree_root { 65 unsigned int height; 66 gfp_t gfp_mask; 67 struct radix_tree_node __rcu *rnode; 68 }; 50 struct radix_tree_node { 51 unsigned int height; /* Height from the bottom */ 52 unsigned int count; 53 union { 54 struct radix_tree_node *parent; /* Used when ascending tree */ 55 struct rcu_head rcu_head; /* Used when freeing node */ 56 }; 57 void __rcu *slots[RADIX_TREE_MAP_SIZE]; 58 unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; 59 };struct radix_tree_node
--51-->当前树的深度,不包括叶子节点的层数
--52-->记录节点中非空指针数量的计数器
--57-->slot是包含64个指针的数组,每个元素可以指向其他节点(struct radix_tree_node)或者页描述符(struct page),上层节点指向其他节点,底层节点指向页描述符(叶子节点)
--58-->tag二维数组用于对radix_tree_node基树进行标记,下面就是一个页可能的标志