Commit 6869b0a8 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: merge PAGE_CLEAR_DIRTY and PAGE_SET_WRITEBACK to PAGE_START_WRITEBACK

PAGE_CLEAR_DIRTY and PAGE_SET_WRITEBACK are two defines used in
__process_pages_contig(), to let the function know to clear page dirty
bit and then set page writeback.

However page writeback and dirty bits are conflicting (at least for
sector size == PAGE_SIZE case), this means these two have to be always
updated together.

This means we can merge PAGE_CLEAR_DIRTY and PAGE_SET_WRITEBACK to
PAGE_START_WRITEBACK.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent d0c2f4fa
...@@ -1976,10 +1976,10 @@ static int __process_pages_contig(struct address_space *mapping, ...@@ -1976,10 +1976,10 @@ static int __process_pages_contig(struct address_space *mapping,
pages_processed++; pages_processed++;
continue; continue;
} }
if (page_ops & PAGE_CLEAR_DIRTY) if (page_ops & PAGE_START_WRITEBACK) {
clear_page_dirty_for_io(pages[i]); clear_page_dirty_for_io(pages[i]);
if (page_ops & PAGE_SET_WRITEBACK)
set_page_writeback(pages[i]); set_page_writeback(pages[i]);
}
if (page_ops & PAGE_SET_ERROR) if (page_ops & PAGE_SET_ERROR)
SetPageError(pages[i]); SetPageError(pages[i]);
if (page_ops & PAGE_END_WRITEBACK) if (page_ops & PAGE_END_WRITEBACK)
......
...@@ -35,12 +35,12 @@ enum { ...@@ -35,12 +35,12 @@ enum {
/* these are flags for __process_pages_contig */ /* these are flags for __process_pages_contig */
#define PAGE_UNLOCK (1 << 0) #define PAGE_UNLOCK (1 << 0)
#define PAGE_CLEAR_DIRTY (1 << 1) /* Page starts writeback, clear dirty bit and set writeback bit */
#define PAGE_SET_WRITEBACK (1 << 2) #define PAGE_START_WRITEBACK (1 << 1)
#define PAGE_END_WRITEBACK (1 << 3) #define PAGE_END_WRITEBACK (1 << 2)
#define PAGE_SET_PRIVATE2 (1 << 4) #define PAGE_SET_PRIVATE2 (1 << 3)
#define PAGE_SET_ERROR (1 << 5) #define PAGE_SET_ERROR (1 << 4)
#define PAGE_LOCK (1 << 6) #define PAGE_LOCK (1 << 5)
/* /*
* page->private values. Every page that is controlled by the extent * page->private values. Every page that is controlled by the extent
......
...@@ -692,8 +692,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk) ...@@ -692,8 +692,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
NULL, NULL,
clear_flags, clear_flags,
PAGE_UNLOCK | PAGE_UNLOCK |
PAGE_CLEAR_DIRTY | PAGE_START_WRITEBACK |
PAGE_SET_WRITEBACK |
page_error_op | page_error_op |
PAGE_END_WRITEBACK); PAGE_END_WRITEBACK);
...@@ -933,8 +932,7 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk) ...@@ -933,8 +932,7 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
async_extent->start + async_extent->start +
async_extent->ram_size - 1, async_extent->ram_size - 1,
NULL, EXTENT_LOCKED | EXTENT_DELALLOC, NULL, EXTENT_LOCKED | EXTENT_DELALLOC,
PAGE_UNLOCK | PAGE_CLEAR_DIRTY | PAGE_UNLOCK | PAGE_START_WRITEBACK);
PAGE_SET_WRITEBACK);
if (btrfs_submit_compressed_write(inode, async_extent->start, if (btrfs_submit_compressed_write(inode, async_extent->start,
async_extent->ram_size, async_extent->ram_size,
ins.objectid, ins.objectid,
...@@ -970,9 +968,8 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk) ...@@ -970,9 +968,8 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
NULL, EXTENT_LOCKED | EXTENT_DELALLOC | NULL, EXTENT_LOCKED | EXTENT_DELALLOC |
EXTENT_DELALLOC_NEW | EXTENT_DELALLOC_NEW |
EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING, EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING,
PAGE_UNLOCK | PAGE_CLEAR_DIRTY | PAGE_UNLOCK | PAGE_START_WRITEBACK |
PAGE_SET_WRITEBACK | PAGE_END_WRITEBACK | PAGE_END_WRITEBACK | PAGE_SET_ERROR);
PAGE_SET_ERROR);
free_async_extent_pages(async_extent); free_async_extent_pages(async_extent);
kfree(async_extent); kfree(async_extent);
goto again; goto again;
...@@ -1070,8 +1067,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, ...@@ -1070,8 +1067,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_LOCKED | EXTENT_DELALLOC |
EXTENT_DELALLOC_NEW | EXTENT_DEFRAG | EXTENT_DELALLOC_NEW | EXTENT_DEFRAG |
EXTENT_DO_ACCOUNTING, PAGE_UNLOCK | EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK | PAGE_START_WRITEBACK | PAGE_END_WRITEBACK);
PAGE_END_WRITEBACK);
*nr_written = *nr_written + *nr_written = *nr_written +
(end - start + PAGE_SIZE) / PAGE_SIZE; (end - start + PAGE_SIZE) / PAGE_SIZE;
*page_started = 1; *page_started = 1;
...@@ -1194,8 +1190,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, ...@@ -1194,8 +1190,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
out_unlock: out_unlock:
clear_bits = EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DELALLOC_NEW | clear_bits = EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
EXTENT_DEFRAG | EXTENT_CLEAR_META_RESV; EXTENT_DEFRAG | EXTENT_CLEAR_META_RESV;
page_ops = PAGE_UNLOCK | PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK | page_ops = PAGE_UNLOCK | PAGE_START_WRITEBACK | PAGE_END_WRITEBACK;
PAGE_END_WRITEBACK;
/* /*
* If we reserved an extent for our delalloc range (or a subrange) and * If we reserved an extent for our delalloc range (or a subrange) and
* failed to create the respective ordered extent, then it means that * failed to create the respective ordered extent, then it means that
...@@ -1320,9 +1315,8 @@ static int cow_file_range_async(struct btrfs_inode *inode, ...@@ -1320,9 +1315,8 @@ static int cow_file_range_async(struct btrfs_inode *inode,
unsigned clear_bits = EXTENT_LOCKED | EXTENT_DELALLOC | unsigned clear_bits = EXTENT_LOCKED | EXTENT_DELALLOC |
EXTENT_DELALLOC_NEW | EXTENT_DEFRAG | EXTENT_DELALLOC_NEW | EXTENT_DEFRAG |
EXTENT_DO_ACCOUNTING; EXTENT_DO_ACCOUNTING;
unsigned long page_ops = PAGE_UNLOCK | PAGE_CLEAR_DIRTY | unsigned long page_ops = PAGE_UNLOCK | PAGE_START_WRITEBACK |
PAGE_SET_WRITEBACK | PAGE_END_WRITEBACK | PAGE_END_WRITEBACK | PAGE_SET_ERROR;
PAGE_SET_ERROR;
extent_clear_unlock_delalloc(inode, start, end, locked_page, extent_clear_unlock_delalloc(inode, start, end, locked_page,
clear_bits, page_ops); clear_bits, page_ops);
...@@ -1519,8 +1513,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, ...@@ -1519,8 +1513,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_LOCKED | EXTENT_DELALLOC |
EXTENT_DO_ACCOUNTING | EXTENT_DO_ACCOUNTING |
EXTENT_DEFRAG, PAGE_UNLOCK | EXTENT_DEFRAG, PAGE_UNLOCK |
PAGE_CLEAR_DIRTY | PAGE_START_WRITEBACK |
PAGE_SET_WRITEBACK |
PAGE_END_WRITEBACK); PAGE_END_WRITEBACK);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1842,8 +1835,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, ...@@ -1842,8 +1835,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
locked_page, EXTENT_LOCKED | locked_page, EXTENT_LOCKED |
EXTENT_DELALLOC | EXTENT_DEFRAG | EXTENT_DELALLOC | EXTENT_DEFRAG |
EXTENT_DO_ACCOUNTING, PAGE_UNLOCK | EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
PAGE_CLEAR_DIRTY | PAGE_START_WRITEBACK |
PAGE_SET_WRITEBACK |
PAGE_END_WRITEBACK); PAGE_END_WRITEBACK);
btrfs_free_path(path); btrfs_free_path(path);
return ret; return ret;
......
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