Also if FlushNeeded - normally this isn't needed as clhead won't be
empty, but there is room for races to make that not so - this is
safer.
So only test the FlushNeeded flags and ChecpointEnd for cnum==0,
ignore for the cleaner clusters.
Signed-off-by: NeilBrown <neilb@suse.de>
dprintk("LAFS_cluster_flush %d\n", cnum);
mutex_lock(&wc->lock);
if (!list_empty(&wc->clhead)
- || (fs->checkpointing & CH_CheckpointEnd)
- || wc->chead_size > sizeof(struct cluster_head))
+ || wc->chead_size > sizeof(struct cluster_head)
+ || (cnum == 0 &&
+ ((fs->checkpointing & CH_CheckpointEnd)
+ || test_bit(FlushNeeded, &fs->fsstate)
+ || test_bit(SecondFlushNeeded, &fs->fsstate)
+ )))
cluster_flush(fs, cnum);
mutex_unlock(&wc->lock);
}