1. 11 7月, 2017 24 次提交
  2. 26 6月, 2017 3 次提交
  3. 29 5月, 2017 1 次提交
  4. 11 5月, 2017 4 次提交
    • E
      qcow2: Discard/zero clusters by byte count · d2cb36af
      Eric Blake 提交于
      Passing a byte offset, but sector count, when we ultimately
      want to operate on cluster granularity, is madness.  Clean up
      the external interfaces to take both offset and count as bytes,
      while still keeping the assertion added previously that the
      caller must align the values to a cluster.  Then rename things
      to make sure backports don't get confused by changed units:
      instead of qcow2_discard_clusters() and qcow2_zero_clusters(),
      we now have qcow2_cluster_discard() and qcow2_cluster_zeroize().
      
      The internal functions still operate on clusters at a time, and
      return an int for number of cleared clusters; but on an image
      with 2M clusters, a single L2 table holds 256k entries that each
      represent a 2M cluster, totalling well over INT_MAX bytes if we
      ever had a request for that many bytes at once.  All our callers
      currently limit themselves to 32-bit bytes (and therefore fewer
      clusters), but by making this function 64-bit clean, we have one
      less place to clean up if we later improve the block layer to
      support 64-bit bytes through all operations (with the block layer
      auto-fragmenting on behalf of more-limited drivers), rather than
      the current state where some interfaces are artificially limited
      to INT_MAX at a time.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20170507000552.20847-13-eblake@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      d2cb36af
    • E
      qcow2: Optimize write zero of unaligned tail cluster · fbaa6bb3
      Eric Blake 提交于
      We've already improved discards to operate efficiently on the tail
      of an unaligned qcow2 image; it's time to make a similar improvement
      to write zeroes.  The special case is only valid at the tail
      cluster of a file, where we must recognize that any sectors beyond
      the image end would implicitly read as zero, and therefore should
      not penalize our logic for widening a partial cluster into writing
      the whole cluster as zero.
      
      However, note that for now, the special case of end-of-file is only
      recognized if there is no backing file, or if the backing file has
      the same length; that's because when the backing file is shorter
      than the active layer, we don't have code in place to recognize
      that reads of a sector unallocated at the top and beyond the backing
      end-of-file are implicitly zero.  It's not much of a real loss,
      because most people don't use images that aren't cluster-aligned,
      or where the active layer is a different size than the backing
      layer (especially where the difference falls within a single cluster).
      
      Update test 154 to cover the new scenarios, using two images of
      intentionally differing length.
      
      While at it, fix the test to gracefully skip when run as
      ./check -qcow2 -o compat=0.10 154
      since the older format lacks zero clusters already required earlier
      in the test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20170507000552.20847-11-eblake@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      fbaa6bb3
    • E
      qcow2: Make distinction between zero cluster types obvious · fdfab37d
      Eric Blake 提交于
      Treat plain zero clusters differently from allocated ones, so that
      we can simplify the logic of checking whether an offset is present.
      Do this by splitting QCOW2_CLUSTER_ZERO into two new enums,
      QCOW2_CLUSTER_ZERO_PLAIN and QCOW2_CLUSTER_ZERO_ALLOC.
      
      I tried to arrange the enum so that we could use
      'ret <= QCOW2_CLUSTER_ZERO_PLAIN' for all unallocated types, and
      'ret >= QCOW2_CLUSTER_ZERO_ALLOC' for allocated types, although
      I didn't actually end up taking advantage of the layout.
      
      In many cases, this leads to simpler code, by properly combining
      cases (sometimes, both zero types pair together, other times,
      plain zero is more like unallocated while allocated zero is more
      like normal).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-id: 20170507000552.20847-7-eblake@redhat.com
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      fdfab37d
    • M
      qcow2: Fix preallocation size formula · 92413c16
      Max Reitz 提交于
      When calculating the number of reftable entries, we should actually use
      the number of refblocks and not (wrongly[1]) re-calculate it.
      
      [1] "Wrongly" means: Dividing the number of clusters by the number of
          entries per refblock and rounding down instead of up.
      Reported-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      92413c16
  5. 09 5月, 2017 1 次提交
  6. 28 4月, 2017 4 次提交
  7. 01 3月, 2017 3 次提交
    • K
      block: Add BDRV_O_RESIZE for blk_new_open() · 55880601
      Kevin Wolf 提交于
      blk_new_open() is a convenience function that processes flags rather
      than QDict options as a simple way to just open an image file.
      
      In order to keep it convenient in the future, it must automatically
      request the necessary permissions. This can easily be inferred from the
      flags for read and write, but we need another flag that tells us whether
      to get the resize permission.
      
      We can't just always request it because that means that no block jobs
      can run on the resulting BlockBackend (which is something that e.g.
      qemu-img commit wants to do), but we also can't request it never because
      most of the .bdrv_create() implementations call blk_truncate().
      
      The solution is to introduce another flag that is passed by all users
      that want to resize the image.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Acked-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      55880601
    • K
      block: Add error parameter to blk_insert_bs() · d7086422
      Kevin Wolf 提交于
      Now that blk_insert_bs() requests the BlockBackend permissions for the
      node it attaches to, it can fail. Instead of aborting, pass the errors
      to the callers.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Acked-by: NFam Zheng <famz@redhat.com>
      d7086422
    • K
      block: Add permissions to blk_new() · 6d0eb64d
      Kevin Wolf 提交于
      We want every user to be specific about the permissions it needs, so
      we'll pass the initial permissions as parameters to blk_new(). A user
      only needs to call blk_set_perm() if it wants to change the permissions
      after the fact.
      
      The permissions are stored in the BlockBackend and applied whenever a
      BlockDriverState should be attached in blk_insert_bs().
      
      This does not include actually choosing the right set of permissions
      everywhere yet. Instead, the usual FIXME comment is added to each place
      and will be addressed in individual patches.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Acked-by: NFam Zheng <famz@redhat.com>
      6d0eb64d