Skip to content

Commit 1358732

Browse files
Li Zetaokdave
authored andcommitted
btrfs: convert submit_eb_subpage() to take a folio
The old page API is being gradually replaced and converted to use folio to improve code readability and avoid repeated conversion between page and folio. Moreover, use folio_pos() instead of page_offset(), which is more consistent with folio usage. Signed-off-by: Li Zetao <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 8849377 commit 1358732

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

fs/btrfs/extent_io.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,12 +1735,11 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
17351735
* Return >=0 for the number of submitted extent buffers.
17361736
* Return <0 for fatal error.
17371737
*/
1738-
static int submit_eb_subpage(struct page *page, struct writeback_control *wbc)
1738+
static int submit_eb_subpage(struct folio *folio, struct writeback_control *wbc)
17391739
{
1740-
struct btrfs_fs_info *fs_info = page_to_fs_info(page);
1741-
struct folio *folio = page_folio(page);
1740+
struct btrfs_fs_info *fs_info = folio_to_fs_info(folio);
17421741
int submitted = 0;
1743-
u64 page_start = page_offset(page);
1742+
u64 folio_start = folio_pos(folio);
17441743
int bit_start = 0;
17451744
int sectors_per_node = fs_info->nodesize >> fs_info->sectorsize_bits;
17461745

@@ -1755,21 +1754,21 @@ static int submit_eb_subpage(struct page *page, struct writeback_control *wbc)
17551754
* Take private lock to ensure the subpage won't be detached
17561755
* in the meantime.
17571756
*/
1758-
spin_lock(&page->mapping->i_private_lock);
1757+
spin_lock(&folio->mapping->i_private_lock);
17591758
if (!folio_test_private(folio)) {
1760-
spin_unlock(&page->mapping->i_private_lock);
1759+
spin_unlock(&folio->mapping->i_private_lock);
17611760
break;
17621761
}
17631762
spin_lock_irqsave(&subpage->lock, flags);
17641763
if (!test_bit(bit_start + btrfs_bitmap_nr_dirty * fs_info->sectors_per_page,
17651764
subpage->bitmaps)) {
17661765
spin_unlock_irqrestore(&subpage->lock, flags);
1767-
spin_unlock(&page->mapping->i_private_lock);
1766+
spin_unlock(&folio->mapping->i_private_lock);
17681767
bit_start++;
17691768
continue;
17701769
}
17711770

1772-
start = page_start + bit_start * fs_info->sectorsize;
1771+
start = folio_start + bit_start * fs_info->sectorsize;
17731772
bit_start += sectors_per_node;
17741773

17751774
/*
@@ -1778,7 +1777,7 @@ static int submit_eb_subpage(struct page *page, struct writeback_control *wbc)
17781777
*/
17791778
eb = find_extent_buffer_nolock(fs_info, start);
17801779
spin_unlock_irqrestore(&subpage->lock, flags);
1781-
spin_unlock(&page->mapping->i_private_lock);
1780+
spin_unlock(&folio->mapping->i_private_lock);
17821781

17831782
/*
17841783
* The eb has already reached 0 refs thus find_extent_buffer()
@@ -1829,7 +1828,7 @@ static int submit_eb_page(struct page *page, struct btrfs_eb_write_context *ctx)
18291828
return 0;
18301829

18311830
if (page_to_fs_info(page)->nodesize < PAGE_SIZE)
1832-
return submit_eb_subpage(page, wbc);
1831+
return submit_eb_subpage(folio, wbc);
18331832

18341833
spin_lock(&mapping->i_private_lock);
18351834
if (!folio_test_private(folio)) {

0 commit comments

Comments
 (0)