Btrfs: scrub, move setup of nofs contexts higher in the stack
authorFilipe Manana <fdmanana@suse.com>
Fri, 7 Dec 2018 13:23:32 +0000 (13:23 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:48 +0000 (14:51 +0100)
commit7c3c7cb99c771c4ce6a01a95e969dbc576fd7533
tree67c1a25a3b1357a9dadbbfc6fff627e84a80ac12
parent0e94c4f45d14cf89d1f40c91b0a8517e791672a7
Btrfs: scrub, move setup of nofs contexts higher in the stack

Since scrub workers only do memory allocation with GFP_KERNEL when they
need to perform repair, we can move the recent setup of the nofs context
up to scrub_handle_errored_block() instead of setting it up down the call
chain at insert_full_stripe_lock() and scrub_add_page_to_wr_bio(),
removing some duplicate code and comment. So the only paths for which a
scrub worker can do memory allocations using GFP_KERNEL are the following:

 scrub_bio_end_io_worker()
   scrub_block_complete()
     scrub_handle_errored_block()
       lock_full_stripe()
         insert_full_stripe_lock()
           -> kmalloc with GFP_KERNEL

  scrub_bio_end_io_worker()
    scrub_block_complete()
      scrub_handle_errored_block()
        scrub_write_page_to_dev_replace()
          scrub_add_page_to_wr_bio()
            -> kzalloc with GFP_KERNEL

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/scrub.c