1. 26 3月, 2018 1 次提交
  2. 09 3月, 2018 3 次提交
  3. 03 3月, 2018 5 次提交
    • S
      block: rename .bdrv_create() to .bdrv_co_create_opts() · efc75e2a
      Stefan Hajnoczi 提交于
      BlockDriver->bdrv_create() has been called from coroutine context since
      commit 5b7e1542 ("block: make
      bdrv_create adopt coroutine").
      
      Make this explicit by renaming to .bdrv_co_create_opts() and add the
      coroutine_fn annotation.  This makes it obvious to block driver authors
      that they may yield, use CoMutex, or other coroutine_fn APIs.
      bdrv_co_create is reserved for the QAPI-based version that Kevin is
      working on.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20170705102231.20711-2-stefanha@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      efc75e2a
    • S
      block: extract AIO_WAIT_WHILE() from BlockDriverState · 7719f3c9
      Stefan Hajnoczi 提交于
      BlockDriverState has the BDRV_POLL_WHILE() macro to wait on event loop
      activity while a condition evaluates to true.  This is used to implement
      synchronous operations where it acts as a condvar between the IOThread
      running the operation and the main loop waiting for the operation.  It
      can also be called from the thread that owns the AioContext and in that
      case it's just a nested event loop.
      
      BlockBackend needs this behavior but doesn't always have a
      BlockDriverState it can use.  This patch extracts BDRV_POLL_WHILE() into
      the AioWait abstraction, which can be used with AioContext and isn't
      tied to BlockDriverState anymore.
      
      This feature could be built directly into AioContext but then all users
      would kick the event loop even if they signal different conditions.
      Imagine an AioContext with many BlockDriverStates, each time a request
      completes any waiter would wake up and re-check their condition.  It's
      nicer to keep a separate AioWait object for each condition instead.
      
      Please see "block/aio-wait.h" for details on the API.
      
      The name AIO_WAIT_WHILE() avoids the confusion between AIO_POLL_WHILE()
      and AioContext polling.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      7719f3c9
    • E
      block: Drop unused .bdrv_co_get_block_status() · 636cb512
      Eric Blake 提交于
      We are gradually moving away from sector-based interfaces, towards
      byte-based.  Now that all drivers have been updated to provide the
      byte-based .bdrv_co_block_status(), we can delete the sector-based
      interface.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      636cb512
    • E
      block: Switch passthrough drivers to .bdrv_co_block_status() · 3e4d0e72
      Eric Blake 提交于
      We are gradually moving away from sector-based interfaces, towards
      byte-based.  Update the generic helpers, and all passthrough clients
      (blkdebug, commit, mirror, throttle) accordingly.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      3e4d0e72
    • E
      block: Add .bdrv_co_block_status() callback · 86a3d5c6
      Eric Blake 提交于
      We are gradually moving away from sector-based interfaces, towards
      byte-based. Now that the block layer exposes byte-based allocation,
      it's time to tackle the drivers.  Add a new callback that operates
      on as small as byte boundaries. Subsequent patches will then update
      individual drivers, then finally remove .bdrv_co_get_block_status().
      
      The new code also passes through the 'want_zero' hint, which will
      allow subsequent patches to further optimize callers that only care
      about how much of the image is allocated (want_zero is false),
      rather than full details about runs of zeroes and which offsets the
      allocation actually maps to (want_zero is true).  As part of this
      effort, fix another part of the documentation: the claim in commit
      4c41cb49 that BDRV_BLOCK_ALLOCATED is short for 'DATA || ZERO' is a
      lie at the block layer (see commit e88ae226), even though it is
      how the bit is computed from the driver layer.  After all, there
      are intentionally cases where we return ZERO but not ALLOCATED at
      the block layer, when we know that a read sees zero because the
      backing file is too short.  Note that the driver interface is thus
      slightly different than the public interface with regards to which
      bits will be set, and what guarantees are provided on input.
      
      We also add an assertion that any driver using the new callback will
      make progress (the only time pnum will be 0 is if the block layer
      already handled an out-of-bounds request, or if there is an error);
      the old driver interface did not provide this guarantee, which
      could lead to some inf-loops in drastic corner-case failures.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      86a3d5c6
  4. 09 2月, 2018 2 次提交
  5. 08 2月, 2018 1 次提交
  6. 22 12月, 2017 2 次提交
  7. 26 10月, 2017 2 次提交
    • E
      block: Align block status requests · efa6e2ed
      Eric Blake 提交于
      Any device that has request_alignment greater than 512 should be
      unable to report status at a finer granularity; it may also be
      simpler for such devices to be guaranteed that the block layer
      has rounded things out to the granularity boundary (the way the
      block layer already rounds all other I/O out).  Besides, getting
      the code correct for super-sector alignment also benefits us
      for the fact that our public interface now has byte granularity,
      even though none of our drivers have byte-level callbacks.
      
      Add an assertion in blkdebug that proves that the block layer
      never requests status of unaligned sections, similar to what it
      does on other requests (while still keeping the generic helper
      in place for when future patches add a throttle driver).  Note
      that iotest 177 already covers this (it would fail if you use
      just the blkdebug.c hunk without the io.c changes).  Meanwhile,
      we can drop assertions in callers that no longer have to pass
      in sector-aligned addresses.
      
      There is a mid-function scope added for 'count' and 'longret',
      for a couple of reasons: first, an upcoming patch will add an
      'if' statement that checks whether a driver has an old- or
      new-style callback, and can conveniently use the same scope for
      less indentation churn at that time.  Second, since we are
      trying to get rid of sector-based computations, wrapping things
      in a scope makes it easier to group and see what will be
      deleted in a final cleanup patch once all drivers have been
      converted to the new-style callback.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      efa6e2ed
    • 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
  8. 13 10月, 2017 2 次提交
  9. 06 10月, 2017 2 次提交
  10. 26 9月, 2017 1 次提交
  11. 05 9月, 2017 5 次提交
  12. 08 8月, 2017 1 次提交
  13. 24 7月, 2017 1 次提交
    • K
      block: Skip implicit nodes in query-block/blockstats · d3c8c674
      Kevin Wolf 提交于
      Commits 0db832f4 and 6cdbceb1 introduced the automatic insertion of filter
      nodes above the top layer of mirror and commit block jobs. The
      assumption made there was that since libvirt doesn't do node-level
      management of the block layer yet, it shouldn't be affected by added
      nodes.
      
      This is true as far as commands issued by libvirt are concerned. It only
      uses BlockBackend names to address nodes, so any operations it performs
      still operate on the root of the tree as intended.
      
      However, the assumption breaks down when you consider query commands,
      which return data for the wrong node now. These commands also return
      information on some child nodes (bs->file and/or bs->backing), which
      libvirt does make use of, and which refer to the wrong nodes, too.
      
      One of the consequences is that oVirt gets wrong information about the
      image size and stops the VM in response as long as a mirror or commit
      job is running:
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1470634
      
      This patch fixes the problem by hiding the implicit nodes created
      automatically by the mirror and commit block jobs in the output of
      query-block and BlockBackend-based query-blockstats as long as the user
      doesn't indicate that they are aware of those nodes by providing a node
      name for them in the QMP command to start the block job.
      
      The node-based commands query-named-block-nodes and query-blockstats
      with query-nodes=true still show all nodes, including implicit ones.
      This ensures that users that are capable of node-level management can
      still access the full information; users that only know BlockBackends
      won't use these commands.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NPeter Krempa <pkrempa@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Tested-by: NEric Blake <eblake@redhat.com>
      d3c8c674
  14. 17 7月, 2017 1 次提交
  15. 11 7月, 2017 7 次提交
  16. 26 6月, 2017 1 次提交
  17. 16 6月, 2017 3 次提交