Commit e38992be authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: make __process_pages_contig() to handle subpage dirty/error/writeback status

For __process_pages_contig() and process_one_page(), to handle subpage
we only need to pass bytenr in and call subpage helpers to handle
dirty/error/writeback status.

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>
parent f02a85d2
...@@ -1816,10 +1816,16 @@ bool btrfs_find_delalloc_range(struct extent_io_tree *tree, u64 *start, ...@@ -1816,10 +1816,16 @@ bool btrfs_find_delalloc_range(struct extent_io_tree *tree, u64 *start,
* Return -EGAIN if the we need to try again. * Return -EGAIN if the we need to try again.
* (For PAGE_LOCK case but got dirty page or page not belong to mapping) * (For PAGE_LOCK case but got dirty page or page not belong to mapping)
*/ */
static int process_one_page(struct address_space *mapping, static int process_one_page(struct btrfs_fs_info *fs_info,
struct address_space *mapping,
struct page *page, struct page *locked_page, struct page *page, struct page *locked_page,
unsigned long page_ops) unsigned long page_ops, u64 start, u64 end)
{ {
u32 len;
ASSERT(end + 1 - start != 0 && end + 1 - start < U32_MAX);
len = end + 1 - start;
if (page_ops & PAGE_SET_ORDERED) if (page_ops & PAGE_SET_ORDERED)
SetPageOrdered(page); SetPageOrdered(page);
...@@ -1827,13 +1833,13 @@ static int process_one_page(struct address_space *mapping, ...@@ -1827,13 +1833,13 @@ static int process_one_page(struct address_space *mapping,
return 1; return 1;
if (page_ops & PAGE_SET_ERROR) if (page_ops & PAGE_SET_ERROR)
SetPageError(page); btrfs_page_clamp_set_error(fs_info, page, start, len);
if (page_ops & PAGE_START_WRITEBACK) { if (page_ops & PAGE_START_WRITEBACK) {
clear_page_dirty_for_io(page); btrfs_page_clamp_clear_dirty(fs_info, page, start, len);
set_page_writeback(page); btrfs_page_clamp_set_writeback(fs_info, page, start, len);
} }
if (page_ops & PAGE_END_WRITEBACK) if (page_ops & PAGE_END_WRITEBACK)
end_page_writeback(page); btrfs_page_clamp_clear_writeback(fs_info, page, start, len);
if (page_ops & PAGE_LOCK) { if (page_ops & PAGE_LOCK) {
lock_page(page); lock_page(page);
if (!PageDirty(page) || page->mapping != mapping) { if (!PageDirty(page) || page->mapping != mapping) {
...@@ -1851,6 +1857,7 @@ static int __process_pages_contig(struct address_space *mapping, ...@@ -1851,6 +1857,7 @@ static int __process_pages_contig(struct address_space *mapping,
u64 start, u64 end, unsigned long page_ops, u64 start, u64 end, unsigned long page_ops,
u64 *processed_end) u64 *processed_end)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(mapping->host->i_sb);
pgoff_t start_index = start >> PAGE_SHIFT; pgoff_t start_index = start >> PAGE_SHIFT;
pgoff_t end_index = end >> PAGE_SHIFT; pgoff_t end_index = end >> PAGE_SHIFT;
pgoff_t index = start_index; pgoff_t index = start_index;
...@@ -1887,8 +1894,9 @@ static int __process_pages_contig(struct address_space *mapping, ...@@ -1887,8 +1894,9 @@ static int __process_pages_contig(struct address_space *mapping,
for (i = 0; i < found_pages; i++) { for (i = 0; i < found_pages; i++) {
int process_ret; int process_ret;
process_ret = process_one_page(mapping, pages[i], process_ret = process_one_page(fs_info, mapping,
locked_page, page_ops); pages[i], locked_page, page_ops,
start, end);
if (process_ret < 0) { if (process_ret < 0) {
for (; i < found_pages; i++) for (; i < found_pages; i++)
put_page(pages[i]); put_page(pages[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment