]> git.neil.brown.name Git - LaFS.git/commitdiff
Make cluster_flush conditional on there being something to write.
authorNeilBrown <neilb@suse.de>
Fri, 25 Jun 2010 06:34:50 +0000 (16:34 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 25 Jun 2010 06:34:50 +0000 (16:34 +1000)
Avoid inadvertent empty clusters by only writing a cluster if
there is clearly something to write.

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

index ea45fca34cb0707411f2ed19c0d20e97327da1f0..377d53698efe58b2e375d3a10740f3f8a352c9a9 100644 (file)
--- 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 2c8c58b031fd14006c3e46c971157b55e159c2ef..2c178be3e5ac593d89fb86fa321b72015eaaac69 100644 (file)
--- 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
 }