1. 19 5月, 2020 2 次提交
  2. 06 1月, 2020 1 次提交
    • M
      blkdebug: Allow taking/unsharing permissions · 69c6449f
      Max Reitz 提交于
      Sometimes it is useful to be able to add a node to the block graph that
      takes or unshare a certain set of permissions for debugging purposes.
      This patch adds this capability to blkdebug.
      
      (Note that you cannot make blkdebug release or share permissions that it
      needs to take or cannot share, because this might result in assertion
      failures in the block layer.  But if the blkdebug node has no parents,
      it will not take any permissions and share everything by default, so you
      can then freely choose what permissions to take and share.)
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20191108123455.39445-4-mreitz@redhat.com
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      69c6449f
  3. 14 6月, 2019 3 次提交
  4. 26 3月, 2019 1 次提交
  5. 25 2月, 2019 2 次提交
    • M
      block: Purify .bdrv_refresh_filename() · 998b3a1e
      Max Reitz 提交于
      Currently, BlockDriver.bdrv_refresh_filename() is supposed to both
      refresh the filename (BDS.exact_filename) and set BDS.full_open_options.
      Now that we have generic code in the central bdrv_refresh_filename() for
      creating BDS.full_open_options, we can drop the latter part from all
      BlockDriver.bdrv_refresh_filename() implementations.
      
      This also means that we can drop all of the existing default code for
      this from the global bdrv_refresh_filename() itself.
      
      Furthermore, we now have to call BlockDriver.bdrv_refresh_filename()
      after having set BDS.full_open_options, because the block driver's
      implementation should now be allowed to depend on BDS.full_open_options
      being set correctly.
      
      Finally, with this patch we can drop the @options parameter from
      BlockDriver.bdrv_refresh_filename(); also, add a comment on this
      function's purpose in block/block_int.h while touching its interface.
      
      This completely obsoletes blklogwrite's implementation of
      .bdrv_refresh_filename().
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20190201192935.18394-25-mreitz@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      998b3a1e
    • M
      block: Add strong_runtime_opts to BlockDriver · 2654267c
      Max Reitz 提交于
      This new field can be set by block drivers to list the runtime options
      they accept that may influence the contents of the respective BDS. As of
      a follow-up patch, this list will be used by the common
      bdrv_refresh_filename() implementation to decide which options to put
      into BDS.full_open_options (and consequently whether a JSON filename has
      to be created), thus freeing the drivers of having to implement that
      logic themselves.
      
      Additionally, this patch adds the field to all of the block drivers that
      need it and sets it accordingly.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Message-id: 20190201192935.18394-22-mreitz@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      2654267c
  6. 28 7月, 2018 1 次提交
  7. 10 7月, 2018 1 次提交
    • F
      block: Use BdrvChild to discard · 0b9fd3f4
      Fam Zheng 提交于
      Other I/O functions are already using a BdrvChild pointer in the API, so
      make discard do the same. It makes it possible to initiate the same
      permission checks before doing I/O, and much easier to share the
      helper functions for this, which will be added and used by write,
      truncate and copy range paths.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0b9fd3f4
  8. 15 5月, 2018 1 次提交
    • M
      block: Support BDRV_REQ_WRITE_UNCHANGED in filters · 228345bf
      Max Reitz 提交于
      Update the rest of the filter drivers to support
      BDRV_REQ_WRITE_UNCHANGED.  They already forward write request flags to
      their children, so we just have to announce support for it.
      
      This patch does not cover the replication driver because that currently
      does not support flags at all, and because it just grabs the WRITE
      permission for its children when it can, so we should be fine just
      submitting the incoming WRITE_UNCHANGED requests as normal writes.
      
      It also does not cover format drivers for similar reasons.  They all use
      bdrv_format_default_perms() as their .bdrv_child_perm() implementation
      so they just always grab the WRITE permission for their file children
      whenever possible.  In addition, it often would be difficult to
      ascertain whether incoming unchanging writes end up as unchanging writes
      in their files.  So we just leave them as normal potentially changing
      writes.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Message-id: 20180421132929.21610-7-mreitz@redhat.com
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      228345bf
  9. 04 5月, 2018 2 次提交
  10. 03 3月, 2018 1 次提交
  11. 09 2月, 2018 2 次提交
  12. 26 10月, 2017 1 次提交
    • 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
  13. 10 10月, 2017 1 次提交
  14. 05 9月, 2017 2 次提交
  15. 04 9月, 2017 3 次提交
  16. 11 7月, 2017 2 次提交
  17. 10 7月, 2017 1 次提交
  18. 26 6月, 2017 2 次提交
  19. 20 6月, 2017 1 次提交
  20. 11 5月, 2017 5 次提交
    • E
      blkdebug: Add ability to override unmap geometries · 430b26a8
      Eric Blake 提交于
      Make it easier to simulate various unusual hardware setups (for
      example, recent commits 3482b9bc and b8d0a980 affect the Dell
      Equallogic iSCSI with its 15M preferred and maximum unmap and
      write zero sizing, or b2f95fee deals with the Linux loopback
      block device having a max_transfer of 64k), by allowing blkdebug
      to wrap any other device with further restrictions on various
      alignments.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20170429191419.30051-9-eblake@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      430b26a8
    • E
      blkdebug: Simplify override logic · 3dc834f8
      Eric Blake 提交于
      Rather than store into a local variable, then copy to the struct
      if the value is valid, then reporting errors otherwise, it is
      simpler to just store into the struct and report errors if the
      value is invalid.  This however requires that the struct store
      a 64-bit number, rather than a narrower type.  Likewise, setting
      a sane errno value in ret prior to the sequence of parsing and
      jumping to out: on error makes it easier for the next patch to
      add a chain of similar checks.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-id: 20170429191419.30051-8-eblake@redhat.com
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      3dc834f8
    • E
      blkdebug: Add pass-through write_zero and discard support · 63188c24
      Eric Blake 提交于
      In order to test the effects of artificial geometry constraints
      on operations like write zero or discard, we first need blkdebug
      to manage these actions.  It also allows us to inject errors on
      those operations, just like we can for read/write/flush.
      
      We can also test the contract promised by the block layer; namely,
      if a device has specified limits on alignment or maximum size,
      then those limits must be obeyed (for now, the blkdebug driver
      merely inherits limits from whatever it is wrapping, but the next
      patch will further enhance it to allow specific limit overrides).
      
      This patch intentionally refuses to service requests smaller than
      the requested alignments; this is because an upcoming patch adds
      a qemu-iotest to prove that the block layer is correctly handling
      fragmentation, but the test only works if there is a way to tell
      the difference at artificial alignment boundaries when blkdebug is
      using a larger-than-default alignment.  If we let the blkdebug
      layer always defer to the underlying layer, which potentially has
      a smaller granularity, the iotest will be thwarted.
      
      Tested by setting up an NBD server with export 'foo', then invoking:
      $ ./qemu-io
      qemu-io> open -o driver=blkdebug blkdebug::nbd://localhost:10809/foo
      qemu-io> d 0 15M
      qemu-io> w -z 0 15M
      
      Pre-patch, the server never sees the discard (it was silently
      eaten by the block layer); post-patch it is passed across the
      wire.  Likewise, pre-patch the write is always passed with
      NBD_WRITE (with 15M of zeroes on the wire), while post-patch
      it can utilize NBD_WRITE_ZEROES (for less traffic).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20170429191419.30051-7-eblake@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      63188c24
    • E
      blkdebug: Refactor error injection · d157ed5f
      Eric Blake 提交于
      Rather than repeat the logic at each caller of checking if a Rule
      exists that warrants an error injection, fold that logic into
      inject_error(); and rename it to rule_check() for legibility.
      This will help the next patch, which adds two more callers that
      need to check rules for the potential of injecting errors.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20170429191419.30051-6-eblake@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      d157ed5f
    • E
      blkdebug: Sanity check block layer guarantees · e0ef4395
      Eric Blake 提交于
      Commits 04ed95f4 and 1a62d0ac updated the block layer to auto-fragment
      any I/O to fit within device boundaries. Additionally, when using a
      minimum alignment of 4k, we want to ensure the block layer does proper
      read-modify-write rather than requesting I/O on a slice of a sector.
      Let's enforce that the contract is obeyed when using blkdebug.  For
      now, blkdebug only allows alignment overrides, and just inherits other
      limits from whatever device it is wrapping, but a future patch will
      further enhance things.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20170429191419.30051-5-eblake@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      e0ef4395
  21. 09 5月, 2017 2 次提交
  22. 28 4月, 2017 2 次提交
  23. 27 4月, 2017 1 次提交
    • M
      block: Do not unref bs->file on error in BD's open · de234897
      Max Reitz 提交于
      The block layer takes care of removing the bs->file child if the block
      driver's bdrv_open()/bdrv_file_open() implementation fails. The block
      driver therefore does not need to do so, and indeed should not unless it
      sets bs->file to NULL afterwards -- because if this is not done, the
      bdrv_unref_child() in bdrv_open_inherit() will dereference the freed
      memory block at bs->file afterwards, which is not good.
      
      We can now decide whether to add a "bs->file = NULL;" after each of the
      offending bdrv_unref_child() invocations, or just drop them altogether.
      The latter is simpler, so let's do that.
      
      Cc: qemu-stable <qemu-stable@nongnu.org>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      de234897