Merge pull request #811 from mmichal10/fix-discard

Fix max discard size
This commit is contained in:
Robert Baldyga 2021-05-10 15:36:37 +02:00 committed by GitHub
commit a226b39c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -550,24 +550,6 @@ void _blockdev_set_exported_object_flush_fua(ocf_core_t core)
#endif #endif
} }
static int _blockdev_calc_discard_alignment(ocf_cache_t cache,
struct block_device *core_bd)
{
unsigned int granularity, offset;
sector_t start;
if (core_bd == core_bd->bd_contains)
return 0;
start = core_bd->bd_part->start_sect;
granularity = ocf_cache_get_line_size(cache) >> SECTOR_SHIFT;
offset = sector_div(start, granularity);
offset = (granularity - offset) % granularity;
return offset << SECTOR_SHIFT;
}
static void _blockdev_set_discard_properties(ocf_cache_t cache, static void _blockdev_set_discard_properties(ocf_cache_t cache,
struct request_queue *exp_q, struct block_device *cache_bd, struct request_queue *exp_q, struct block_device *cache_bd,
struct block_device *core_bd, sector_t core_sectors) struct block_device *core_bd, sector_t core_sectors)
@ -588,11 +570,10 @@ static void _blockdev_set_discard_properties(ocf_cache_t cache,
exp_q->limits.discard_granularity = exp_q->limits.discard_granularity =
core_q->limits.discard_granularity; core_q->limits.discard_granularity;
} else { } else {
blk_queue_max_discard_sectors(exp_q, core_sectors); blk_queue_max_discard_sectors(exp_q,
exp_q->limits.discard_granularity = min((uint64_t)core_sectors, (uint64_t)UINT_MAX));
ocf_cache_get_line_size(cache); exp_q->limits.discard_granularity = queue_logical_block_size(exp_q);
exp_q->limits.discard_alignment = exp_q->limits.discard_alignment = 0;
_blockdev_calc_discard_alignment(cache, core_bd);
} }
} }