• Tejun Heo's avatar
    writeback: flush inode cgroup wb switches instead of pinning super_block · a1a0e23e
    Tejun Heo authored
    If cgroup writeback is in use, inodes can be scheduled for
    asynchronous wb switching.  Before 5ff8eaac ("writeback: keep
    superblock pinned during cgroup writeback association switches"), this
    could race with umount leading to super_block being destroyed while
    inodes are pinned for wb switching.  5ff8eaac fixed it by bumping
    s_active while wb switches are in flight; however, this allowed
    in-flight wb switches to make umounts asynchronous when the userland
    expected synchronosity - e.g. fsck immediately following umount may
    fail because the device is still busy.
    
    This patch removes the problematic super_block pinning and instead
    makes generic_shutdown_super() flush in-flight wb switches.  wb
    switches are now executed on a dedicated isw_wq so that they can be
    flushed and isw_nr_in_flight keeps track of the number of in-flight wb
    switches so that flushing can be avoided in most cases.
    
    v2: Move cgroup_writeback_umount() further below and add MS_ACTIVE
        check in inode_switch_wbs() as Jan an Al suggested.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Reported-by: default avatarTahsin Erdogan <tahsin@google.com>
    Cc: Jan Kara <jack@suse.cz>
    Cc: Al Viro <viro@ZenIV.linux.org.uk>
    Link: http://lkml.kernel.org/g/CAAeU0aNCq7LGODvVGRU-oU_o-6enii5ey0p1c26D1ZzYwkDc5A@mail.gmail.com
    Fixes: 5ff8eaac ("writeback: keep superblock pinned during cgroup writeback association switches")
    Cc: stable@vger.kernel.org #v4.5
    Reviewed-by: default avatarJan Kara <jack@suse.cz>
    Tested-by: default avatarTahsin Erdogan <tahsin@google.com>
    Signed-off-by: default avatarJens Axboe <axboe@fb.com>
    a1a0e23e
writeback.h 12.3 KB