Skip to contentSkip to conversation

block: fix alignment calculations in bdrv_co_do_zero_pwritev

PATCH Applied Denis V. Lunev 3 participants 3 messages Apr 26, 2017 – Apr 27, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix alignment calculations in bdrv_co_do_zero_pwritev

tail_padding_bytes is calculated wrong. F.e. for

    offset = 0
    bytes = 2048
    align = 512

we will have tail_padding_bytes = 512 which is definitely wrong. The patch fixes that arithmetics.

Fortunately this problem is harmless, we will have 1 extra allocation and free thus there is no need to put this into stable. The problem is here from the very beginning.

CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>
---
 block/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/io.c +1 -1
index a7142e0..1e1523b 100644
@@ -1452,7 +1452,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child,
     int ret = 0;
 
     head_padding_bytes = offset & (align - 1);
-    tail_padding_bytes = align - ((offset + bytes) & (align - 1));
+    tail_padding_bytes = (align - (offset + bytes)) & (align - 1);
 
 
     assert(flags & BDRV_REQ_ZERO_WRITE);
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Denis V. Lunev

tail_padding_bytes is calculated wrong. F.e. for

    offset = 0
    bytes = 2048
    align = 512

we will have tail_padding_bytes = 512 which is definitely wrong. The patch fixes that arithmetics.

Fortunately this problem is harmless, we will have 1 extra allocation and free thus there is no need to put this into stable. The problem is here from the very beginning.

Quoted 6 lines
CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>
---
 block/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Applied
#2 lore raw
In reply to Denis V. Lunev

Am 26.04.2017 um 10:40 hat Denis V. Lunev geschrieben:

Quoted 7 lines

tail_padding_bytes is calculated wrong. F.e. for

    offset = 0
    bytes = 2048
    align = 512

we will have tail_padding_bytes = 512 which is definitely wrong. The patch fixes that arithmetics.

Quoted 7 lines

Fortunately this problem is harmless, we will have 1 extra allocation and free thus there is no need to put this into stable. The problem is here from the very beginning.

CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>

Thanks, applied to block-next.

Kevin