btrfs: stop clearing EXTENT_DIRTY in inode I/O tree
Since commit fee187d9d9 ("Btrfs: do not set EXTENT_DIRTY along with
EXTENT_DELALLOC"), we never set EXTENT_DIRTY in inode->io_tree, so we
can simplify and stop trying to clear it.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
committed by
David Sterba
parent
f50cb7aff9
commit
e182163d9c
@@ -4322,10 +4322,8 @@ int extent_invalidatepage(struct extent_io_tree *tree,
|
|||||||
|
|
||||||
lock_extent_bits(tree, start, end, &cached_state);
|
lock_extent_bits(tree, start, end, &cached_state);
|
||||||
wait_on_page_writeback(page);
|
wait_on_page_writeback(page);
|
||||||
clear_extent_bit(tree, start, end,
|
clear_extent_bit(tree, start, end, EXTENT_LOCKED | EXTENT_DELALLOC |
|
||||||
EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC |
|
EXTENT_DO_ACCOUNTING, 1, 1, &cached_state);
|
||||||
EXTENT_DO_ACCOUNTING,
|
|
||||||
1, 1, &cached_state);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -537,8 +537,8 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
|
|||||||
* we can set things up properly
|
* we can set things up properly
|
||||||
*/
|
*/
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, end_of_last_block,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, end_of_last_block,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC |
|
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
|
||||||
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 0, 0, cached);
|
0, 0, cached);
|
||||||
|
|
||||||
if (!btrfs_is_free_space_inode(BTRFS_I(inode))) {
|
if (!btrfs_is_free_space_inode(BTRFS_I(inode))) {
|
||||||
if (start_pos >= isize &&
|
if (start_pos >= isize &&
|
||||||
|
|||||||
@@ -1006,7 +1006,7 @@ update_cache_item(struct btrfs_trans_handle *trans,
|
|||||||
ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
|
ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, NULL);
|
EXTENT_DELALLOC, 0, 0, NULL);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
leaf = path->nodes[0];
|
leaf = path->nodes[0];
|
||||||
@@ -1018,9 +1018,8 @@ update_cache_item(struct btrfs_trans_handle *trans,
|
|||||||
if (found_key.objectid != BTRFS_FREE_SPACE_OBJECTID ||
|
if (found_key.objectid != BTRFS_FREE_SPACE_OBJECTID ||
|
||||||
found_key.offset != offset) {
|
found_key.offset != offset) {
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0,
|
||||||
inode->i_size - 1,
|
inode->i_size - 1, EXTENT_DELALLOC, 0,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0,
|
0, NULL);
|
||||||
NULL);
|
|
||||||
btrfs_release_path(path);
|
btrfs_release_path(path);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -1116,7 +1115,7 @@ static int flush_dirty_cache(struct inode *inode)
|
|||||||
ret = btrfs_wait_ordered_range(inode, 0, (u64)-1);
|
ret = btrfs_wait_ordered_range(inode, 0, (u64)-1);
|
||||||
if (ret)
|
if (ret)
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, NULL);
|
EXTENT_DELALLOC, 0, 0, NULL);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4986,9 +4986,8 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, block_start, block_end,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, block_start, block_end,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC |
|
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
|
||||||
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
|
0, 0, &cached_state);
|
||||||
0, 0, &cached_state);
|
|
||||||
|
|
||||||
ret = btrfs_set_extent_delalloc(inode, block_start, block_end, 0,
|
ret = btrfs_set_extent_delalloc(inode, block_start, block_end, 0,
|
||||||
&cached_state);
|
&cached_state);
|
||||||
@@ -5372,9 +5371,9 @@ static void evict_inode_truncate_pages(struct inode *inode)
|
|||||||
btrfs_qgroup_free_data(inode, NULL, start, end - start + 1);
|
btrfs_qgroup_free_data(inode, NULL, start, end - start + 1);
|
||||||
|
|
||||||
clear_extent_bit(io_tree, start, end,
|
clear_extent_bit(io_tree, start, end,
|
||||||
EXTENT_LOCKED | EXTENT_DIRTY |
|
EXTENT_LOCKED | EXTENT_DELALLOC |
|
||||||
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING |
|
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 1, 1,
|
||||||
EXTENT_DEFRAG, 1, 1, &cached_state);
|
&cached_state);
|
||||||
|
|
||||||
cond_resched();
|
cond_resched();
|
||||||
spin_lock(&io_tree->lock);
|
spin_lock(&io_tree->lock);
|
||||||
@@ -7732,12 +7731,9 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
|
|||||||
u64 start = iblock << inode->i_blkbits;
|
u64 start = iblock << inode->i_blkbits;
|
||||||
u64 lockstart, lockend;
|
u64 lockstart, lockend;
|
||||||
u64 len = bh_result->b_size;
|
u64 len = bh_result->b_size;
|
||||||
int unlock_bits = EXTENT_LOCKED;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (create)
|
if (!create)
|
||||||
unlock_bits |= EXTENT_DIRTY;
|
|
||||||
else
|
|
||||||
len = min_t(u64, len, fs_info->sectorsize);
|
len = min_t(u64, len, fs_info->sectorsize);
|
||||||
|
|
||||||
lockstart = start;
|
lockstart = start;
|
||||||
@@ -7796,9 +7792,8 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto unlock_err;
|
goto unlock_err;
|
||||||
|
|
||||||
/* clear and unlock the entire range */
|
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart,
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend,
|
lockend, &cached_state);
|
||||||
unlock_bits, 1, 0, &cached_state);
|
|
||||||
} else {
|
} else {
|
||||||
ret = btrfs_get_blocks_direct_read(em, bh_result, inode,
|
ret = btrfs_get_blocks_direct_read(em, bh_result, inode,
|
||||||
start, len);
|
start, len);
|
||||||
@@ -7814,9 +7809,8 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
|
|||||||
*/
|
*/
|
||||||
lockstart = start + bh_result->b_size;
|
lockstart = start + bh_result->b_size;
|
||||||
if (lockstart < lockend) {
|
if (lockstart < lockend) {
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
|
unlock_extent_cached(&BTRFS_I(inode)->io_tree,
|
||||||
lockend, unlock_bits, 1, 0,
|
lockstart, lockend, &cached_state);
|
||||||
&cached_state);
|
|
||||||
} else {
|
} else {
|
||||||
free_extent_state(cached_state);
|
free_extent_state(cached_state);
|
||||||
}
|
}
|
||||||
@@ -7827,8 +7821,8 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unlock_err:
|
unlock_err:
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend,
|
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, lockend,
|
||||||
unlock_bits, 1, 0, &cached_state);
|
&cached_state);
|
||||||
err:
|
err:
|
||||||
if (dio_data)
|
if (dio_data)
|
||||||
current->journal_info = dio_data;
|
current->journal_info = dio_data;
|
||||||
@@ -8843,8 +8837,7 @@ again:
|
|||||||
*/
|
*/
|
||||||
if (!inode_evicting)
|
if (!inode_evicting)
|
||||||
clear_extent_bit(tree, start, end,
|
clear_extent_bit(tree, start, end,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC |
|
EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
|
||||||
EXTENT_DELALLOC_NEW |
|
|
||||||
EXTENT_LOCKED | EXTENT_DO_ACCOUNTING |
|
EXTENT_LOCKED | EXTENT_DO_ACCOUNTING |
|
||||||
EXTENT_DEFRAG, 1, 0, &cached_state);
|
EXTENT_DEFRAG, 1, 0, &cached_state);
|
||||||
/*
|
/*
|
||||||
@@ -8899,8 +8892,7 @@ again:
|
|||||||
if (PageDirty(page))
|
if (PageDirty(page))
|
||||||
btrfs_qgroup_free_data(inode, NULL, page_start, PAGE_SIZE);
|
btrfs_qgroup_free_data(inode, NULL, page_start, PAGE_SIZE);
|
||||||
if (!inode_evicting) {
|
if (!inode_evicting) {
|
||||||
clear_extent_bit(tree, page_start, page_end,
|
clear_extent_bit(tree, page_start, page_end, EXTENT_LOCKED |
|
||||||
EXTENT_LOCKED | EXTENT_DIRTY |
|
|
||||||
EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
|
EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
|
||||||
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 1, 1,
|
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 1, 1,
|
||||||
&cached_state);
|
&cached_state);
|
||||||
@@ -9028,9 +9020,8 @@ again:
|
|||||||
* reserve data&meta space before lock_page() (see above comments).
|
* reserve data&meta space before lock_page() (see above comments).
|
||||||
*/
|
*/
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, end,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, end,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC |
|
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING |
|
||||||
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
|
EXTENT_DEFRAG, 0, 0, &cached_state);
|
||||||
0, 0, &cached_state);
|
|
||||||
|
|
||||||
ret2 = btrfs_set_extent_delalloc(inode, page_start, end, 0,
|
ret2 = btrfs_set_extent_delalloc(inode, page_start, end, 0,
|
||||||
&cached_state);
|
&cached_state);
|
||||||
|
|||||||
@@ -1333,9 +1333,8 @@ again:
|
|||||||
lock_extent_bits(&BTRFS_I(inode)->io_tree,
|
lock_extent_bits(&BTRFS_I(inode)->io_tree,
|
||||||
page_start, page_end - 1, &cached_state);
|
page_start, page_end - 1, &cached_state);
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start,
|
||||||
page_end - 1, EXTENT_DIRTY | EXTENT_DELALLOC |
|
page_end - 1, EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING |
|
||||||
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 0, 0,
|
EXTENT_DEFRAG, 0, 0, &cached_state);
|
||||||
&cached_state);
|
|
||||||
|
|
||||||
if (i_done != page_cnt) {
|
if (i_done != page_cnt) {
|
||||||
spin_lock(&BTRFS_I(inode)->lock);
|
spin_lock(&BTRFS_I(inode)->lock);
|
||||||
|
|||||||
@@ -988,8 +988,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
|
|||||||
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
|
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
|
||||||
BTRFS_MAX_EXTENT_SIZE >> 1,
|
BTRFS_MAX_EXTENT_SIZE >> 1,
|
||||||
(BTRFS_MAX_EXTENT_SIZE >> 1) + sectorsize - 1,
|
(BTRFS_MAX_EXTENT_SIZE >> 1) + sectorsize - 1,
|
||||||
EXTENT_DELALLOC | EXTENT_DIRTY |
|
EXTENT_DELALLOC | EXTENT_UPTODATE, 0, 0, NULL);
|
||||||
EXTENT_UPTODATE, 0, 0, NULL);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
test_err("clear_extent_bit returned %d", ret);
|
test_err("clear_extent_bit returned %d", ret);
|
||||||
goto out;
|
goto out;
|
||||||
@@ -1056,8 +1055,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
|
|||||||
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
|
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
|
||||||
BTRFS_MAX_EXTENT_SIZE + sectorsize,
|
BTRFS_MAX_EXTENT_SIZE + sectorsize,
|
||||||
BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1,
|
BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC |
|
EXTENT_DELALLOC | EXTENT_UPTODATE, 0, 0, NULL);
|
||||||
EXTENT_UPTODATE, 0, 0, NULL);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
test_err("clear_extent_bit returned %d", ret);
|
test_err("clear_extent_bit returned %d", ret);
|
||||||
goto out;
|
goto out;
|
||||||
@@ -1089,8 +1087,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
|
|||||||
|
|
||||||
/* Empty */
|
/* Empty */
|
||||||
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
|
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC |
|
EXTENT_DELALLOC | EXTENT_UPTODATE, 0, 0, NULL);
|
||||||
EXTENT_UPTODATE, 0, 0, NULL);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
test_err("clear_extent_bit returned %d", ret);
|
test_err("clear_extent_bit returned %d", ret);
|
||||||
goto out;
|
goto out;
|
||||||
@@ -1105,8 +1102,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
|
|||||||
out:
|
out:
|
||||||
if (ret)
|
if (ret)
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
|
||||||
EXTENT_DIRTY | EXTENT_DELALLOC |
|
EXTENT_DELALLOC | EXTENT_UPTODATE, 0, 0, NULL);
|
||||||
EXTENT_UPTODATE, 0, 0, NULL);
|
|
||||||
iput(inode);
|
iput(inode);
|
||||||
btrfs_free_dummy_root(root);
|
btrfs_free_dummy_root(root);
|
||||||
btrfs_free_dummy_fs_info(fs_info);
|
btrfs_free_dummy_fs_info(fs_info);
|
||||||
|
|||||||
Reference in New Issue
Block a user