Message ID | 20211122151713.14316-1-nborisov@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: eliminate if in main loop in tree_search_offset | expand |
On Mon, Nov 22, 2021 at 05:17:13PM +0200, Nikolay Borisov wrote: > Reshuffle the code inside the first loop of tree_search_offset so that > one if() is eliminated and the becomes more linear. Need a SOB and you need to set entry = NULL initially if you're going to make this change. Thanks, Josef
On 22.11.21 г. 18:50, Josef Bacik wrote: > On Mon, Nov 22, 2021 at 05:17:13PM +0200, Nikolay Borisov wrote: >> Reshuffle the code inside the first loop of tree_search_offset so that >> one if() is eliminated and the becomes more linear. > > Need a SOB and you need to set entry = NULL initially if you're going to make > this change. Thanks, Doh, I had it set before nuking the work via git checkout and on the 2nd try I forgot.... > > Josef >
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 145a07b19359..141fae2692a4 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1595,12 +1595,7 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl, struct btrfs_free_space *entry, *prev = NULL; /* find entry that is closest to the 'offset' */ - while (1) { - if (!n) { - entry = NULL; - break; - } - + while (n) { entry = rb_entry(n, struct btrfs_free_space, offset_index); prev = entry; @@ -1610,6 +1605,8 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl, n = n->rb_right; else break; + + entry = NULL; } if (bitmap_only) {