1. 26 10月, 2017 7 次提交
    • E
      block: Switch bdrv_make_zero() to byte-based · 7286d610
      Eric Blake 提交于
      We are gradually converting to byte-based interfaces, as they are
      easier to reason about than sector-based.  Change the internal
      loop iteration of zeroing a device to track by bytes instead of
      sectors (although we are still guaranteed that we iterate by steps
      that are sector-aligned).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      7286d610
    • E
      qcow2: Switch is_zero_sectors() to byte-based · f06f6b66
      Eric Blake 提交于
      We are gradually converting to byte-based interfaces, as they are
      easier to reason about than sector-based.  Convert another internal
      function (no semantic change), and rename it to is_zero() in the
      process.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f06f6b66
    • E
      block: Make bdrv_round_to_clusters() signature more useful · 7cfd5275
      Eric Blake 提交于
      In the process of converting sector-based interfaces to bytes,
      I'm finding it easier to represent a byte count as a 64-bit
      integer at the block layer (even if we are internally capped
      by SIZE_MAX or even INT_MAX for individual transactions, it's
      still nicer to not have to worry about truncation/overflow
      issues on as many variables).  Update the signature of
      bdrv_round_to_clusters() to uniformly use int64_t, matching
      the signature already chosen for bdrv_is_allocated and the
      fact that off_t is also a signed type, then adjust clients
      according to the required fallout (even where the result could
      now exceed 32 bits, no client is directly assigning the result
      into a 32-bit value without breaking things into a loop first).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      7cfd5275
    • E
      block: Add flag to avoid wasted work in bdrv_is_allocated() · c9ce8c4d
      Eric Blake 提交于
      Not all callers care about which BDS owns the mapping for a given
      range of the file, or where the zeroes lie within that mapping.  In
      particular, bdrv_is_allocated() cares more about finding the
      largest run of allocated data from the guest perspective, whether
      or not that data is consecutive from the host perspective, and
      whether or not the data reads as zero.  Therefore, doing subsequent
      refinements such as checking how much of the format-layer
      allocation also satisfies BDRV_BLOCK_ZERO at the protocol layer is
      wasted work - in the best case, it just costs extra CPU cycles
      during a single bdrv_is_allocated(), but in the worst case, it
      results in a smaller *pnum, and forces callers to iterate through
      more status probes when visiting the entire file for even more
      extra CPU cycles.
      
      This patch only optimizes the block layer (no behavior change when
      want_zero is true, but skip unnecessary effort when it is false).
      Then when subsequent patches tweak the driver callback to be
      byte-based, we can also pass this hint through to the driver.
      
      Tweak BdrvCoGetBlockStatusData to declare arguments in parameter
      order, rather than mixing things up (minimizing padding is not
      necessary here).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c9ce8c4d
    • E
      block: Allow NULL file for bdrv_get_block_status() · 298a1665
      Eric Blake 提交于
      Not all callers care about which BDS owns the mapping for a given
      range of the file.  This patch merely simplifies the callers by
      consolidating the logic in the common call point, while guaranteeing
      a non-NULL file to all the driver callbacks, for no semantic change.
      The only caller that does not care about pnum is bdrv_is_allocated,
      as invoked by vvfat; we can likewise add assertions that the rest
      of the stack does not have to worry about a NULL pnum.
      
      Furthermore, this will also set the stage for a future cleanup: when
      a caller does not care about which BDS owns an offset, it would be
      nice to allow the driver to optimize things to not have to return
      BDRV_BLOCK_OFFSET_VALID in the first place.  In the case of fragmented
      allocation (for example, it's fairly easy to create a qcow2 image
      where consecutive guest addresses are not at consecutive host
      addresses), the current contract requires bdrv_get_block_status()
      to clamp *pnum to the limit where host addresses are no longer
      consecutive, but allowing a NULL file means that *pnum could be
      set to the full length of known-allocated data.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      298a1665
    • K
      qemu-iotests: Test backing_fmt with backing node reference · 760c4d43
      Kevin Wolf 提交于
      This changes test case 191 to include a backing image that has
      backing_fmt set in the image file, but is referenced by node name in the
      qemu command line.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      760c4d43
    • P
      block: don't add 'driver' to options when referring to backing via node name · 6bff597b
      Peter Krempa 提交于
      When referring to a backing file of an image via node name
      bdrv_open_backing_file would add the 'driver' option to the option list
      filling it with the backing format driver. This breaks construction of
      the backing chain via -blockdev, as bdrv_open_inherit reports an error
      if both 'reference' and 'options' are provided.
      
      $ qemu-img create -f raw /tmp/backing.raw 64M
      $ qemu-img create -f qcow2 -F raw -b /tmp/backing.raw /tmp/test.qcow2
      $ qemu-system-x86_64 \
        -blockdev driver=file,filename=/tmp/backing.raw,node-name=backing \
        -blockdev driver=qcow2,file.driver=file,file.filename=/tmp/test.qcow2,node-name=root,backing=backing
      qemu-system-x86_64: -blockdev driver=qcow2,file.driver=file,file.filename=/tmp/test.qcow2,node-name=root,backing=backing: Could not open backing file: Cannot reference an existing block device with additional options or a new filename
      Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6bff597b
  2. 25 10月, 2017 33 次提交