Skip to content

Commit e182163

Browse files
osandovkdave
authored andcommitted
btrfs: stop clearing EXTENT_DIRTY in inode I/O tree
Since commit fee187d ("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 <[email protected]> Signed-off-by: Omar Sandoval <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent f50cb7a commit e182163

File tree

6 files changed

+30
-47
lines changed

6 files changed

+30
-47
lines changed

fs/btrfs/extent_io.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4322,10 +4322,8 @@ int extent_invalidatepage(struct extent_io_tree *tree,
43224322

43234323
lock_extent_bits(tree, start, end, &cached_state);
43244324
wait_on_page_writeback(page);
4325-
clear_extent_bit(tree, start, end,
4326-
EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC |
4327-
EXTENT_DO_ACCOUNTING,
4328-
1, 1, &cached_state);
4325+
clear_extent_bit(tree, start, end, EXTENT_LOCKED | EXTENT_DELALLOC |
4326+
EXTENT_DO_ACCOUNTING, 1, 1, &cached_state);
43294327
return 0;
43304328
}
43314329

fs/btrfs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
537537
* we can set things up properly
538538
*/
539539
clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, end_of_last_block,
540-
EXTENT_DIRTY | EXTENT_DELALLOC |
541-
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 0, 0, cached);
540+
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
541+
0, 0, cached);
542542

543543
if (!btrfs_is_free_space_inode(BTRFS_I(inode))) {
544544
if (start_pos >= isize &&

fs/btrfs/free-space-cache.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ update_cache_item(struct btrfs_trans_handle *trans,
10061006
ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
10071007
if (ret < 0) {
10081008
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
1009-
EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, NULL);
1009+
EXTENT_DELALLOC, 0, 0, NULL);
10101010
goto fail;
10111011
}
10121012
leaf = path->nodes[0];
@@ -1018,9 +1018,8 @@ update_cache_item(struct btrfs_trans_handle *trans,
10181018
if (found_key.objectid != BTRFS_FREE_SPACE_OBJECTID ||
10191019
found_key.offset != offset) {
10201020
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0,
1021-
inode->i_size - 1,
1022-
EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0,
1023-
NULL);
1021+
inode->i_size - 1, EXTENT_DELALLOC, 0,
1022+
0, NULL);
10241023
btrfs_release_path(path);
10251024
goto fail;
10261025
}
@@ -1116,7 +1115,7 @@ static int flush_dirty_cache(struct inode *inode)
11161115
ret = btrfs_wait_ordered_range(inode, 0, (u64)-1);
11171116
if (ret)
11181117
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
1119-
EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, NULL);
1118+
EXTENT_DELALLOC, 0, 0, NULL);
11201119

11211120
return ret;
11221121
}

fs/btrfs/inode.c

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4986,9 +4986,8 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
49864986
}
49874987

49884988
clear_extent_bit(&BTRFS_I(inode)->io_tree, block_start, block_end,
4989-
EXTENT_DIRTY | EXTENT_DELALLOC |
4990-
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
4991-
0, 0, &cached_state);
4989+
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
4990+
0, 0, &cached_state);
49924991

49934992
ret = btrfs_set_extent_delalloc(inode, block_start, block_end, 0,
49944993
&cached_state);
@@ -5372,9 +5371,9 @@ static void evict_inode_truncate_pages(struct inode *inode)
53725371
btrfs_qgroup_free_data(inode, NULL, start, end - start + 1);
53735372

53745373
clear_extent_bit(io_tree, start, end,
5375-
EXTENT_LOCKED | EXTENT_DIRTY |
5376-
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING |
5377-
EXTENT_DEFRAG, 1, 1, &cached_state);
5374+
EXTENT_LOCKED | EXTENT_DELALLOC |
5375+
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 1, 1,
5376+
&cached_state);
53785377

53795378
cond_resched();
53805379
spin_lock(&io_tree->lock);
@@ -7732,12 +7731,9 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
77327731
u64 start = iblock << inode->i_blkbits;
77337732
u64 lockstart, lockend;
77347733
u64 len = bh_result->b_size;
7735-
int unlock_bits = EXTENT_LOCKED;
77367734
int ret = 0;
77377735

7738-
if (create)
7739-
unlock_bits |= EXTENT_DIRTY;
7740-
else
7736+
if (!create)
77417737
len = min_t(u64, len, fs_info->sectorsize);
77427738

77437739
lockstart = start;
@@ -7796,9 +7792,8 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
77967792
if (ret < 0)
77977793
goto unlock_err;
77987794

7799-
/* clear and unlock the entire range */
7800-
clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend,
7801-
unlock_bits, 1, 0, &cached_state);
7795+
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart,
7796+
lockend, &cached_state);
78027797
} else {
78037798
ret = btrfs_get_blocks_direct_read(em, bh_result, inode,
78047799
start, len);
@@ -7814,9 +7809,8 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
78147809
*/
78157810
lockstart = start + bh_result->b_size;
78167811
if (lockstart < lockend) {
7817-
clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
7818-
lockend, unlock_bits, 1, 0,
7819-
&cached_state);
7812+
unlock_extent_cached(&BTRFS_I(inode)->io_tree,
7813+
lockstart, lockend, &cached_state);
78207814
} else {
78217815
free_extent_state(cached_state);
78227816
}
@@ -7827,8 +7821,8 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
78277821
return 0;
78287822

78297823
unlock_err:
7830-
clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend,
7831-
unlock_bits, 1, 0, &cached_state);
7824+
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, lockend,
7825+
&cached_state);
78327826
err:
78337827
if (dio_data)
78347828
current->journal_info = dio_data;
@@ -8843,8 +8837,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,
88438837
*/
88448838
if (!inode_evicting)
88458839
clear_extent_bit(tree, start, end,
8846-
EXTENT_DIRTY | EXTENT_DELALLOC |
8847-
EXTENT_DELALLOC_NEW |
8840+
EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
88488841
EXTENT_LOCKED | EXTENT_DO_ACCOUNTING |
88498842
EXTENT_DEFRAG, 1, 0, &cached_state);
88508843
/*
@@ -8899,8 +8892,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,
88998892
if (PageDirty(page))
89008893
btrfs_qgroup_free_data(inode, NULL, page_start, PAGE_SIZE);
89018894
if (!inode_evicting) {
8902-
clear_extent_bit(tree, page_start, page_end,
8903-
EXTENT_LOCKED | EXTENT_DIRTY |
8895+
clear_extent_bit(tree, page_start, page_end, EXTENT_LOCKED |
89048896
EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
89058897
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 1, 1,
89068898
&cached_state);
@@ -9028,9 +9020,8 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf)
90289020
* reserve data&meta space before lock_page() (see above comments).
90299021
*/
90309022
clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, end,
9031-
EXTENT_DIRTY | EXTENT_DELALLOC |
9032-
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
9033-
0, 0, &cached_state);
9023+
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING |
9024+
EXTENT_DEFRAG, 0, 0, &cached_state);
90349025

90359026
ret2 = btrfs_set_extent_delalloc(inode, page_start, end, 0,
90369027
&cached_state);

fs/btrfs/ioctl.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,9 +1333,8 @@ static int cluster_pages_for_defrag(struct inode *inode,
13331333
lock_extent_bits(&BTRFS_I(inode)->io_tree,
13341334
page_start, page_end - 1, &cached_state);
13351335
clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start,
1336-
page_end - 1, EXTENT_DIRTY | EXTENT_DELALLOC |
1337-
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 0, 0,
1338-
&cached_state);
1336+
page_end - 1, EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING |
1337+
EXTENT_DEFRAG, 0, 0, &cached_state);
13391338

13401339
if (i_done != page_cnt) {
13411340
spin_lock(&BTRFS_I(inode)->lock);

fs/btrfs/tests/inode-tests.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
988988
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
989989
BTRFS_MAX_EXTENT_SIZE >> 1,
990990
(BTRFS_MAX_EXTENT_SIZE >> 1) + sectorsize - 1,
991-
EXTENT_DELALLOC | EXTENT_DIRTY |
992-
EXTENT_UPTODATE, 0, 0, NULL);
991+
EXTENT_DELALLOC | EXTENT_UPTODATE, 0, 0, NULL);
993992
if (ret) {
994993
test_err("clear_extent_bit returned %d", ret);
995994
goto out;
@@ -1056,8 +1055,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
10561055
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
10571056
BTRFS_MAX_EXTENT_SIZE + sectorsize,
10581057
BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1,
1059-
EXTENT_DIRTY | EXTENT_DELALLOC |
1060-
EXTENT_UPTODATE, 0, 0, NULL);
1058+
EXTENT_DELALLOC | EXTENT_UPTODATE, 0, 0, NULL);
10611059
if (ret) {
10621060
test_err("clear_extent_bit returned %d", ret);
10631061
goto out;
@@ -1089,8 +1087,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
10891087

10901088
/* Empty */
10911089
ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
1092-
EXTENT_DIRTY | EXTENT_DELALLOC |
1093-
EXTENT_UPTODATE, 0, 0, NULL);
1090+
EXTENT_DELALLOC | EXTENT_UPTODATE, 0, 0, NULL);
10941091
if (ret) {
10951092
test_err("clear_extent_bit returned %d", ret);
10961093
goto out;
@@ -1105,8 +1102,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
11051102
out:
11061103
if (ret)
11071104
clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
1108-
EXTENT_DIRTY | EXTENT_DELALLOC |
1109-
EXTENT_UPTODATE, 0, 0, NULL);
1105+
EXTENT_DELALLOC | EXTENT_UPTODATE, 0, 0, NULL);
11101106
iput(inode);
11111107
btrfs_free_dummy_root(root);
11121108
btrfs_free_dummy_fs_info(fs_info);

0 commit comments

Comments
 (0)