On Wed, Aug 15, 2018 at 10:39:56AM +0300, Nikolay Borisov wrote: > Refactor the delayed refs loop by using the newly introduced > btrfs_run_delayed_refs_for_head function. This greatly simplifies > __btrfs_run_delayed_refs and makes it more obvious what is happening. > We now have 1 loop which iterates the existing delayed_heads and then > each selected ref head is processed by the new helper. All existing > semantics of the code are preserved so no functional changes. What a mess, took me some time to understand and find the hidden loop, this is a perfect counter example. Thanks for fixing it up. Reviewed-by: David Sterba <dsterba@xxxxxxxx> > - rb_erase(&ref->ref_node, &locked_ref->ref_tree); There was a merge conflict with the rb_root_cached tree update, but the fixup was trivial. > + } while ((nr != -1 && count < nr) || locked_ref); I can't be the first to notice that the '-1' is signed long compared to an unsigned long. This part is not obvious as this means to process all delayed refs, called from the contexts like commit. Replacing that with something more explicit would be good.
