From a25e8ccb52445d319d4dcdc65086f4f5e8256de8 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 3 Jul 2010 11:00:20 +1000 Subject: [PATCH] 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 --- segments.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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++; -- 2.39.5