qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 16/24] block: Make zero-after-EOF work with l


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v2 16/24] block: Make zero-after-EOF work with larger alignment
Date: Fri, 10 Jan 2014 20:07:19 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 13.12.2013 14:22, Kevin Wolf wrote:
Odd file sizes could make bdrv_aligned_preadv() shorten the request in
non-aligned ways. Fix it by rounding to the required alignment instead
of 512 bytes.

Signed-off-by: Kevin Wolf <address@hidden>
---
  block.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index b4f6ead..6dddb7c 100644
--- a/block.c
+++ b/block.c
@@ -2725,7 +2725,7 @@ err:
   */
  static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
      BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
-    QEMUIOVector *qiov, int flags)
+    int64_t align, QEMUIOVector *qiov, int flags)
  {
      BlockDriver *drv = bs->drv;
      int ret;
@@ -2773,7 +2773,7 @@ static int coroutine_fn 
bdrv_aligned_preadv(BlockDriverState *bs,
          }
total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
-        max_nb_sectors = MAX(0, total_sectors - sector_num);
+        max_nb_sectors = MAX(0, ROUND_UP(total_sectors - sector_num, align));

It appears this should be an alignment given in sectors…

          if (max_nb_sectors > 0) {
              ret = drv->bdrv_co_readv(bs, sector_num,
                                       MIN(nb_sectors, max_nb_sectors), qiov);
@@ -2858,7 +2858,7 @@ static int coroutine_fn 
bdrv_co_do_preadv(BlockDriverState *bs,
      }
tracked_request_begin(&req, bs, offset, bytes, false);
-    ret = bdrv_aligned_preadv(bs, &req, offset, bytes,
+    ret = bdrv_aligned_preadv(bs, &req, offset, bytes, align,

Whereas this one is an alignment given in bytes.

Max

                                use_local_qiov ? &local_qiov : qiov,
                                flags);
      tracked_request_end(&req);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]