From: NeilBrown Date: Fri, 25 Jun 2010 06:34:50 +0000 (+1000) Subject: Make cluster_flush conditional on there being something to write. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=d7fb35f4fe4112aedac2287741ca07e40c86b712;p=LaFS.git Make cluster_flush conditional on there being something to write. Avoid inadvertent empty clusters by only writing a cluster if there is clearly something to write. Signed-off-by: NeilBrown --- diff --git a/cluster.c b/cluster.c index ea45fca..377d536 100644 --- a/cluster.c +++ b/cluster.c @@ -1317,7 +1317,10 @@ void lafs_cluster_flush(struct fs *fs, int cnum) { struct wc *wc = &fs->wc[cnum]; mutex_lock(&wc->lock); - cluster_flush(fs, cnum); + if (!list_empty(&wc->clhead) + || (fs->checkpointing & CH_CheckpointEnd) + || wc->chead_size > sizeof(struct cluster_head)) + cluster_flush(fs, cnum); mutex_unlock(&wc->lock); } diff --git a/file.c b/file.c index 2c8c58b..2c178be 100644 --- a/file.c +++ b/file.c @@ -314,8 +314,7 @@ static void lafs_sync_page(struct page *page) putdref(b); } #else - if (!lafs_cluster_empty(fs, 0)) - lafs_cluster_flush(fs, 0); + lafs_cluster_flush(fs, 0); #endif }