Do all block index writes in a batch

Follow-up to #5241 that increases flushing speed and improves atomicity of disk updates further.