1. 14 7月, 2020 7 次提交
    • E
      sheepdog: Add trivial backing_fmt support · 80fa43e7
      Eric Blake 提交于
      Sheepdog already requires that if backing_file is present, that it be
      another sheepdog image (see sd_co_create).  Meanwhile, we want to move
      towards always being explicit about the backing format for other
      drivers where it matters.  So for convenience, make qemu-img create -F
      sheepdog work, while rejecting all other explicit formats (note that
      this is only for QemuOpts usage; there is no change to the QAPI to
      allow a format through -blockdev).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-4-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      80fa43e7
    • E
      block: Finish deprecation of 'qemu-img convert -n -o' · 25956af3
      Eric Blake 提交于
      It's been two releases since we started warning; time to make the
      combination an error as promised.  There was no iotest coverage, so
      add some.
      
      While touching the documentation, tweak another section heading for
      consistent style.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-3-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      25956af3
    • E
      qemu-img: Flush stdout before before potential stderr messages · 4e2f4418
      Eric Blake 提交于
      During 'qemu-img create ... 2>&1', if --quiet is not in force, we can
      end up with buffered I/O in stdout that was produced before failure,
      but which appears in output after failure.  This is confusing; the fix
      is to flush stdout prior to attempting anything that might produce an
      error message.  Several iotests demonstrate the resulting ordering
      change now that the merged outputs now reflect chronology.  (An even
      better fix would be to avoid printf from within block.c altogether,
      but that's much more invasive...)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200706203954.341758-2-eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      4e2f4418
    • K
      file-posix: Mitigate file fragmentation with extent size hints · ffa244c8
      Kevin Wolf 提交于
      Especially when O_DIRECT is used with image files so that the page cache
      indirection can't cause a merge of allocating requests, the file will
      fragment on the file system layer, with a potentially very small
      fragment size (this depends on the requests the guest sent).
      
      On Linux, fragmentation can be reduced by setting an extent size hint
      when creating the file (at least on XFS, it can't be set any more after
      the first extent has been allocated), basically giving raw files a
      "cluster size" for allocation.
      
      This adds a create option to set the extent size hint, and changes the
      default from not setting a hint to setting it to 1 MB. The main reason
      why qcow2 defaults to smaller cluster sizes is that COW becomes more
      expensive, which is not an issue with raw files, so we can choose a
      larger size. The tradeoff here is only potentially wasted disk space.
      
      For qcow2 (or other image formats) over file-posix, the advantage should
      even be greater because they grow sequentially without leaving holes, so
      there won't be wasted space. Setting even larger extent size hints for
      such images may make sense. This can be done with the new option, but
      let's keep the default conservative for now.
      
      The effect is very visible with a test that intentionally creates a
      badly fragmented file with qemu-img bench (the time difference while
      creating the file is already remarkable) and then looks at the number of
      extents and the time a simple "qemu-img map" takes.
      
      Without an extent size hint:
      
          $ ./qemu-img create -f raw -o extent_size_hint=0 ~/tmp/test.raw 10G
          Formatting '/home/kwolf/tmp/test.raw', fmt=raw size=10737418240 extent_size_hint=0
          $ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 0
          Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 0, step size 8192)
          Run completed in 25.848 seconds.
          $ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 4096
          Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 4096, step size 8192)
          Run completed in 19.616 seconds.
          $ filefrag ~/tmp/test.raw
          /home/kwolf/tmp/test.raw: 2000000 extents found
          $ time ./qemu-img map ~/tmp/test.raw
          Offset          Length          Mapped to       File
          0               0x1e8480000     0               /home/kwolf/tmp/test.raw
      
          real    0m1,279s
          user    0m0,043s
          sys     0m1,226s
      
      With the new default extent size hint of 1 MB:
      
          $ ./qemu-img create -f raw -o extent_size_hint=1M ~/tmp/test.raw 10G
          Formatting '/home/kwolf/tmp/test.raw', fmt=raw size=10737418240 extent_size_hint=1048576
          $ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 0
          Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 0, step size 8192)
          Run completed in 11.833 seconds.
          $ ./qemu-img bench -f raw -t none -n -w ~/tmp/test.raw -c 1000000 -S 8192 -o 4096
          Sending 1000000 write requests, 4096 bytes each, 64 in parallel (starting at offset 4096, step size 8192)
          Run completed in 10.155 seconds.
          $ filefrag ~/tmp/test.raw
          /home/kwolf/tmp/test.raw: 178 extents found
          $ time ./qemu-img map ~/tmp/test.raw
          Offset          Length          Mapped to       File
          0               0x1e8480000     0               /home/kwolf/tmp/test.raw
      
          real    0m0,061s
          user    0m0,040s
          sys     0m0,014s
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Message-Id: <20200707142329.48303-1-kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      ffa244c8
    • K
      iotests/059: Filter out disk size with more standard filter · 046e07ca
      Kevin Wolf 提交于
      The actual disk space used by an image can vary between filesystems and
      depending on other settings like an extent size hint. Replace the one
      call of "$QEMU_IMG info" and the associated one-off sed filter with the
      more standard "_img_info" and the standard filter from common.filter.
      
      Apart from turning "vmdk" into "IMGFMT" and changing the placeholder for
      cid fields, this only removes the "disk size" line.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      046e07ca
    • K
      qemu-img map: Don't limit block status request size · d0ceea88
      Kevin Wolf 提交于
      Limiting each loop iteration of qemu-img map to 1 GB was arbitrary from
      the beginning, though it only cut the maximum in half then because the
      interface was a signed 32 bit byte count. These days, bdrv_block_status
      supports a 64 bit byte count, so the arbitrary limit is even worse.
      
      On file-posix, bdrv_block_status() eventually maps to SEEK_HOLE and
      SEEK_DATA, which don't support a limit, but always do all of the work
      necessary to find the start of the next hole/data. Much of this work may
      be repeated if we don't use this information fully, but query with an
      only slightly larger offset in the next loop iteration. Therefore, if
      bdrv_block_status() is called in a loop, it should always pass the
      full number of bytes that the whole loop is interested in.
      
      This removes the arbitrary limit and speeds up 'qemu-img map'
      significantly on heavily fragmented images.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Message-Id: <20200707144629.51235-1-kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d0ceea88
    • M
      iotests: Simplify _filter_img_create() a bit · 4b196cd1
      Max Reitz 提交于
      Not only is it a bit stupid to try to filter multi-line "Formatting"
      output (because we only need it for a single test, which can easily be
      amended to no longer need it), it is also problematic when there can be
      output after a "Formatting" line that we do not want to filter as if it
      were part of it.
      
      So rename _filter_img_create to _do_filter_img_create, let it filter
      only a single line, and let _filter_img_create loop over all input
      lines, calling _do_filter_img_create only on those that match
      /^Formatting/ (basically, what _filter_img_create_in_qmp did already).
      (And fix 020 to work with that.)
      Reported-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-Id: <20200709110205.310942-1-mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      4b196cd1
  2. 13 7月, 2020 33 次提交