• Filipe Manana's avatar
    Btrfs: scrub, move setup of nofs contexts higher in the stack · 7c3c7cb9
    Filipe Manana authored
    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: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    7c3c7cb9
scrub.c 106 KB