ctl_ms_flush_sector_cache writes all dirty sectors to the storage media. The cache entries remain valid so they are immediately ready for a subsequent read request.
If you wish to invalidate the whole cache so that it is empty, use ctl_ms_purge_sector_cache.
All sectors are written to the media. If there is an error writing to the media for any sector, ctl_ms_flush_sector_cache returns CTL_MS_DELAYED_WRITE_ERROR.