Skip to content

Clean up around bdrv_getlength()

Markus Armbruster qemu-devel 3 versions – Applied

Status from this message: Thanks, applied to my block tree for QEMU 2.1:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest10 patches 3 repliesApplied
  2. v410 patches 5 repliesSuperseded
  3. v15 patches 6 repliesApplied

Changes in v5 from the cover letter

* Straightforward rebase, only 10/10 conflicted

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/10raw-posix: Fix raw_getlength() to always return -errno on errorblock/raw-posix.c+22 -61 reply
2/10block: New bdrv_nb_sectors()block.c include/block/block.h+20 -100 replies
3/10block: Use bdrv_nb_sectors() in bdrv_make_zero()block.c+5 -70 replies
4/10block: Use bdrv_nb_sectors() in bdrv_aligned_preadv()block.c+4 -50 replies
5/10block: Use bdrv_nb_sectors() in bdrv_co_get_block_status()block.c+8 -80 replies
6/10block: Use bdrv_nb_sectors() in img_convert()qemu-img.c+4 -40 replies
7/10block: Use bdrv_nb_sectors() where sectors, not bytes are wantedblock-migration.c block.c block/qcow2.c +1 more+8 -110 replies
8/10block: Drop superfluous aligning of bdrv_getlength()'s valueblock.c block/qcow2.c+0 -20 replies
9/10qemu-img: Make img_convert() get image size just once per imageqemu-img.c+16 -160 replies
10/10block: Avoid bdrv_get_geometry() where errors should be detectedblock.c block/qapi.c qemu-img.c+68 -210 replies

Reviews trailers per patch

All 10 patches have a Reviewed-by or Acked-by.

PatchEric BlakeBenoit CanetMax Reitz
1/10R-b R-b
2/10R-b R-b
3/10R-b R-b
4/10R-b R-b
5/10R-b R-b
6/10R-b R-b
7/10R-b R-b
8/10R-b R-b
9/10R-b R-b
10/10R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v5 thread

Cover letter [Qemu-devel] [PATCH v5 00/10] Clean up around bdrv_getlength()

Issues addressed in this series:

* BlockDriver method bdrv_getlength() generally returns -errno, but some implementations return -1 instead. Fix them [PATCH 1].

* Frequent conversions between sectors and bytes complicate the code needlessly. Clean up some [PATCH 2-7].

* bdrv_getlength() always returns a multiple of BDRV_SECTOR_SIZE, but some places appear to be confused about that, and align the result up or down. Don't [PATCH 8].

* bdrv_get_geometry() hides errors. Don't use it in places where errors should be detected [PATCH 9+10].

Issues not addressed:

* We want to move away from counting in arbitrary units of 512 bytes we call "sector", even though it's not really related to either guest or host sector size. My patches mostly move sideways:

- Sector-based bdrv_get_geometry() gets partly replaced by new bdrv_nb_sectors(), still sector-based.

- Some sector-based places get converted from bdrv_getlength() to bdrv_nb_sectors(). At least, this de-duplicates the conversion from bytes to sectors.

- Two places get converted from bdrv_get_geometry() to bdrv_getlength(). Two baby steps forward.

* There are quite a few literals left in the code where BDRV_SECTOR_SIZE, BDRV_SECTOR_BITS or BDRV_SECTOR_MASK should be used instead.

* Error handling is missing in places, but it's not always obvious whether errors can actually happen, and if yes, how to handle them.

* Several calls of bdrv_get_geometry() remain in hw/. I wanted to replace them all, but ran out of steam.

v5:
* Straightforward rebase, only 10/10 conflicted
v4:
* Trivially rebased
* Set ret on error paths in img_compare() and img_rebase() in PATCH 10 [Benoît]
v3:
* Trivially rebased
* Correct silly g_new() vs. g_new0() mistake in PATCH 09 [Max] v2:
* Trivially rebased
* Correct silly bdrv_getlength() vs. bdrv_nb_sectors() mistake in PATCH 03
* Split PATCH 03 into 03-07 [Kevin]
* Conversion of bs_sectors to array in PATCH 05 had a subscript off by one, fix [Kevin]
* Split PATCH 05 into 09-10 [Kevin]

Markus Armbruster (10):
raw-posix: Fix raw_getlength() to always return -errno on error
block: New bdrv_nb_sectors()
block: Use bdrv_nb_sectors() in bdrv_make_zero()
block: Use bdrv_nb_sectors() in bdrv_aligned_preadv()
block: Use bdrv_nb_sectors() in bdrv_co_get_block_status()
block: Use bdrv_nb_sectors() in img_convert()
block: Use bdrv_nb_sectors() where sectors, not bytes are wanted
block: Drop superfluous aligning of bdrv_getlength()'s value
qemu-img: Make img_convert() get image size just once per image
block: Avoid bdrv_get_geometry() where errors should be detected

 block-migration.c     |  9 +++--
 block.c               | 81 +++++++++++++++++++++++-------------------
 block/qapi.c          | 14 +++++---
 block/qcow2.c         |  3 +-
 block/raw-posix.c     | 28 +++++++++++----
 block/vmdk.c          |  5 ++-
 include/block/block.h |  1 +
 qemu-img.c            | 98 +++++++++++++++++++++++++++++++++++----------------
 8 files changed, 152 insertions(+), 87 deletions(-)
Signature · 1 line
1.9.3