From: NeilBrown Date: Sat, 3 Jul 2010 01:00:20 +0000 (+1000) Subject: Avoid overallocation to the cleaner X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=a25e8ccb52445d319d4dcdc65086f4f5e8256de8;p=LaFS.git Avoid overallocation to the cleaner Don't give space to the cleaner at the expense of space for writing new blocks. That would be greedy. Signed-off-by: NeilBrown --- diff --git a/segments.c b/segments.c index 5570360..2733b1a 100644 --- a/segments.c +++ b/segments.c @@ -574,12 +574,16 @@ int lafs_alloc_cleaner_segs(struct fs *fs, int max) /* 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++;