[Top][All Lists]

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

Re: [Qemu-block] [Qemu-devel] [PATCH v4 03/20] file-posix: Switch to .bd

From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 03/20] file-posix: Switch to .bdrv_co_block_status()
Date: Thu, 30 Nov 2017 14:40:54 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 10/12/2017 01:58 PM, Eric Blake wrote:
We are gradually moving away from sector-based interfaces, towards
byte-based.  Update the file protocol driver accordingly.

In want_zero mode, we continue to report fine-grained hole
information (the caller wants as much mapping detail as possible);
but when not in that mode, the caller prefers larger *pnum and
merely cares about what offsets are allocated at this layer, rather
than where the holes live.  Since holes still read as zeroes at
this layer (rather than deferring to a backing layer), we can take
the shortcut of skipping lseek(), and merely state that all bytes
are allocated.

Signed-off-by: Eric Blake <address@hidden>


@@ -2154,39 +2156,46 @@ static int64_t coroutine_fn 
raw_co_get_block_status(BlockDriverState *bs,
          return ret;

-    start = sector_num * BDRV_SECTOR_SIZE;
      total_size = bdrv_getlength(bs);
      if (total_size < 0) {
          return total_size;
-    } else if (start >= total_size) {
+    } else if (offset >= total_size) {
          *pnum = 0;
          return 0;
-    } else if (start + nb_sectors * BDRV_SECTOR_SIZE > total_size) {
-        nb_sectors = DIV_ROUND_UP(total_size - start, BDRV_SECTOR_SIZE);
+    } else if (offset + bytes > total_size) {
+        bytes = total_size - offset;

I just realized: this is dead code. The block layer already checked bdrv_getlength() and clamped values. So, v5 will trim this and similar redundant driver code.

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

reply via email to

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