• Qu Wenruo's avatar
    btrfs: make process_one_page() to handle subpage locking · 1e1de387
    Qu Wenruo authored
    Introduce a new data inodes specific subpage member, writers, to record
    how many sectors are under page lock for delalloc writing.
    
    This member acts pretty much the same as readers, except it's only for
    delalloc writes.
    
    This is important for delalloc code to trace which page can really be
    freed, as we have cases like run_delalloc_nocow() where we may exit
    processing nocow range inside a page, but need to exit to do cow half
    way.
    In that case, we need a way to determine if we can really unlock a full
    page.
    
    With the new btrfs_subpage::writers, there is a new requirement:
    - Page locked by process_one_page() must be unlocked by
      process_one_page()
      There are still tons of call sites manually lock and unlock a page,
      without updating btrfs_subpage::writers.
      So if we lock a page through process_one_page() then it must be
      unlocked by process_one_page() to keep btrfs_subpage::writers
      consistent.
    
      This will be handled in next patch.
    
    Tested-by: Ritesh Harjani <riteshh@linux.ibm.com> # [ppc64]
    Tested-by: Anand Jain <anand.jain@oracle.com> # [aarch64]
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    1e1de387
subpage.h 4.12 KB