From e4d4750f965c94a4e5c4926a480e071b859fce17 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 e4ed365..9bddd22 100644 --- a/modules/cas_cache/volume/vol_block_dev_top.c +++ b/modules/cas_cache/volume/vol_block_dev_top.c @@ -356,9 +356,7 @@ static void blkdev_handle_discard(struct bd_object *bvol, struct bio *bio) io = ocf_volume_new_io(bvol->front_volume, queue, 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");