md: move code in to submit_flushes.