Added flush_disk to factor out common buffer cache flushing code.