bdev/raid: fix flush on raid0
the calculation (offset_blocks + num_blocks - 1) didn't check if num_blocks is 0 which it is in case of flush. in flush case, offset_blocks was also 0, so we got (-1) and we got big unsigned number. just replace it with (offset_blocks + num_blocks - (num_blocks > 0)) to solve the issue. NOTE this is only fixing the wrong math, there might be more issues that outside the scope of this commit for example, if flush(x, y) called, no bdev implementation really use those values, and all bdevs just flush the whole disk also, a convention is that fluch(0, 0) should flush it all (but like I said before, all bdevs flush the whole disk anyway) Change-Id: I7e991653bc3050349dc155365b2c37ecc2d6b24c Signed-off-by: Amir Haroush <amir.haroush@huawei.com> Signed-off-by: Shai Fultheim <shai.fultheim@huawei.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13579 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
f352e9f477
commit
ef65d8467c
@ -147,12 +147,14 @@ _raid0_get_io_range(struct raid_bdev_io_range *io_range,
|
|||||||
{
|
{
|
||||||
uint64_t start_strip;
|
uint64_t start_strip;
|
||||||
uint64_t end_strip;
|
uint64_t end_strip;
|
||||||
|
uint64_t total_blocks;
|
||||||
|
|
||||||
io_range->strip_size = strip_size;
|
io_range->strip_size = strip_size;
|
||||||
|
total_blocks = offset_blocks + num_blocks - (num_blocks > 0);
|
||||||
|
|
||||||
/* The start and end strip index in raid0 bdev scope */
|
/* The start and end strip index in raid0 bdev scope */
|
||||||
start_strip = offset_blocks >> strip_size_shift;
|
start_strip = offset_blocks >> strip_size_shift;
|
||||||
end_strip = (offset_blocks + num_blocks - 1) >> strip_size_shift;
|
end_strip = total_blocks >> strip_size_shift;
|
||||||
io_range->start_strip_in_disk = start_strip / num_base_bdevs;
|
io_range->start_strip_in_disk = start_strip / num_base_bdevs;
|
||||||
io_range->end_strip_in_disk = end_strip / num_base_bdevs;
|
io_range->end_strip_in_disk = end_strip / num_base_bdevs;
|
||||||
|
|
||||||
@ -161,7 +163,7 @@ _raid0_get_io_range(struct raid_bdev_io_range *io_range,
|
|||||||
* Strips between them certainly have aligned offset and length to boundaries.
|
* Strips between them certainly have aligned offset and length to boundaries.
|
||||||
*/
|
*/
|
||||||
io_range->start_offset_in_strip = offset_blocks % strip_size;
|
io_range->start_offset_in_strip = offset_blocks % strip_size;
|
||||||
io_range->end_offset_in_strip = (offset_blocks + num_blocks - 1) % strip_size;
|
io_range->end_offset_in_strip = total_blocks % strip_size;
|
||||||
|
|
||||||
/* The base bdev indexes in which start and end strips are located */
|
/* The base bdev indexes in which start and end strips are located */
|
||||||
io_range->start_disk = start_strip % num_base_bdevs;
|
io_range->start_disk = start_strip % num_base_bdevs;
|
||||||
|
Loading…
Reference in New Issue
Block a user