writeback, cgroup: switch inodes with dirty timestamps to release dying cgwbs
[ Upstream commit 6654408a33e6297d8e1d2773409431d487399b95 ]
The cgwb cleanup routine will try to release the dying cgwb by switching
the attached inodes. It fetches the attached inodes from wb->b_attached
list, omitting the fact that inodes only with dirty timestamps reside in
wb->b_dirty_time list, which is the case when lazytime is enabled. This
causes enormous zombie memory cgroup when lazytime is enabled, as inodes
with dirty timestamps can not be switched to a live cgwb for a long time.
It is reasonable not to switch cgwb for inodes with dirty data, as
otherwise it may break the bandwidth restrictions. However since the
writeback of inode metadata is not accounted for, let's also switch
inodes with dirty timestamps to avoid zombie memory and block cgroups
when laztytime is enabled.
Fixes: c22d70a162
("writeback, cgroup: release dying cgwbs by switching attached inodes")
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20231014125511.102978-1-jefflexu@linux.alibaba.com
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
2bb46b2082
Коммит
565f9337b6
|
@ -609,6 +609,24 @@ out_free:
|
||||||
kfree(isw);
|
kfree(isw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isw_prepare_wbs_switch(struct inode_switch_wbs_context *isw,
|
||||||
|
struct list_head *list, int *nr)
|
||||||
|
{
|
||||||
|
struct inode *inode;
|
||||||
|
|
||||||
|
list_for_each_entry(inode, list, i_io_list) {
|
||||||
|
if (!inode_prepare_wbs_switch(inode, isw->new_wb))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
isw->inodes[*nr] = inode;
|
||||||
|
(*nr)++;
|
||||||
|
|
||||||
|
if (*nr >= WB_MAX_INODES_PER_ISW - 1)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cleanup_offline_cgwb - detach associated inodes
|
* cleanup_offline_cgwb - detach associated inodes
|
||||||
* @wb: target wb
|
* @wb: target wb
|
||||||
|
@ -621,7 +639,6 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb)
|
||||||
{
|
{
|
||||||
struct cgroup_subsys_state *memcg_css;
|
struct cgroup_subsys_state *memcg_css;
|
||||||
struct inode_switch_wbs_context *isw;
|
struct inode_switch_wbs_context *isw;
|
||||||
struct inode *inode;
|
|
||||||
int nr;
|
int nr;
|
||||||
bool restart = false;
|
bool restart = false;
|
||||||
|
|
||||||
|
@ -643,17 +660,17 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb)
|
||||||
|
|
||||||
nr = 0;
|
nr = 0;
|
||||||
spin_lock(&wb->list_lock);
|
spin_lock(&wb->list_lock);
|
||||||
list_for_each_entry(inode, &wb->b_attached, i_io_list) {
|
/*
|
||||||
if (!inode_prepare_wbs_switch(inode, isw->new_wb))
|
* In addition to the inodes that have completed writeback, also switch
|
||||||
continue;
|
* cgwbs for those inodes only with dirty timestamps. Otherwise, those
|
||||||
|
* inodes won't be written back for a long time when lazytime is
|
||||||
isw->inodes[nr++] = inode;
|
* enabled, and thus pinning the dying cgwbs. It won't break the
|
||||||
|
* bandwidth restrictions, as writeback of inode metadata is not
|
||||||
if (nr >= WB_MAX_INODES_PER_ISW - 1) {
|
* accounted for.
|
||||||
restart = true;
|
*/
|
||||||
break;
|
restart = isw_prepare_wbs_switch(isw, &wb->b_attached, &nr);
|
||||||
}
|
if (!restart)
|
||||||
}
|
restart = isw_prepare_wbs_switch(isw, &wb->b_dirty_time, &nr);
|
||||||
spin_unlock(&wb->list_lock);
|
spin_unlock(&wb->list_lock);
|
||||||
|
|
||||||
/* no attached inodes? bail out */
|
/* no attached inodes? bail out */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче