]> git.neil.brown.name Git - LaFS.git/commitdiff
Tune checkpoint freq by segments, not blocks.
authorNeilBrown <neilb@suse.de>
Fri, 13 Aug 2010 11:56:49 +0000 (21:56 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 13 Aug 2010 12:13:40 +0000 (22:13 +1000)
If nothing else does, we should force a checkpoint
every few segments rather than every so-many blocks.

Signed-off-by: NeilBrown <neilb@suse.de>
checkpoint.c
cluster.c
state.h
super.c

index baf4e23919c09bfd065be6f3626bb198a2355a1c..8eccf47df233370976df341b7814dff673cac50b 100644 (file)
@@ -508,7 +508,7 @@ static void finish_checkpoint(struct fs *fs, int youth)
        fs->cleaner.cleaning = 0;
 
        fs->checkpoint_youth = youth;
-       fs->newblocks = 0;
+       fs->newsegments = 0;
        lafs_wake_thread(fs);
 }
 
@@ -519,7 +519,7 @@ unsigned long lafs_do_checkpoint(struct fs *fs)
            !test_bit(FinalCheckpoint, &fs->fsstate)) {
                /* not compulsory, but maybe just time */
                if (fs->cleaner.active == 0 &&
-                   fs->newblocks > fs->max_newblocks)
+                   fs->newsegments > fs->max_newsegs)
                        set_bit(CheckpointNeeded, &fs->fsstate);
        }
 
index bf46087d221d792adce4116b21364bfb65286de7..0f3e2eb2221bebe551fa3bf9c17cf51a01868b45 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -445,6 +445,10 @@ static int new_segment(struct fs *fs, int cnum)
        BUG_ON(wc->seg.dev != dev);
        BUG_ON(wc->seg.num != seg);
 
+       if (cnum == 0)
+               /* wc mutex protects us here */
+               fs->newsegments++;
+
        return 0;
 }
 
@@ -1192,8 +1196,6 @@ static void cluster_flush(struct fs *fs, int cnum)
                        lafs_allocated_block(fs, b, addr);
                blocks++;
        }
-       if (cnum == 0)
-               fs->newblocks += blocks;
 
        if (head_start)
                cluster_closehead(wc, head_start);
diff --git a/state.h b/state.h
index 0489fbea1ff65da89682429c6457d41ddedf18fe..ee37bec839c54975f13095ee347a0195ca2199b3 100644 (file)
--- a/state.h
+++ b/state.h
@@ -141,11 +141,8 @@ struct fs {
        } cleaner;
        struct task_struct *thread;
 
-       unsigned long newblocks;        /* number of blocks written since checkpoint
-                                        * FIXME this should probably be a count
-                                        * of segments (?)
-                                        */
-       unsigned long max_newblocks;    /* max blocks in a checkpoint (roughly) */
+       unsigned long newsegments;      /* number of segments written since checkpoint */
+       unsigned long max_newsegs;      /* max segments in a checkpoint (roughly) */
 
        /* counters for (pre)allocating space. */
        spinlock_t alloc_lock;
diff --git a/super.c b/super.c
index 7faf0675849b0c42f5a8ab3f76736795ab39a8fb..6c0c32dabd37aaa5c250c6d724ef16a561a53641 100644 (file)
--- a/super.c
+++ b/super.c
@@ -574,9 +574,7 @@ lafs_load(struct fs *fs, struct options *op, int newest)
                fs->wc[i].seg.dev = -1;
        }
 
-       fs->max_newblocks = 1000; /* FIXME this should be configurable, and
-                                  * guessed better
-                                  */
+       fs->max_newsegs = 32; /* FIXME this should be configurable */
 
        err = -ENOMEM;
        fs->devs = kzalloc(sizeof(struct fs_dev)*fs->devices, GFP_KERNEL);