Skip to content

Commit da07d4a

Browse files
lorddoskiaskdave
authored andcommitted
btrfs: Streamline btrfs_delalloc_reserve_metadata initial operations
The behavior of btrfs_delalloc_reserve_metadata depends on whether the inode we are allocating for is the freespace inode or not. As it stands if we are the free node we set 'flush' and 'delalloc_lock' variable to certain values. Subsequently we check the values of those vars and act accordingly. Instead, simplify things by having 1 if which checks whether we are the freespace inode or not and do any specific operation in either branches of that if. This makes the code a bit easier to understand, as an added bonus it also shrinks the compiled size: add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-17 (-17) Function old new delta btrfs_delalloc_reserve_metadata 1876 1859 -17 Total: Before=85966, After=85949, chg -0.02% No functional changes. Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: Edmund Nadolski <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b1b8e38 commit da07d4a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/btrfs/extent-tree.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6061,13 +6061,13 @@ int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes)
60616061
if (btrfs_is_free_space_inode(inode)) {
60626062
flush = BTRFS_RESERVE_NO_FLUSH;
60636063
delalloc_lock = false;
6064-
} else if (current->journal_info) {
6065-
flush = BTRFS_RESERVE_FLUSH_LIMIT;
6066-
}
6064+
} else {
6065+
if (current->journal_info)
6066+
flush = BTRFS_RESERVE_FLUSH_LIMIT;
60676067

6068-
if (flush != BTRFS_RESERVE_NO_FLUSH &&
6069-
btrfs_transaction_in_commit(fs_info))
6070-
schedule_timeout(1);
6068+
if (btrfs_transaction_in_commit(fs_info))
6069+
schedule_timeout(1);
6070+
}
60716071

60726072
if (delalloc_lock)
60736073
mutex_lock(&inode->delalloc_mutex);

0 commit comments

Comments
 (0)