/* cleaner is about to start.
* See how many segments of space can safely
* be reserved for its use.
+ * We don't allocate more to the cleaner than we
+ * leave spare for new allocations.
*/
int watermark = fs->max_segment * 4;
int rv = 0;
spin_lock(&fs->alloc_lock);
while (fs->clean_reserved < max * fs->max_segment &&
- fs->free_blocks > fs->allocated_blocks + watermark) {
+ fs->free_blocks > (fs->clean_reserved
+ + fs->allocated_blocks
+ + watermark)) {
fs->clean_reserved += fs->max_segment;
fs->free_blocks -= fs->max_segment;
rv++;