Skip to content

Commit 873695b

Browse files
Liu Bokdave
authored andcommitted
Btrfs: create helper for processing bits on contiguous pages
This introduces a new helper which can be used to process pages bits. Signed-off-by: Liu Bo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent e4c3b2d commit 873695b

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

fs/btrfs/extent_io.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,28 +1731,22 @@ STATIC u64 find_lock_delalloc_range(struct inode *inode,
17311731
return found;
17321732
}
17331733

1734-
void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
1735-
u64 delalloc_end, struct page *locked_page,
1736-
unsigned clear_bits,
1737-
unsigned long page_ops)
1734+
static void __process_pages_contig(struct address_space *mapping,
1735+
struct page *locked_page,
1736+
pgoff_t start_index, pgoff_t end_index,
1737+
unsigned long page_ops)
17381738
{
1739-
struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree;
1740-
int ret;
1739+
unsigned long nr_pages = end_index - start_index + 1;
1740+
pgoff_t index = start_index;
17411741
struct page *pages[16];
1742-
unsigned long index = start >> PAGE_SHIFT;
1743-
unsigned long end_index = end >> PAGE_SHIFT;
1744-
unsigned long nr_pages = end_index - index + 1;
1742+
unsigned ret;
17451743
int i;
17461744

1747-
clear_extent_bit(tree, start, end, clear_bits, 1, 0, NULL, GFP_NOFS);
1748-
if (page_ops == 0)
1749-
return;
1750-
17511745
if ((page_ops & PAGE_SET_ERROR) && nr_pages > 0)
1752-
mapping_set_error(inode->i_mapping, -EIO);
1746+
mapping_set_error(mapping, -EIO);
17531747

17541748
while (nr_pages > 0) {
1755-
ret = find_get_pages_contig(inode->i_mapping, index,
1749+
ret = find_get_pages_contig(mapping, index,
17561750
min_t(unsigned long,
17571751
nr_pages, ARRAY_SIZE(pages)), pages);
17581752
for (i = 0; i < ret; i++) {
@@ -1782,6 +1776,19 @@ void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
17821776
}
17831777
}
17841778

1779+
void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
1780+
u64 delalloc_end, struct page *locked_page,
1781+
unsigned clear_bits,
1782+
unsigned long page_ops)
1783+
{
1784+
clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, clear_bits, 1, 0,
1785+
NULL, GFP_NOFS);
1786+
1787+
__process_pages_contig(inode->i_mapping, locked_page,
1788+
start >> PAGE_SHIFT, end >> PAGE_SHIFT,
1789+
page_ops);
1790+
}
1791+
17851792
/*
17861793
* count the number of bytes in the tree that have a given bit(s)
17871794
* set. This can be fairly slow, except for EXTENT_DIRTY which is

0 commit comments

Comments
 (0)