From de9755ee41324fd14f71b659bd6c179d9b5b6d4c Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Wed, 16 Mar 2022 12:43:33 +0100 Subject: [PATCH] Don't propagate bio flags to OCF for discard I/O 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 Signed-off-by: Robert Baldyga --- modules/cas_cache/volume/vol_block_dev_top.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/cas_cache/volume/vol_block_dev_top.c b/modules/cas_cache/volume/vol_block_dev_top.c index 37e16efa8..ebb3af176 100644 --- a/modules/cas_cache/volume/vol_block_dev_top.c +++ b/modules/cas_cache/volume/vol_block_dev_top.c @@ -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");