• Qu Wenruo's avatar
    btrfs: refactor alloc_extent_buffer() to allocate-then-attach method · 09e6cef1
    Qu Wenruo authored
    Currently alloc_extent_buffer() utilizes find_or_create_page() to
    allocate one page a time for an extent buffer.
    
    This method has the following disadvantages:
    
    - find_or_create_page() is the legacy way of allocating new pages
      With the new folio infrastructure, find_or_create_page() is just
      redirected to filemap_get_folio().
    
    - Lacks the way to support higher order (order >= 1) folios
      As we can not yet let filemap give us a higher order folio.
    
    This patch would change the workflow by the following way:
    
    		Old		   |		new
    -----------------------------------+-------------------------------------
                                       | ret = btrfs_alloc_page_array();
    for (i = 0; i < num_pages; i++) {  | for (i = 0; i < num_pages; i++) {
        p = find_or_create_page();     |     ret = filemap_add_folio();
        /* Attach page private */      |     /* Reuse page cache if needed */
        /* Reused eb if needed */      |
    				   |     /* Attach page private and
    				   |        reuse eb if needed */
    				   | }
    
    By this we split the page allocation and private attaching into two
    parts, allowing future updates to each part more easily, and migrate to
    folio interfaces (especially for possible higher order folios).
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    09e6cef1
raid56.c 73.8 KB