1. 08 6月, 2016 2 次提交
  2. 12 5月, 2016 3 次提交
    • E
      block: Honor BDRV_REQ_FUA during write_zeroes · 465fe887
      Eric Blake 提交于
      The block layer has a couple of cases where it can lose
      Force Unit Access semantics when writing a large block of
      zeroes, such that the request returns before the zeroes
      have been guaranteed to land on underlying media.
      
      SCSI does not support FUA during WRITESAME(10/16); FUA is only
      supported if it falls back to WRITE(10/16).  But where the
      underlying device is new enough to not need a fallback, it
      means that any upper layer request with FUA semantics was
      silently ignoring BDRV_REQ_FUA.
      
      Conversely, NBD has situations where it can support FUA but not
      ZERO_WRITE; when that happens, the generic block layer fallback
      to bdrv_driver_pwritev() (or the older bdrv_co_writev() in qemu
      2.6) was losing the FUA flag.
      
      The problem of losing flags unrelated to ZERO_WRITE has been
      latent in bdrv_co_do_write_zeroes() since commit aa7bfbff, but
      back then, it did not matter because there was no FUA flag.  It
      became observable when commit 93f5e6d8 paved the way for flags
      that can impact correctness, when we should have been using
      bdrv_co_writev_flags() with modified flags.  Compare to commit
      9eeb6dd1, which got flag manipulation right in
      bdrv_co_do_zero_pwritev().
      
      Symptoms: I tested with qemu-io with default writethrough cache
      (which is supposed to use FUA semantics on every write), and
      targetted an NBD client connected to a server that intentionally
      did not advertise NBD_FLAG_SEND_FUA.  When doing 'write 0 512',
      the NBD client sent two operations (NBD_CMD_WRITE then
      NBD_CMD_FLUSH) to get the fallback FUA semantics; but when doing
      'write -z 0 512', the NBD client sent only NBD_CMD_WRITE.
      
      The fix is do to a cleanup bdrv_co_flush() at the end of the
      operation if any step in the middle relied on a BDS that does
      not natively support FUA for that step (note that we don't
      need to flush after every operation, if the operation is broken
      into chunks based on bounce-buffer sizing).  Each BDS gains a
      new flag .supported_zero_flags, which parallels the use of
      .supported_write_flags but only when accessing a zero write
      operation (the flags MUST be different, because of SCSI having
      different semantics based on WRITE vs. WRITESAME; and also
      because BDRV_REQ_MAY_UNMAP only makes sense on zero writes).
      
      Also fix some documentation to describe -ENOTSUP semantics,
      particularly since iscsi depends on those semantics.
      
      Down the road, we may want to add a driver where its
      .bdrv_co_pwritev() honors all three of BDRV_REQ_FUA,
      BDRV_REQ_ZERO_WRITE, and BDRV_REQ_MAY_UNMAP, and advertise
      this via bs->supported_write_flags for blocks opened by that
      driver; such a driver should NOT supply .bdrv_co_write_zeroes
      nor .supported_zero_flags.  But none of the drivers touched
      in this patch want to do that (the act of writing zeroes is
      different enough from normal writes to deserve a second
      callback).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      465fe887
    • P
      linux-aio: make it more type safe · dd7f7ed1
      Paolo Bonzini 提交于
      Replace void* with an opaque LinuxAioState type.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      dd7f7ed1
    • P
      block: plug whole tree at once, introduce bdrv_io_unplugged_begin/end · 6b98bd64
      Paolo Bonzini 提交于
      Extract the handling of io_plug "depth" from linux-aio.c and let the
      main bdrv_drain loop do nothing but wait on I/O.
      
      Like the two newly introduced functions, bdrv_io_plug and bdrv_io_unplug
      now operate on all children.  The visit order is now symmetrical between
      plug and unplug, making it possible for formats to implement plug/unplug.
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6b98bd64
  3. 30 3月, 2016 1 次提交
  4. 23 3月, 2016 2 次提交
    • V
      util: move declarations out of qemu-common.h · f348b6d1
      Veronia Bahaa 提交于
      Move declarations out of qemu-common.h for functions declared in
      utils/ files: e.g. include/qemu/path.h for utils/path.c.
      Move inline functions out of qemu-common.h and into new files (e.g.
      include/qemu/bcd.h)
      Signed-off-by: NVeronia Bahaa <veroniabahaa@gmail.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f348b6d1
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  5. 03 2月, 2016 2 次提交
  6. 20 1月, 2016 2 次提交
  7. 18 12月, 2015 1 次提交
  8. 17 12月, 2015 1 次提交
    • E
      qapi: Don't let implicit enum MAX member collide · 7fb1cf16
      Eric Blake 提交于
      Now that we guarantee the user doesn't have any enum values
      beginning with a single underscore, we can use that for our
      own purposes.  Renaming ENUM_MAX to ENUM__MAX makes it obvious
      that the sentinel is generated.
      
      This patch was mostly generated by applying a temporary patch:
      
      |diff --git a/scripts/qapi.py b/scripts/qapi.py
      |index e6d014b..b862ec9 100644
      |--- a/scripts/qapi.py
      |+++ b/scripts/qapi.py
      |@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = {
      |     max_index = c_enum_const(name, 'MAX', prefix)
      |     ret += mcgen('''
      |     [%(max_index)s] = NULL,
      |+// %(max_index)s
      | };
      | ''',
      |                max_index=max_index)
      
      then running:
      
      $ cat qapi-{types,event}.c tests/test-qapi-types.c |
          sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list
      $ git grep -l _MAX | xargs sed -i -f list
      
      The only things not generated are the changes in scripts/qapi.py.
      
      Rejecting enum members named 'MAX' is now useless, and will be dropped
      in the next patch.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      [Rebased to current master, commit message tweaked]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      7fb1cf16
  9. 25 11月, 2015 1 次提交
  10. 12 11月, 2015 1 次提交
  11. 24 10月, 2015 2 次提交
  12. 16 10月, 2015 1 次提交
  13. 12 10月, 2015 1 次提交
  14. 02 10月, 2015 1 次提交
  15. 05 9月, 2015 1 次提交
    • M
      block/raw-posix: Use raw_normalize_devicepath() · bdd03cdf
      Max Reitz 提交于
      The filename given to qemu_open() in block/raw-posix.c should generally
      have been processed by raw_normalize_devicepath(); unless we are only
      probing (in which case the caller often checks whether the file is a
      block device or not, and this property will be changed by
      raw_normalize_devicepath() on NetBSD) or it is about a deprecated device
      (i.e. floppy).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      bdd03cdf
  16. 07 7月, 2015 1 次提交
    • R
      block/raw-posix: Don't think /dev/fd/<NN> is a floppy drive. · 25d9747b
      Richard W.M. Jones 提交于
      In libguestfs we use /dev/fd/<NN> to pass pre-opened file descriptors
      to qemu-img.  Lately I've discovered that although this works, qemu
      believes that these are floppy disk images.  That in itself isn't much
      of a problem, but now qemu prints a warning about host floppy
      pass-thru being deprecated.
      
      Extend the existing test so that it ignores /dev/fd/ as well as
      /dev/fdset/
      
      A simple test of this, if you are using the bash shell, is:
      
        qemu-img info <( cat /dev/null )
      
      without this patch:
      
        $ qemu-img info <( cat /dev/null )
        qemu-img: Host floppy pass-through is deprecated
        Support for it will be removed in a future release.
        qemu-img: Could not open '/dev/fd/63': Could not refresh total sector count: Illegal seek
      
      with this patch:
      
        $ qemu-img info <( cat /dev/null )
        qemu-img: Could not open '/dev/fd/63': Could not refresh total sector count: Illegal seek
      Signed-off-by: NRichard W.M. Jones <rjones@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-id: 1435761614-31358-1-git-send-email-rjones@redhat.com
      Fixes: https://bugs.launchpad.net/qemu/+bug/1470536Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      25d9747b
  17. 23 6月, 2015 5 次提交
  18. 12 6月, 2015 2 次提交
  19. 22 5月, 2015 2 次提交
    • D
      block: align bounce buffers to page · 459b4e66
      Denis V. Lunev 提交于
      The following sequence
          int fd = open(argv[1], O_RDWR | O_CREAT | O_DIRECT, 0644);
          for (i = 0; i < 100000; i++)
                  write(fd, buf, 4096);
      performs 5% better if buf is aligned to 4096 bytes.
      
      The difference is quite reliable.
      
      On the other hand we do not want at the moment to enforce bounce
      buffering if guest request is aligned to 512 bytes.
      
      The patch changes default bounce buffer optimal alignment to
      MAX(page size, 4k). 4k is chosen as maximal known sector size on real
      HDD.
      
      The justification of the performance improve is quite interesting.
      From the kernel point of view each request to the disk was split
      by two. This could be seen by blktrace like this:
        9,0   11  1     0.000000000 11151  Q  WS 312737792 + 1023 [qemu-img]
        9,0   11  2     0.000007938 11151  Q  WS 312738815 + 8 [qemu-img]
        9,0   11  3     0.000030735 11151  Q  WS 312738823 + 1016 [qemu-img]
        9,0   11  4     0.000032482 11151  Q  WS 312739839 + 8 [qemu-img]
        9,0   11  5     0.000041379 11151  Q  WS 312739847 + 1016 [qemu-img]
        9,0   11  6     0.000042818 11151  Q  WS 312740863 + 8 [qemu-img]
        9,0   11  7     0.000051236 11151  Q  WS 312740871 + 1017 [qemu-img]
        9,0    5  1     0.169071519 11151  Q  WS 312741888 + 1023 [qemu-img]
      After the patch the pattern becomes normal:
        9,0    6  1     0.000000000 12422  Q  WS 314834944 + 1024 [qemu-img]
        9,0    6  2     0.000038527 12422  Q  WS 314835968 + 1024 [qemu-img]
        9,0    6  3     0.000072849 12422  Q  WS 314836992 + 1024 [qemu-img]
        9,0    6  4     0.000106276 12422  Q  WS 314838016 + 1024 [qemu-img]
      and the amount of requests sent to disk (could be calculated counting
      number of lines in the output of blktrace) is reduced about 2 times.
      
      Both qemu-img and qemu-io are affected while qemu-kvm is not. The guest
      does his job well and real requests comes properly aligned (to page).
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Message-id: 1431441056-26198-3-git-send-email-den@openvz.org
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: Kevin Wolf <kwolf@redhat.com>
      CC: Stefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      459b4e66
    • D
      block: minimal bounce buffer alignment · 4196d2f0
      Denis V. Lunev 提交于
      The patch introduces new concept: minimal memory alignment for bounce
      buffers. Original so called "optimal" value is actually minimal required
      value for aligment. It should be used for validation that the IOVec
      is properly aligned and bounce buffer is not required.
      
      Though, from the performance point of view, it would be better if
      bounce buffer or IOVec allocated by QEMU will be aligned stricter.
      
      The patch does not change any alignment value yet.
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Message-id: 1431441056-26198-2-git-send-email-den@openvz.org
      CC: Paolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      CC: Stefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      4196d2f0
  20. 19 3月, 2015 2 次提交
  21. 10 3月, 2015 3 次提交
  22. 09 3月, 2015 1 次提交
    • D
      block/raw-posix: fix compilation warning on OSX · a6dcf097
      Denis V. Lunev 提交于
      block/raw-posix.c:947:19: warning: unused variable 's' [-Wunused-variable]
          BDRVRawState *s = aiocb->bs->opaque;
      
      This variable is used only when on of the following macros are defined
      CONFIG_XFS, CONFIG_FALLOCATE, CONFIG_FALLOCATE_PUNCH_HOLE or
      CONFIG_FALLOCATE_ZERO_RANGE. Fortunately, CONFIG_FALLOCATE_PUNCH_HOLE
      and CONFIG_FALLOCATE_ZERO_RANGE could be defined only along with
      CONFIG_FALLOCATE. Therefore checking for CONFIG_XFS or CONFIG_FALLOCATE
      would be enough.
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      CC: Peter Maydell <peter.maydell@linaro.org>
      CC: Kevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a6dcf097
  23. 16 2月, 2015 1 次提交
  24. 07 2月, 2015 1 次提交