1. 05 7月, 2016 4 次提交
    • E
      block: Move request_alignment into BlockLimit · a5b8dd2c
      Eric Blake 提交于
      It makes more sense to have ALL block size limit constraints
      in the same struct.  Improve the documentation while at it.
      
      Simplify a couple of conditionals, now that we have audited and
      documented that request_alignment is always non-zero.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a5b8dd2c
    • E
      block: Switch discard length bounds to byte-based · b9f7855a
      Eric Blake 提交于
      Sector-based limits are awkward to think about; in our on-going
      quest to move to byte-based interfaces, convert max_discard and
      discard_alignment.  Rename them, using 'pdiscard' as an aid to
      track which remaining discard interfaces need conversion, and so
      that the compiler will help us catch the change in semantics
      across any rebased code.  The BlockLimits type is now completely
      byte-based; and in iscsi.c, sector_limits_lun2qemu() is no
      longer needed.
      
      pdiscard_alignment is made unsigned (we use power-of-2 alignments
      as bitmasks, where unsigned is easier to think about) while
      leaving max_pdiscard signed (since we still have an 'int'
      interface); this is comparable to what commit cf081fca did for
      write zeroes limits.  We may later want to make everything an
      unsigned 64-bit limit - but that requires a bigger code audit.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b9f7855a
    • E
      block: Wording tweaks to write zeroes limits · 29cc6a68
      Eric Blake 提交于
      Improve the documentation of the write zeroes limits, to mention
      additional constraints that drivers should observe.  Worth squashing
      into commit cf081fca, if that hadn't been pushed already :)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      29cc6a68
    • E
      block: Switch transfer length bounds to byte-based · 5def6b80
      Eric Blake 提交于
      Sector-based limits are awkward to think about; in our on-going
      quest to move to byte-based interfaces, convert max_transfer_length
      and opt_transfer_length.  Rename them (dropping the _length suffix)
      so that the compiler will help us catch the change in semantics
      across any rebased code, and improve the documentation.  Use unsigned
      values, so that we don't have to worry about negative values and
      so that bit-twiddling is easier; however, we are still constrained
      by 2^31 of signed int in most APIs.
      
      When a value comes from an external source (iscsi and raw-posix),
      sanitize the results to ensure that opt_transfer is a power of 2.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5def6b80
  2. 20 6月, 2016 1 次提交
    • S
      block: use safe iteration over AioContext notifiers · e8a095da
      Stefan Hajnoczi 提交于
      It's possible that an AioContext notifier user was close to finishing
      when .detach_aio_context() or .attached_aio_context() is called.  In
      that case they may call bdrv_remove_aio_context_notifier() during the
      callback.
      
      Use safe iteration to avoid crashing when the notifier list is modified
      during iteration.  We must not only handle the case where the current
      aio notifier is removed during a callback but also the one where any
      other aio notifier is removed.
      
      The next patch adds an AioContext notifier for block jobs and they
      really could be terminating just as .detach_aio_context() is invoked.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Message-id: 1466096189-6477-6-git-send-email-stefanha@redhat.com
      e8a095da
  3. 16 6月, 2016 4 次提交
    • M
      block/mirror: Fix target backing BDS · 274fccee
      Max Reitz 提交于
      Currently, we are trying to move the backing BDS from the source to the
      target in bdrv_replace_in_backing_chain() which is called from
      mirror_exit(). However, mirror_complete() already tries to open the
      target's backing chain with a call to bdrv_open_backing_file().
      
      First, we should only set the target's backing BDS once. Second, the
      mirroring block job has a better idea of what to set it to than the
      generic code in bdrv_replace_in_backing_chain() (in fact, the latter's
      conditions on when to move the backing BDS from source to target are not
      really correct).
      
      Therefore, remove that code from bdrv_replace_in_backing_chain() and
      leave it to mirror_complete().
      
      Depending on what kind of mirroring is performed, we furthermore want to
      use different strategies to open the target's backing chain:
      
      - If blockdev-mirror is used, we can assume the user made sure that the
        target already has the correct backing chain. In particular, we should
        not try to open a backing file if the target does not have any yet.
      
      - If drive-mirror with mode=absolute-paths is used, we can and should
        reuse the already existing chain of nodes that the source BDS is in.
        In case of sync=full, no backing BDS is required; with sync=top, we
        just link the source's backing BDS to the target, and with sync=none,
        we use the source BDS as the target's backing BDS.
        We should not try to open these backing files anew because this would
        lead to two BDSs existing per physical file in the backing chain, and
        we would like to avoid such concurrent access.
      
      - If drive-mirror with mode=existing is used, we have to use the
        information provided in the physical image file which means opening
        the target's backing chain completely anew, just as it has been done
        already.
        If the target's backing chain shares images with the source, this may
        lead to multiple BDSs per physical image file. But since we cannot
        reliably ascertain this case, there is nothing we can do about it.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20160610185750.30956-3-mreitz@redhat.com
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      274fccee
    • K
      block: Remove bs->zero_beyond_eof · c9d20029
      Kevin Wolf 提交于
      It is always true for open images now.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      c9d20029
    • K
      block: Make bdrv_load/save_vmstate coroutine_fns · 1a8ae822
      Kevin Wolf 提交于
      This allows drivers to share code between normal I/O and vmstate
      accesses.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      1a8ae822
    • K
      block: Make .bdrv_load_vmstate() vectored · 5ddda0b8
      Kevin Wolf 提交于
      This brings it in line with .bdrv_save_vmstate().
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      5ddda0b8
  4. 08 6月, 2016 3 次提交
    • E
      block: Kill bdrv_co_write_zeroes() · c1499a5e
      Eric Blake 提交于
      Now that all drivers have been converted to a byte interface,
      we no longer need a sector interface.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c1499a5e
    • E
      block: Add .bdrv_co_pwrite_zeroes() · d05aa8bb
      Eric Blake 提交于
      Update bdrv_co_do_write_zeroes() to be byte-based, and select
      between the new byte-based bdrv_co_pwrite_zeroes() or the old
      bdrv_co_write_zeroes().  The next patches will convert drivers,
      then remove the old interface.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d05aa8bb
    • E
      block: Track write zero limits in bytes · cf081fca
      Eric Blake 提交于
      Another step towards removing sector-based interfaces: convert
      the maximum write and minimum alignment values from sectors to
      bytes.  Rename the variables to let the compiler check that all
      users are converted to the new semantics.
      
      The maximum remains an int as long as BDRV_REQUEST_MAX_SECTORS
      is constrained by INT_MAX (this means that we can't even
      support a 2G write_zeroes, but just under it) - changing
      operation lengths to unsigned or to 64-bits is a much bigger
      audit, and debatable if we even want to do it (since at the
      core, a 32-bit platform will still have ssize_t as its
      underlying limit on write()).
      
      Meanwhile, alignment is changed to 'uint32_t', since it makes no
      sense to have an alignment larger than the maximum write, and
      less painful to use an unsigned type with well-defined behavior
      in bit operations than to have to worry about what happens if
      a driver mistakenly supplies a negative alignment.
      
      Add an assert that no one was trying to use sectors to get a
      write zeroes larger than 2G, and therefore that a later conversion
      to bytes won't be impacted by keeping the limit at 32 bits.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      cf081fca
  5. 26 5月, 2016 1 次提交
    • K
      block: Fix reconfiguring graph with drained nodes · 36fe1331
      Kevin Wolf 提交于
      When changing the BlockDriverState that a BdrvChild points to while the
      node is currently drained, we must call the .drained_end() parent
      callback. Conversely, when this means attaching a new node that is
      already drained, we need to call .drained_begin().
      
      bdrv_root_attach_child() takes now an opaque parameter, which is needed
      because the callbacks must also be called if we're attaching a new child
      to the BlockBackend when the root node is already drained, and they need
      a way to identify the BlockBackend. Previously, child->opaque was set
      too late and the callbacks would still see it as NULL.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      36fe1331
  6. 19 5月, 2016 9 次提交
  7. 12 5月, 2016 9 次提交
  8. 30 3月, 2016 4 次提交
  9. 17 3月, 2016 4 次提交
  10. 14 3月, 2016 1 次提交
    • K
      hmp: 'drive_add -n' for creating a node without BB · abb21ac3
      Kevin Wolf 提交于
      This patch adds an option to the drive_add HMP command to create only a
      BlockDriverState without a BlockBackend on top.
      
      The motivation for this is that libvirt needs to specify options to a
      migration target (specifically, detect-zeroes). drive-mirror doesn't
      allow specifying options, and the proper way to do this is to create the
      target BDS separately with blockdev-add (where you can specify options)
      and then use blockdev-mirror to that BDS.
      
      However, libvirt can't use blockdev-add as long as it is still
      experimental, and we're expecting that it will still take some time, so
      we need to resort to drive_add.
      
      The problem with drive_add is that so far it always created a BB, and
      BDSes with a BB can't be used as a mirroring target as long as we don't
      support multiple BBs per BDS - and while we're working towards that
      goal, it's another thing that will still take some time.
      
      So to achieve the goal, the simplest solution to provide the
      functionality now without adding one-off options to the mirror QMP
      commands is to extend drive_add to create nodes without BBs.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      abb21ac3