+ case FLUSH_DELAYED_ITEMS_NR:
+ case FLUSH_DELAYED_ITEMS:
+ nr = (*state == FLUSH_DELAYED_ITEMS_NR) ? 10 : -1;
This 10 seemed awfully magical so I read a bit more.
It appears to be an attempt to pop back up into reserve_metadata_bytes()
to see if the caller has been satisfied before continuing on to apply
all the delayed items.
The magic number seems awfully clumsy. It'll either do too much work or
will blow through all the delayed items, depending on the load. Is it
too hard to have btrfs_run_delayed_items() check for the callers
reservation and return if there's a chance that it'll be satisfied?
Am I missing something? Over-thinking a rare path as the initial steps
will tend to free up space most of the time?
- z