1. 10 12月, 2014 3 次提交
  2. 03 11月, 2014 8 次提交
    • S
      block: let commit blockjob run in BDS AioContext · 9e85cd5c
      Stefan Hajnoczi 提交于
      The commit block job must run in the BlockDriverState AioContext so that
      it works with dataplane.
      
      Acquire the AioContext in blockdev.c so starting the block job is safe.
      One detail here is that the bdrv_drain_all() must be moved inside the
      aio_context_acquire() region so requests cannot sneak in between the
      drain and acquire.
      
      The completion code in block/commit.c must perform backing chain
      manipulation and bdrv_reopen() from the main loop.  Use
      block_job_defer_to_main_loop() to achieve that.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1413889440-32577-11-git-send-email-stefanha@redhat.com
      9e85cd5c
    • S
      block: let mirror blockjob run in BDS AioContext · 5a7e7a0b
      Stefan Hajnoczi 提交于
      The mirror block job must run in the BlockDriverState AioContext so that
      it works with dataplane.
      
      Acquire the AioContext in blockdev.c so starting the block job is safe.
      
      Note that to_replace is treated separately from other BlockDriverStates
      in that it does not need to be in the same AioContext.  Explicitly
      acquire/release to_replace's AioContext when accessing it.
      
      The completion code in block/mirror.c must perform BDS graph
      manipulation and bdrv_reopen() from the main loop.  Use
      block_job_defer_to_main_loop() to achieve that.
      
      The bdrv_drain_all() call is not allowed outside the main loop since it
      could lead to lock ordering problems.  Use bdrv_drain(bs) instead
      because we have acquired the AioContext so nothing else can sneak in
      I/O.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1413889440-32577-10-git-send-email-stefanha@redhat.com
      5a7e7a0b
    • S
      block: let stream blockjob run in BDS AioContext · f3e69beb
      Stefan Hajnoczi 提交于
      The stream block job must run in the BlockDriverState AioContext so that
      it works with dataplane.
      
      The basics of acquiring the AioContext are easy in blockdev.c.
      
      The tricky part is the completion code which drops part of the backing
      file chain.  This must be done in the main loop where bdrv_unref() and
      bdrv_close() are safe to call.  Use block_job_defer_to_main_loop() to
      achieve that.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1413889440-32577-9-git-send-email-stefanha@redhat.com
      f3e69beb
    • S
      block: let backup blockjob run in BDS AioContext · 761731b1
      Stefan Hajnoczi 提交于
      The backup block job must run in the BlockDriverState AioContext so that
      it works with dataplane.
      
      The basics of acquiring the AioContext are easy in blockdev.c.
      
      The completion code in block/backup.c must call bdrv_unref() from the
      main loop.  Use block_job_defer_to_main_loop() to achieve that.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1413889440-32577-8-git-send-email-stefanha@redhat.com
      761731b1
    • S
      blockdev: add note that block_job_cb() must be thread-safe · 723c5d93
      Stefan Hajnoczi 提交于
      This function is correct but we should document the constraint that
      everything must be thread-safe.
      
      Emitting QMP events and scheduling BHs are both thread-safe so nothing
      needs to be done here.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1413889440-32577-5-git-send-email-stefanha@redhat.com
      723c5d93
    • S
      blockdev: acquire AioContext in blockdev_mark_auto_del() · 91fddb0d
      Stefan Hajnoczi 提交于
      When an emulated storage controller is unrealized it will call
      blockdev_mark_auto_del().  This will cancel any running block job (and
      that eventually releases its reference to the BDS so it can be freed).
      
      Since the block job may be executing in another AioContext we must
      acquire/release to ensure thread safety.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1413889440-32577-4-git-send-email-stefanha@redhat.com
      91fddb0d
    • S
      blockdev: acquire AioContext in do_qmp_query_block_jobs_one() · 69691e72
      Stefan Hajnoczi 提交于
      Make sure that query-block-jobs acquires the BlockDriverState
      AioContext so that the blockjob isn't running in another thread while we
      access its state.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1413889440-32577-3-git-send-email-stefanha@redhat.com
      69691e72
    • S
      block: acquire AioContext in generic blockjob QMP commands · 3d948cdf
      Stefan Hajnoczi 提交于
      block-job-set-speed, block-job-cancel, block-job-pause,
      block-job-resume, and block-job-complete must acquire the
      BlockDriverState AioContext so that it is safe to access bs.
      
      At the moment bs->job is always NULL when dataplane is active because op
      blockers prevent blockjobs from starting.  Once the rest of the blockjob
      API has been made aware of AioContext we can drop the op blocker.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1413889440-32577-2-git-send-email-stefanha@redhat.com
      3d948cdf
  3. 20 10月, 2014 14 次提交
  4. 03 10月, 2014 5 次提交
  5. 25 9月, 2014 4 次提交
  6. 11 9月, 2014 1 次提交
    • M
      blockdev: Refuse to drive_del something added with blockdev-add · 48f364dd
      Markus Armbruster 提交于
      For some device models, the guest can prevent unplug.  Some users need a
      way to forcibly revoke device model access to the block backend then, so
      the underlying images can be safely used for something else.
      
      drive_del lets you do that.  Unfortunately, it conflates revoking access
      with destroying the backend.
      
      Commit 9063f814 made drive_del immediately destroy the root BDS.  Nice:
      the device name becomes available for reuse immediately.  Not so nice:
      the device model's pointer to the root BDS dangles, and we're prone to
      crash when the memory gets reused.
      
      Commit d22b2f41 fixed that by hiding the root BDS instead of destroying
      it.  Destruction only happens on unplug.  "Hiding" means removing it
      from bdrv_states and graph_bdrv_states; see bdrv_make_anon().
      
      This "destroy on revoke" is a misfeature we don't want to carry
      forward to blockdev-add, just like "destroy on unplug" (commit
      2d246f01).  So make drive_del fail on anything added with blockdev-add.
      
      We'll add separate QMP commands to revoke device model access and to
      destroy backends.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      48f364dd
  7. 08 9月, 2014 1 次提交
  8. 29 8月, 2014 2 次提交
  9. 20 8月, 2014 2 次提交
    • S
      block: acquire AioContext in qmp_block_resize() · 927e0e76
      Stefan Hajnoczi 提交于
      Make block_resize safe for dataplane where another thread may be running
      the BlockDriverState's AioContext.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      927e0e76
    • M
      block: Use g_new() & friends where that makes obvious sense · 5839e53b
      Markus Armbruster 提交于
      g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
      for two reasons.  One, it catches multiplication overflowing size_t.
      Two, it returns T * rather than void *, which lets the compiler catch
      more type errors.
      
      Patch created with Coccinelle, with two manual changes on top:
      
      * Add const to bdrv_iterate_format() to keep the types straight
      
      * Convert the allocation in bdrv_drop_intermediate(), which Coccinelle
        inexplicably misses
      
      Coccinelle semantic patch:
      
          @@
          type T;
          @@
          -g_malloc(sizeof(T))
          +g_new(T, 1)
          @@
          type T;
          @@
          -g_try_malloc(sizeof(T))
          +g_try_new(T, 1)
          @@
          type T;
          @@
          -g_malloc0(sizeof(T))
          +g_new0(T, 1)
          @@
          type T;
          @@
          -g_try_malloc0(sizeof(T))
          +g_try_new0(T, 1)
          @@
          type T;
          expression n;
          @@
          -g_malloc(sizeof(T) * (n))
          +g_new(T, n)
          @@
          type T;
          expression n;
          @@
          -g_try_malloc(sizeof(T) * (n))
          +g_try_new(T, n)
          @@
          type T;
          expression n;
          @@
          -g_malloc0(sizeof(T) * (n))
          +g_new0(T, n)
          @@
          type T;
          expression n;
          @@
          -g_try_malloc0(sizeof(T) * (n))
          +g_try_new0(T, n)
          @@
          type T;
          expression p, n;
          @@
          -g_realloc(p, sizeof(T) * (n))
          +g_renew(T, p, n)
          @@
          type T;
          expression p, n;
          @@
          -g_try_realloc(p, sizeof(T) * (n))
          +g_try_renew(T, p, n)
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NJeff Cody <jcody@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5839e53b