Skip to content

Commit

Permalink
Don't propagate bio flags to OCF for discard I/O
Browse files Browse the repository at this point in the history
One of the steps of discarding data in cache is invalidating OCF metadata.
If a cache line which is supposed to be discarded is dirty, invalidating
it will require flushing metadata. Unfortunately, OCF allocates flushing
requests with the exactly the same flags as the original IO (in this case
discard flag is set) so the page on the disk is discarded instead of being
flushed. In case of power failure occurring before the metadata is flushed
to the disk, the data may be corrupted even if recovery will succeed.

Disabling propagation of original I/O flags for discard requests solves
this problem.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
  • Loading branch information
Robert Baldyga committed Mar 16, 2022
1 parent 8577a25 commit de9755e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions modules/cas_cache/volume/vol_block_dev_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ static void _blockdev_handle_discard(ocf_core_t core, struct bio *bio)

io = ocf_core_new_io(core, cache_priv->io_queues[smp_processor_id()],
CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT,
CAS_BIO_BISIZE(bio), OCF_WRITE, 0,
CAS_CLEAR_FLUSH(CAS_BIO_OP_FLAGS(bio)));

CAS_BIO_BISIZE(bio), OCF_WRITE, 0, 0);
if (!io) {
CAS_PRINT_RL(KERN_CRIT
"Out of memory. Ending IO processing.\n");
Expand Down

0 comments on commit de9755e

Please sign in to comment.