Skip to contentSkip to conversation

512-on-4k follow-up patches

PATCH In review Kevin Wolf 3 participants 8 messages Feb 7, 2014 – Feb 8, 2014

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

cover 512-on-4k follow-up patches

Kevin Wolf (3):
block: Fix memory leaks in bdrv_co_do_pwritev()
block: bdrv_aligned_pwritev: Assert overlap range
block: Don't call ROUND_UP with negative values

 block.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
1.8.1.4
author
#1 lore raw

PATCH 1/3 block: Fix memory leaks in bdrv_co_do_pwritev()

The error path for a failure in one of the two bdrv_aligned_preadv() calls leaked head_buf or tail_buf, respectively. This fixes the memory leak.

---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block.c +2 -2
index ac0ccac..c1d1f74 100644
@@ -3279,9 +3279,9 @@ fail:
 
     if (use_local_qiov) {
         qemu_iovec_destroy(&local_qiov);
-        qemu_vfree(head_buf);
-        qemu_vfree(tail_buf);
     }
+    qemu_vfree(head_buf);
+    qemu_vfree(tail_buf);
 
     return ret;
 }
Signature · 1 line
1.8.1.4
author
#2 lore raw

PATCH 2/3 block: bdrv_aligned_pwritev: Assert overlap range

In reply to Kevin Wolf

This adds assertions that the request that we actually end up passing to the block driver (which includes RMW data and has therefore potentially been rounded to alignment boundaries) is fully covered by the overlap_{offset,size} fields of the associated BdrvTrackedRequest.

---
 block.c | 2 ++
 1 file changed, 2 insertions(+)
block.c +2 -0
index c1d1f74..a027823 100644
@@ -3134,6 +3134,8 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs,
 
     waited = wait_serialising_requests(req);
     assert(!waited || !req->serialising);
+    assert(req->overlap_offset <= offset);
+    assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
 
     ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
 
Signature · 1 line
1.8.1.4
author
#3 lore raw

PATCH 3/3 block: Don't call ROUND_UP with negative values

In reply to Kevin Wolf

The behaviour of the ROUND_UP macro with negative numbers isn't obvious. It happens to do the right thing in this please, but better avoid it.

---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block.c +2 -2
index a027823..b0c5025 100644
@@ -2915,8 +2915,8 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
         }
 
         total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
-        max_nb_sectors = MAX(0, ROUND_UP(total_sectors - sector_num,
-                                         align >> BDRV_SECTOR_BITS));
+        max_nb_sectors = ROUND_UP(MAX(0, total_sectors - sector_num),
+                                  align >> BDRV_SECTOR_BITS);
         if (max_nb_sectors > 0) {
             ret = drv->bdrv_co_readv(bs, sector_num,
                                      MIN(nb_sectors, max_nb_sectors), qiov);
Signature · 1 line
1.8.1.4
#4 lore raw

Re: [Qemu-devel] [PATCH 3/3] block: Don't call ROUND_UP with negative values

Quoted 2 lines · Kevin Wolf

The behaviour of the ROUND_UP macro with negative numbers isn't obvious. It happens to do the right thing in this please, but better avoid it.

s/please/place/

Quoted 6 lines
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Series: Reviewed-by: Eric Blake <[email protected]>

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#5 lore raw

Re: [Qemu-devel] [PATCH 3/3] block: Don't call ROUND_UP with negative values

Am 07.02.2014 um 17:27 hat Eric Blake geschrieben:

Quoted 5 lines · Kevin Wolf
Quoted 2 lines

The behaviour of the ROUND_UP macro with negative numbers isn't obvious. It happens to do the right thing in this please, but better avoid it.

s/please/place/

Indeed... Thanks, fixed it locally.

Quoted 7 lines
Quoted 5 lines
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Series: Reviewed-by: Eric Blake <[email protected]>

Kevin

Reviewed-by
#6 lore raw

Re: [Qemu-devel] [PATCH 3/3] block: Don't call ROUND_UP with negative values

Quoted 16 lines · Kevin Wolf

Am 07.02.2014 um 17:27 hat Eric Blake geschrieben:

Quoted 5 lines · Kevin Wolf
Quoted 2 lines

The behaviour of the ROUND_UP macro with negative numbers isn't obvious. It happens to do the right thing in this please, but better avoid it.

s/please/place/

Indeed... Thanks, fixed it locally.

Quoted 7 lines
Quoted 5 lines
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Series: Reviewed-by: Eric Blake <[email protected]>

Not necessary after Eric's review, but here it is anyway:

series

Thanks!
Laszlo

author
#7 lore raw

Re: [Qemu-devel] [PATCH 3/3] block: Don't call ROUND_UP with negative values

Am 08.02.2014 um 00:24 hat Laszlo Ersek geschrieben:

Quoted 16 lines · Kevin Wolf
Quoted 15 lines

Am 07.02.2014 um 17:27 hat Eric Blake geschrieben:

Quoted 5 lines · Kevin Wolf
Quoted 2 lines

The behaviour of the ROUND_UP macro with negative numbers isn't obvious. It happens to do the right thing in this please, but better avoid it.

s/please/place/

Indeed... Thanks, fixed it locally.

Quoted 6 lines
Quoted 5 lines
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 1 line
Quoted 1 line

Series: Reviewed-by: Eric Blake <[email protected]>

Not necessary after Eric's review, but here it is anyway:

series

Review is never unnecessary. Thanks, Laszlo.

Kevin