/* * why some writeback work was initiated
*/ enum wb_reason {
WB_REASON_BACKGROUND,
WB_REASON_VMSCAN,
WB_REASON_SYNC,
WB_REASON_PERIODIC,
WB_REASON_LAPTOP_TIMER,
WB_REASON_FS_FREE_SPACE, /* * There is no bdi forker thread any more and works are done * by emergency worker, however, this is TPs userland visible * and we'll be exposing exactly the same information, * so it has a mismatch name.
*/
WB_REASON_FORKER_THREAD,
WB_REASON_FOREIGN_FLUSH,
/* * If one wants to wait for one or more wb_writeback_works, each work's * ->done should be set to a wb_completion defined using the following * macro. Once all work items are issued with wb_queue_work(), the caller * can wait for the completion of all using wb_wait_for_completion(). Work * items which are waited upon aren't freed automatically on completion.
*/ #define WB_COMPLETION_INIT(bdi) __WB_COMPLETION_INIT(&(bdi)->wb_waitq)
/* * Each wb (bdi_writeback) can perform writeback operations, is measured * and throttled, independently. Without cgroup writeback, each bdi * (bdi_writeback) is served by its embedded bdi->wb. * * On the default hierarchy, blkcg implicitly enables memcg. This allows * using memcg's page ownership for attributing writeback IOs, and every * memcg - blkcg combination can be served by its own wb by assigning a * dedicated wb to each memcg, which enables isolation across different * cgroups and propagation of IO back pressure down from the IO layer upto * the tasks which are generating the dirty pages to be written back. * * A cgroup wb is indexed on its bdi by the ID of the associated memcg, * refcounted with the number of inodes attached to it, and pins the memcg * and the corresponding blkcg. As the corresponding blkcg for a memcg may * change as blkcg is disabled and enabled higher up in the hierarchy, a wb * is tested for blkcg after lookup and removed from index on mismatch so * that a new wb for the combination can be created. * * Each bdi_writeback that is not embedded into the backing_dev_info must hold * a reference to the parent backing_dev_info. See cgwb_create() for details.
*/ struct bdi_writeback { struct backing_dev_info *bdi; /* our parent bdi */
unsignedlong state; /* Always use atomic bitops on this */ unsignedlong last_old_flush; /* last old data flush */
struct list_head b_dirty; /* dirty inodes */ struct list_head b_io; /* parked for writeback */ struct list_head b_more_io; /* parked for more writeback */ struct list_head b_dirty_time; /* time stamps are dirty */
spinlock_t list_lock; /* protects the b_* lists */
atomic_t writeback_inodes; /* number of inodes under writeback */ struct percpu_counter stat[NR_WB_STAT_ITEMS];
unsignedlong bw_time_stamp; /* last time write bw is updated */ unsignedlong dirtied_stamp; unsignedlong written_stamp; /* pages written at bw_time_stamp */ unsignedlong write_bandwidth; /* the estimated write bandwidth */ unsignedlong avg_write_bandwidth; /* further smoothed write bw, > 0 */
/* * The base dirty throttle rate, re-calculated on every 200ms. * All the bdi tasks' dirty rate will be curbed under it. * @dirty_ratelimit tracks the estimated @balanced_dirty_ratelimit * in small steps and is much more smooth/stable than the latter.
*/ unsignedlong dirty_ratelimit; unsignedlong balanced_dirty_ratelimit;
struct fprop_local_percpu completions; int dirty_exceeded; enum wb_reason start_all_reason;
spinlock_t work_lock; /* protects work_list & dwork scheduling */ struct list_head work_list; struct delayed_work dwork; /* work item used for writeback */ struct delayed_work bw_dwork; /* work item used for bandwidth estimate */
struct list_head bdi_node; /* anchored at bdi->wb_list */
#ifdef CONFIG_CGROUP_WRITEBACK struct percpu_ref refcnt; /* used only for !root wb's */ struct fprop_local_percpu memcg_completions; struct cgroup_subsys_state *memcg_css; /* the associated memcg */ struct cgroup_subsys_state *blkcg_css; /* and blkcg */ struct list_head memcg_node; /* anchored at memcg->cgwb_list */ struct list_head blkcg_node; /* anchored at blkcg->cgwb_list */ struct list_head b_attached; /* attached inodes, protected by list_lock */ struct list_head offline_node; /* anchored at offline_cgwbs */
/* * Sum of avg_write_bw of wbs with dirty inodes. > 0 if there are * any dirty wbs, which is depended upon by bdi_has_dirty().
*/
atomic_long_t tot_write_bandwidth; /* * Jiffies when last process was dirty throttled on this bdi. Used by * blk-wbt.
*/ unsignedlong last_bdp_sleep;
struct bdi_writeback wb; /* the root writeback info for this bdi */ struct list_head wb_list; /* list of all wbs */ #ifdef CONFIG_CGROUP_WRITEBACK struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */ struct mutex cgwb_release_mutex; /* protect shutdown of wb structs */ struct rw_semaphore wb_switch_rwsem; /* no cgwb switch while syncing */ #endif
wait_queue_head_t wb_waitq;
/** * wb_tryget - try to increment a wb's refcount * @wb: bdi_writeback to get
*/ staticinlinebool wb_tryget(struct bdi_writeback *wb)
{ if (wb != &wb->bdi->wb) return percpu_ref_tryget(&wb->refcnt); returntrue;
}
/** * wb_get - increment a wb's refcount * @wb: bdi_writeback to get
*/ staticinlinevoid wb_get(struct bdi_writeback *wb)
{ if (wb != &wb->bdi->wb)
percpu_ref_get(&wb->refcnt);
}
/** * wb_put - decrement a wb's refcount * @wb: bdi_writeback to put * @nr: number of references to put
*/ staticinlinevoid wb_put_many(struct bdi_writeback *wb, unsignedlong nr)
{ if (WARN_ON_ONCE(!wb->bdi)) { /* * A driver bug might cause a file to be removed before bdi was * initialized.
*/ return;
}
if (wb != &wb->bdi->wb)
percpu_ref_put_many(&wb->refcnt, nr);
}
/** * wb_put - decrement a wb's refcount * @wb: bdi_writeback to put
*/ staticinlinevoid wb_put(struct bdi_writeback *wb)
{
wb_put_many(wb, 1);
}
/** * wb_dying - is a wb dying? * @wb: bdi_writeback of interest * * Returns whether @wb is unlinked and being drained.
*/ staticinlinebool wb_dying(struct bdi_writeback *wb)
{ return percpu_ref_is_dying(&wb->refcnt);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.