Btrfs: cleanup extent_clear_unlock_delalloc flags
extent_clear_unlock_delalloc has a growing set of ugly parameters that is very difficult to read and maintain. This switches to a flag field and well named flag defines. Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Родитель
1cdda9b81a
Коммит
a791e35e12
|
@ -1401,12 +1401,7 @@ out_failed:
|
||||||
int extent_clear_unlock_delalloc(struct inode *inode,
|
int extent_clear_unlock_delalloc(struct inode *inode,
|
||||||
struct extent_io_tree *tree,
|
struct extent_io_tree *tree,
|
||||||
u64 start, u64 end, struct page *locked_page,
|
u64 start, u64 end, struct page *locked_page,
|
||||||
int unlock_pages,
|
unsigned long op)
|
||||||
int clear_unlock,
|
|
||||||
int clear_delalloc, int clear_dirty,
|
|
||||||
int set_writeback,
|
|
||||||
int end_writeback,
|
|
||||||
int set_private2)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct page *pages[16];
|
struct page *pages[16];
|
||||||
|
@ -1416,17 +1411,17 @@ int extent_clear_unlock_delalloc(struct inode *inode,
|
||||||
int i;
|
int i;
|
||||||
int clear_bits = 0;
|
int clear_bits = 0;
|
||||||
|
|
||||||
if (clear_unlock)
|
if (op & EXTENT_CLEAR_UNLOCK)
|
||||||
clear_bits |= EXTENT_LOCKED;
|
clear_bits |= EXTENT_LOCKED;
|
||||||
if (clear_dirty)
|
if (op & EXTENT_CLEAR_DIRTY)
|
||||||
clear_bits |= EXTENT_DIRTY;
|
clear_bits |= EXTENT_DIRTY;
|
||||||
|
|
||||||
if (clear_delalloc)
|
if (op & EXTENT_CLEAR_DELALLOC)
|
||||||
clear_bits |= EXTENT_DELALLOC;
|
clear_bits |= EXTENT_DELALLOC;
|
||||||
|
|
||||||
clear_extent_bit(tree, start, end, clear_bits, 1, 0, NULL, GFP_NOFS);
|
clear_extent_bit(tree, start, end, clear_bits, 1, 0, NULL, GFP_NOFS);
|
||||||
if (!(unlock_pages || clear_dirty || set_writeback || end_writeback ||
|
if (!(op & (EXTENT_CLEAR_UNLOCK_PAGE | EXTENT_CLEAR_DIRTY | EXTENT_SET_WRITEBACK |
|
||||||
set_private2))
|
EXTENT_END_WRITEBACK | EXTENT_SET_PRIVATE2)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (nr_pages > 0) {
|
while (nr_pages > 0) {
|
||||||
|
@ -1435,20 +1430,20 @@ int extent_clear_unlock_delalloc(struct inode *inode,
|
||||||
nr_pages, ARRAY_SIZE(pages)), pages);
|
nr_pages, ARRAY_SIZE(pages)), pages);
|
||||||
for (i = 0; i < ret; i++) {
|
for (i = 0; i < ret; i++) {
|
||||||
|
|
||||||
if (set_private2)
|
if (op & EXTENT_SET_PRIVATE2)
|
||||||
SetPagePrivate2(pages[i]);
|
SetPagePrivate2(pages[i]);
|
||||||
|
|
||||||
if (pages[i] == locked_page) {
|
if (pages[i] == locked_page) {
|
||||||
page_cache_release(pages[i]);
|
page_cache_release(pages[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (clear_dirty)
|
if (op & EXTENT_CLEAR_DIRTY)
|
||||||
clear_page_dirty_for_io(pages[i]);
|
clear_page_dirty_for_io(pages[i]);
|
||||||
if (set_writeback)
|
if (op & EXTENT_SET_WRITEBACK)
|
||||||
set_page_writeback(pages[i]);
|
set_page_writeback(pages[i]);
|
||||||
if (end_writeback)
|
if (op & EXTENT_END_WRITEBACK)
|
||||||
end_page_writeback(pages[i]);
|
end_page_writeback(pages[i]);
|
||||||
if (unlock_pages)
|
if (op & EXTENT_CLEAR_UNLOCK_PAGE)
|
||||||
unlock_page(pages[i]);
|
unlock_page(pages[i]);
|
||||||
page_cache_release(pages[i]);
|
page_cache_release(pages[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,15 @@
|
||||||
#define EXTENT_BUFFER_BLOCKING 1
|
#define EXTENT_BUFFER_BLOCKING 1
|
||||||
#define EXTENT_BUFFER_DIRTY 2
|
#define EXTENT_BUFFER_DIRTY 2
|
||||||
|
|
||||||
|
/* these are flags for extent_clear_unlock_delalloc */
|
||||||
|
#define EXTENT_CLEAR_UNLOCK_PAGE 0x1
|
||||||
|
#define EXTENT_CLEAR_UNLOCK 0x2
|
||||||
|
#define EXTENT_CLEAR_DELALLOC 0x4
|
||||||
|
#define EXTENT_CLEAR_DIRTY 0x8
|
||||||
|
#define EXTENT_SET_WRITEBACK 0x10
|
||||||
|
#define EXTENT_END_WRITEBACK 0x20
|
||||||
|
#define EXTENT_SET_PRIVATE2 0x40
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* page->private values. Every page that is controlled by the extent
|
* page->private values. Every page that is controlled by the extent
|
||||||
* map has page->private set to one.
|
* map has page->private set to one.
|
||||||
|
@ -288,10 +297,5 @@ int extent_range_uptodate(struct extent_io_tree *tree,
|
||||||
int extent_clear_unlock_delalloc(struct inode *inode,
|
int extent_clear_unlock_delalloc(struct inode *inode,
|
||||||
struct extent_io_tree *tree,
|
struct extent_io_tree *tree,
|
||||||
u64 start, u64 end, struct page *locked_page,
|
u64 start, u64 end, struct page *locked_page,
|
||||||
int unlock_page,
|
unsigned long op);
|
||||||
int clear_unlock,
|
|
||||||
int clear_delalloc, int clear_dirty,
|
|
||||||
int set_writeback,
|
|
||||||
int end_writeback,
|
|
||||||
int set_private2);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -424,9 +424,10 @@ again:
|
||||||
* and free up our temp pages.
|
* and free up our temp pages.
|
||||||
*/
|
*/
|
||||||
extent_clear_unlock_delalloc(inode,
|
extent_clear_unlock_delalloc(inode,
|
||||||
&BTRFS_I(inode)->io_tree,
|
&BTRFS_I(inode)->io_tree,
|
||||||
start, end, NULL, 1, 0,
|
start, end, NULL,
|
||||||
0, 1, 1, 1, 0);
|
EXTENT_CLEAR_UNLOCK_PAGE | EXTENT_CLEAR_DIRTY |
|
||||||
|
EXTENT_SET_WRITEBACK | EXTENT_END_WRITEBACK);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto free_pages_out;
|
goto free_pages_out;
|
||||||
}
|
}
|
||||||
|
@ -637,11 +638,13 @@ static noinline int submit_compressed_extents(struct inode *inode,
|
||||||
* clear dirty, set writeback and unlock the pages.
|
* clear dirty, set writeback and unlock the pages.
|
||||||
*/
|
*/
|
||||||
extent_clear_unlock_delalloc(inode,
|
extent_clear_unlock_delalloc(inode,
|
||||||
&BTRFS_I(inode)->io_tree,
|
&BTRFS_I(inode)->io_tree,
|
||||||
async_extent->start,
|
async_extent->start,
|
||||||
async_extent->start +
|
async_extent->start +
|
||||||
async_extent->ram_size - 1,
|
async_extent->ram_size - 1,
|
||||||
NULL, 1, 1, 0, 1, 1, 0, 0);
|
NULL, EXTENT_CLEAR_UNLOCK_PAGE |
|
||||||
|
EXTENT_CLEAR_UNLOCK |
|
||||||
|
EXTENT_CLEAR_DIRTY | EXTENT_SET_WRITEBACK);
|
||||||
|
|
||||||
ret = btrfs_submit_compressed_write(inode,
|
ret = btrfs_submit_compressed_write(inode,
|
||||||
async_extent->start,
|
async_extent->start,
|
||||||
|
@ -712,9 +715,14 @@ static noinline int cow_file_range(struct inode *inode,
|
||||||
start, end, 0, NULL);
|
start, end, 0, NULL);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
extent_clear_unlock_delalloc(inode,
|
extent_clear_unlock_delalloc(inode,
|
||||||
&BTRFS_I(inode)->io_tree,
|
&BTRFS_I(inode)->io_tree,
|
||||||
start, end, NULL, 1, 1,
|
start, end, NULL,
|
||||||
1, 1, 1, 1, 0);
|
EXTENT_CLEAR_UNLOCK_PAGE |
|
||||||
|
EXTENT_CLEAR_UNLOCK |
|
||||||
|
EXTENT_CLEAR_DELALLOC |
|
||||||
|
EXTENT_CLEAR_DIRTY |
|
||||||
|
EXTENT_SET_WRITEBACK |
|
||||||
|
EXTENT_END_WRITEBACK);
|
||||||
*nr_written = *nr_written +
|
*nr_written = *nr_written +
|
||||||
(end - start + PAGE_CACHE_SIZE) / PAGE_CACHE_SIZE;
|
(end - start + PAGE_CACHE_SIZE) / PAGE_CACHE_SIZE;
|
||||||
*page_started = 1;
|
*page_started = 1;
|
||||||
|
@ -738,6 +746,8 @@ static noinline int cow_file_range(struct inode *inode,
|
||||||
btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0);
|
btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0);
|
||||||
|
|
||||||
while (disk_num_bytes > 0) {
|
while (disk_num_bytes > 0) {
|
||||||
|
unsigned long op;
|
||||||
|
|
||||||
cur_alloc_size = min(disk_num_bytes, root->fs_info->max_extent);
|
cur_alloc_size = min(disk_num_bytes, root->fs_info->max_extent);
|
||||||
ret = btrfs_reserve_extent(trans, root, cur_alloc_size,
|
ret = btrfs_reserve_extent(trans, root, cur_alloc_size,
|
||||||
root->sectorsize, 0, alloc_hint,
|
root->sectorsize, 0, alloc_hint,
|
||||||
|
@ -789,10 +799,13 @@ static noinline int cow_file_range(struct inode *inode,
|
||||||
* Do set the Private2 bit so we know this page was properly
|
* Do set the Private2 bit so we know this page was properly
|
||||||
* setup for writepage
|
* setup for writepage
|
||||||
*/
|
*/
|
||||||
|
op = unlock ? EXTENT_CLEAR_UNLOCK_PAGE : 0;
|
||||||
|
op |= EXTENT_CLEAR_UNLOCK | EXTENT_CLEAR_DELALLOC |
|
||||||
|
EXTENT_SET_PRIVATE2;
|
||||||
|
|
||||||
extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree,
|
extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree,
|
||||||
start, start + ram_size - 1,
|
start, start + ram_size - 1,
|
||||||
locked_page, unlock, 1,
|
locked_page, op);
|
||||||
1, 0, 0, 0, 1);
|
|
||||||
disk_num_bytes -= cur_alloc_size;
|
disk_num_bytes -= cur_alloc_size;
|
||||||
num_bytes -= cur_alloc_size;
|
num_bytes -= cur_alloc_size;
|
||||||
alloc_hint = ins.objectid + ins.offset;
|
alloc_hint = ins.objectid + ins.offset;
|
||||||
|
@ -1112,8 +1125,10 @@ out_check:
|
||||||
BUG_ON(ret);
|
BUG_ON(ret);
|
||||||
|
|
||||||
extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree,
|
extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree,
|
||||||
cur_offset, cur_offset + num_bytes - 1,
|
cur_offset, cur_offset + num_bytes - 1,
|
||||||
locked_page, 1, 1, 1, 0, 0, 0, 1);
|
locked_page, EXTENT_CLEAR_UNLOCK_PAGE |
|
||||||
|
EXTENT_CLEAR_UNLOCK | EXTENT_CLEAR_DELALLOC |
|
||||||
|
EXTENT_SET_PRIVATE2);
|
||||||
cur_offset = extent_end;
|
cur_offset = extent_end;
|
||||||
if (cur_offset > end)
|
if (cur_offset > end)
|
||||||
break;
|
break;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче