]> git.neil.brown.name Git - LaFS.git/commitdiff
Avoid overallocation to the cleaner
authorNeilBrown <neilb@suse.de>
Sat, 3 Jul 2010 01:00:20 +0000 (11:00 +1000)
committerNeilBrown <neilb@suse.de>
Sat, 3 Jul 2010 01:00:20 +0000 (11:00 +1000)
Don't give space to the cleaner at the expense of space for
writing new blocks.  That would be greedy.

Signed-off-by: NeilBrown <neilb@suse.de>
segments.c

index 55703606557c54aedaeb83f0730f579838c92fbf..2733b1a3be3e643590cee8b3ba7f9db8b7627c3b 100644 (file)
@@ -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++;