• Roman Gushchin's avatar
    writeback, cgroup: support switching multiple inodes at once · f5fbe6b7
    Roman Gushchin authored
    Currently only a single inode can be switched to another writeback
    structure at once.  That means to switch an inode a separate
    inode_switch_wbs_context structure must be allocated, and a separate rcu
    callback and work must be scheduled.
    
    It's fine for the existing ad-hoc switching, which is not happening that
    often, but sub-optimal for massive switching required in order to release
    a writeback structure.  To prepare for it, let's add a support for
    switching multiple inodes at once.
    
    Instead of containing a single inode pointer, inode_switch_wbs_context
    will contain a NULL-terminated array of inode pointers.
    inode_do_switch_wbs() will be called for each inode.
    
    To optimize the locking bdi->wb_switch_rwsem, old_wb's and new_wb's
    list_locks will be acquired and released only once altogether for all
    inodes.  wb_wakeup() will be also be called only once.  Instead of calling
    wb_put(old_wb) after each successful switch, wb_put_many() is introduced
    and used.
    
    Link: https://lkml.kernel.org/r/20210608230225.2078447-8-guro@fb.comSigned-off-by: default avatarRoman Gushchin <guro@fb.com>
    Acked-by: default avatarTejun Heo <tj@kernel.org>
    Reviewed-by: default avatarJan Kara <jack@suse.cz>
    Acked-by: default avatarDennis Zhou <dennis@kernel.org>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: Dave Chinner <dchinner@redhat.com>
    Cc: Jan Kara <jack@suse.com>
    Cc: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    f5fbe6b7
fs-writeback.c 77.4 KB