From: NeilBrown Date: Fri, 13 Aug 2010 11:56:49 +0000 (+1000) Subject: Tune checkpoint freq by segments, not blocks. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=83fe3bbdeda0ec48aea96bc216cb4cb041ca9660;p=LaFS.git Tune checkpoint freq by segments, not blocks. If nothing else does, we should force a checkpoint every few segments rather than every so-many blocks. Signed-off-by: NeilBrown --- diff --git a/checkpoint.c b/checkpoint.c index baf4e23..8eccf47 100644 --- a/checkpoint.c +++ b/checkpoint.c @@ -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); } diff --git a/cluster.c b/cluster.c index bf46087..0f3e2eb 100644 --- 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 0489fbe..ee37bec 100644 --- 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 7faf067..6c0c32d 100644 --- 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);