Writeback related data structure
The data structures related to writeback include:
1,backing_dev_info, the data structure describes all of the information for Backing_dev, which typically contains Backing_dev objects in the request queue of a block device.
2,bdi_writeback, the data structure encapsulates writeback kernel threads and the inode queues that need to be manipulated.
3,wb_writeback_work, the data structure encapsulates writeback's work tasks.
The relationships between the data structures are shown in the following illustration:
The following is a brief introduction to each data structure.
BDI Information
The BDI object needs to be registered in the system's BDI queue when the block device is added. For ext3, the BDI object of the underlying block device needs to be contacted in the Ext3 Root_inode at Mount time. The BDI object data structure is defined as follows:
struct Backing_dev_info {struct list_head bdi_list; unsigned long ra_pages; /* Max ReadAhead in page_cache_size units/unsigned long state; /* Always use atomic bitops in this * * * unsigned int capabilities; /* Device Capabilities * * CONGESTED_FN *CONGESTED_FN; /* Function pointer if device is MD/DM/void *congested_data;
/* Pointer to aux the data for congested func */char *name;
struct Percpu_counter Bdi_stat[nr_bdi_stat_items]; unsigned long bw_time_stamp;
/* Last time Write BW is updated */unsigned long dirtied_stamp; unsigned long written_stamp; /* pages written at Bw_time_stamp */unsigned long write_bandwidth; /* The estimated write bandwidth * * unsigned long avg_write_bandwidth;
* Further smoothed Write bw/* * The base dirty throttle rate, re-calculated on every 200ms.
* All the BDI tasks ' dirty rate would be curbed under it. * @dirty_ratelimit TRacks The estimated @balanced_dirty_ratelimit * in small steps and are much more smooth/stable than the latter.
* * unsigned long dirty_ratelimit;
unsigned long balanced_dirty_ratelimit;
struct PROP_LOCAL_PERCPU completions;
int dirty_exceeded;
unsigned int min_ratio;
unsigned int max_ratio, Max_prop_frac; struct Bdi_writeback wb; /* Default writeback info for this Bdi,writeback object * * spinlock_t wb_lock;
/* Protects work_list * * * struct list_head work_list;
struct device *dev;
* * In laptop mode of the application of the timer/struct timer_list laptop_mode_wb_timer;
#ifdef config_debug_fs struct dentry *debug_dir;
struct Dentry *debug_stats; #endif};
A writeback object is defined in the BDI data structure, which is a description of the writeback kernel thread and encapsulates the inode queues that need to be processed. There is a work_list in the BDI data structure that maintains the tasks that writeback kernel threads need to handle. If no work can be processed on the queue, the writeback kernel thread will sleep and wait.