message: fscache: fix a bug introduced by commit
  Fix a bug introduced by commit which will cause data corruption
  under race conditions.
  Fixes:
diff: @@ -704,12 +704,10 @@ impl FileCacheEntry {
  start = std::cmp::min(*chunk_id - chunk_index, start);
  end = std::cmp::max(*chunk_id - chunk_index, end);
  }
  - if end < start {
  - return Ok(());
  - }
  (start as usize, end as usize)
  };
  + if start_idx <= end_idx {
  let start_chunk = &chunks[start_idx];
  let end_chunk = &chunks[end_idx];
  let (blob_offset, blob_end, blob_size) =
  @@ -731,8 +729,11 @@ impl FileCacheEntry {
  ) {
  Ok(mut bufs) => {
  if self.is_raw_data {
  - let res =
  - Self::persist_cached_data(&self.file, blob_offset, bufs.compressed_buf());
  + let res = Self::persist_cached_data(
  + &self.file,
  + blob_offset,
  + bufs.compressed_buf(),
  + );
  for idx in start_idx..=end_idx {
  if status[idx] {
  self.update_chunk_pending_status(chunks[idx].as_ref(), res.is_ok());
  @@ -771,6 +772,7 @@ impl FileCacheEntry {
  return Err(e);
  }
  }
  + }
  if !bitmap.wait_for_range_ready(chunk_index, count)? {
  if prefetch {
  @@ -1106,10 +1108,12 @@ impl FileCacheEntry {
  let mut d = DataBuffer::Allocated(alloc_buf(d_size));
  // Try to read and validate data from cache if:
  - // - the chunk is marked as ready
  - // - it's not in direct map mode and blob is not a legacy stargz. Legacy stargz has
  - // incorrect chunk hash value, so can't be used to validate data from cache.
  - let buffer = if self.read_file_cache(chunk.as_ref(), d.mut_slice()).is_ok() {
  + // - it's an stargz image and the chunk is ready.
  + // - chunk data validation is enabled.
  + // - digested or dummy chunk map is used.
  + let is_ready = self.chunk_map.is_ready(chunk.as_ref())?;
  + let try_cache = is_ready || !self.is_direct_chunkmap;
  + let buffer = if try_cache && self.read_file_cache(chunk.as_ref(), d.mut_slice()).is_ok() {
  self.metrics.whole_hits.inc();
  self.chunk_map.set_ready_and_clear_pending(chunk.as_ref())?;
  trace!(
  