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 <michal.mielewczyk@intel.com>
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2022-03-16 12:43:33 +01:00
parent f9a2846224
commit e4d4750f96

View File

@ -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, io = ocf_volume_new_io(bvol->front_volume, queue,
CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT, CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT,
CAS_BIO_BISIZE(bio), OCF_WRITE, 0, CAS_BIO_BISIZE(bio), OCF_WRITE, 0, 0);
CAS_CLEAR_FLUSH(CAS_BIO_OP_FLAGS(bio)));
if (!io) { if (!io) {
CAS_PRINT_RL(KERN_CRIT CAS_PRINT_RL(KERN_CRIT
"Out of memory. Ending IO processing.\n"); "Out of memory. Ending IO processing.\n");