• Omar Sandoval's avatar
    btrfs: don't prematurely free work in reada_start_machine_worker() · e732fe95
    Omar Sandoval authored
    Currently, reada_start_machine_worker() frees the reada_machine_work and
    then calls __reada_start_machine() to do readahead. This is another
    potential instance of the bug in "btrfs: don't prematurely free work in
    run_ordered_work()".
    
    There _might_ already be a deadlock here: reada_start_machine_worker()
    can depend on itself through stacked filesystems (__read_start_machine()
    -> reada_start_machine_dev() -> reada_tree_block_flagged() ->
    read_extent_buffer_pages() -> submit_one_bio() ->
    btree_submit_bio_hook() -> btrfs_map_bio() -> submit_stripe_bio() ->
    submit_bio() onto a loop device can trigger readahead on the lower
    filesystem).
    
    Either way, let's fix it by freeing the work at the end.
    Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
    Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    e732fe95
reada.c 24.4 KB