On Wed 02-06-21 17:55:14, Roman Gushchin wrote: > Currently there is no way to iterate over inodes attached to a > specific cgwb structure. It limits the ability to efficiently > reclaim the writeback structure itself and associated memory and > block cgroup structures without scanning all inodes belonging to a sb, > which can be prohibitively expensive. > > While dirty/in-active-writeback an inode belongs to one of the > bdi_writeback's io lists: b_dirty, b_io, b_more_io and b_dirty_time. > Once cleaned up, it's removed from all io lists. So the > inode->i_io_list can be reused to maintain the list of inodes, > attached to a bdi_writeback structure. > > This patch introduces a new wb->b_attached list, which contains all > inodes which were dirty at least once and are attached to the given > cgwb. Inodes attached to the root bdi_writeback structures are never > placed on such list. The following patch will use this list to try to > release cgwbs structures more efficiently. > > Suggested-by: Jan Kara <jack@xxxxxxx> > Signed-off-by: Roman Gushchin <guro@xxxxxx> Looks good, just one small comment below, with that fixed feel free to add: Reviewed-by: Jan Kara <jack@xxxxxxx> ... > @@ -1014,6 +1024,12 @@ fs_initcall(cgroup_writeback_init); > static void bdi_down_write_wb_switch_rwsem(struct backing_dev_info *bdi) { } > static void bdi_up_write_wb_switch_rwsem(struct backing_dev_info *bdi) { } > > +static void inode_cgwb_move_to_attached(struct inode *inode, > + struct bdi_writeback *wb) > +{ > + list_del_init(&inode->i_io_list); > +} > + I think you miss clearing of I_SYNC_QUEUED here. Also you could add here the lock assertions that are in the other version of inode_cgwb_move_to_attached(). Honza -- Jan Kara <jack@xxxxxxxx> SUSE Labs, CR