[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 5/6] block/io: refactor bdrv_co_do_pwrite_zeroes head calculat
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v2 5/6] block/io: refactor bdrv_co_do_pwrite_zeroes head calculation |
Date: |
Wed, 1 Apr 2020 18:01:11 +0300 |
It's wrong to update head using num in this place, as num may be
reduced during the iteration (seems it doesn't, but it's not obvious),
and we'll have wrong head value on next iteration.
Instead update head at iteration end.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/io.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/io.c b/block/io.c
index 07270524a9..f8335e7212 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1790,7 +1790,6 @@ static int coroutine_fn
bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
* convenience, limit this request to max_transfer even if
* we don't need to fall back to writes. */
num = MIN(MIN(bytes, max_transfer), alignment - head);
- head = (head + num) % alignment;
assert(num < max_write_zeroes);
} else if (tail && num > alignment) {
/* Shorten the request to the last aligned sector. */
@@ -1849,6 +1848,9 @@ static int coroutine_fn
bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
offset += num;
bytes -= num;
+ if (head) {
+ head = offset % alignment;
+ }
}
fail:
--
2.21.0
- [PATCH v2 0/6] nbd: reduce max_block restrictions, Vladimir Sementsov-Ogievskiy, 2020/04/01
- [PATCH v2 1/6] block/nbd-client: drop max_block restriction from block_status, Vladimir Sementsov-Ogievskiy, 2020/04/01
- [PATCH v2 2/6] block/nbd-client: drop max_block restriction from discard, Vladimir Sementsov-Ogievskiy, 2020/04/01
- [PATCH v2 4/6] block/nbd: define new max_write_zero_fast limit, Vladimir Sementsov-Ogievskiy, 2020/04/01
- [PATCH v2 5/6] block/io: refactor bdrv_co_do_pwrite_zeroes head calculation,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v2 6/6] block/io: auto-no-fallback for write-zeroes, Vladimir Sementsov-Ogievskiy, 2020/04/01
- [PATCH v2 3/6] block: add max_pwrite_zeroes_fast to BlockLimits, Vladimir Sementsov-Ogievskiy, 2020/04/01
- Re: [PATCH v2 0/6] nbd: reduce max_block restrictions, no-reply, 2020/04/01