1. 27 2月, 2017 3 次提交
  2. 25 2月, 2017 3 次提交
  3. 24 2月, 2017 8 次提交
    • K
      vvfat: Use opened node as backing file · a8a4d15c
      Kevin Wolf 提交于
      We should not try to assign a not yet opened node as the backing file,
      because as soon as the permission system is added it will fail.  The
      just added bdrv_new_open_driver() function is the right tool to open a
      file with an internal driver, use it.
      
      In case anyone wonders whether that magic fake backing file to trigger a
      special action on 'commit' actually works today: No, not for me. One
      reason is that we've been adding a raw format driver on top for several
      years now and raw doesn't support commit. Other reasons include that the
      backing file isn't writable and the driver doesn't support reopen, and
      it's also size 0 and the driver doesn't support bdrv_truncate. All of
      these are easily fixable, but then 'commit' ended up in an infinite loop
      deep in the vvfat code for me, so I thought I'd best leave it alone. I'm
      not really sure what it was supposed to do anyway.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      a8a4d15c
    • K
      block: Attach bs->file only during .bdrv_open() · 4e4bf5c4
      Kevin Wolf 提交于
      The way that attaching bs->file worked was a bit unusual in that it was
      the only child that would be attached to a node which is not opened yet.
      Because of this, the block layer couldn't know yet which permissions the
      driver would eventually need.
      
      This patch moves the point where bs->file is attached to the beginning
      of the individual .bdrv_open() implementations, so drivers already know
      what they are going to do with the child. This is also more consistent
      with how driver-specific children work.
      
      For a moment, bdrv_open() gets its own BdrvChild to perform image
      probing, but instead of directly assigning this BdrvChild to the BDS, it
      becomes a temporary one and the node name is passed as an option to the
      drivers, so that they can simply use bdrv_open_child() to create another
      reference for their own use.
      
      This duplicated child for (the not opened yet) bs is not the final
      state, a follow-up patch will change the image probing code to use a
      BlockBackend, which is completely independent of bs.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      4e4bf5c4
    • K
      block: Pass BdrvChild to bdrv_truncate() · 52cdbc58
      Kevin Wolf 提交于
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      52cdbc58
    • K
      mirror: Resize active commit base in mirror_run() · becc347e
      Kevin Wolf 提交于
      This is more consistent with the commit block job, and it moves the code
      to a place where we already have the necessary BlockBackends to resize
      the base image when bdrv_truncate() is changed to require a BdrvChild.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      becc347e
    • K
      qcow2: Use BB for resizing in qcow2_amend_options() · 70b27f36
      Kevin Wolf 提交于
      In order to able to convert bdrv_truncate() to take a BdrvChild and
      later to correctly check the resize permission here, we need to use a
      BlockBackend for resizing the image.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      70b27f36
    • N
      qemu-img: Improve documentation for PREALLOC_MODE_FALLOC · c6ccc2c5
      Nir Soffer 提交于
      Now that we are truncating the file in both PREALLOC_MODE_FULL and
      PREALLOC_MODE_OFF, not truncating in PREALLOC_MODE_FALLOC looks odd.
      Add a comment explaining why we do not truncate in this case.
      Signed-off-by: NNir Soffer <nirsof@gmail.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c6ccc2c5
    • N
      qemu-img: Truncate before full preallocation · 5a1dad9d
      Nir Soffer 提交于
      In a previous commit (qemu-img: Do not truncate before preallocation) we
      moved truncate to the PREALLOC_MODE_OFF branch to avoid slowdown in
      posix_fallocate().
      
      However this change is not optimal when using PREALLOC_MODE_FULL, since
      knowing the final size from the beginning could allow the file system
      driver to do less allocations and possibly avoid fragmentation of the
      file.
      
      Now we truncate also before doing full preallocation.
      Signed-off-by: NNir Soffer <nirsof@gmail.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5a1dad9d
    • N
      qemu-img: Do not truncate before preallocation · f6a72404
      Nir Soffer 提交于
      When using file system that does not support fallocate() (e.g. NFS <
      4.2), truncating the file only when preallocation=OFF speeds up creating
      raw file.
      
      Here is example run, tested on Fedora 24 machine, creating raw file on
      NFS version 3 server.
      
      $ time ./qemu-img-master create -f raw -o preallocation=falloc mnt/test 1g
      Formatting 'mnt/test', fmt=raw size=1073741824 preallocation=falloc
      
      real	0m21.185s
      user	0m0.022s
      sys	0m0.574s
      
      $ time ./qemu-img-fix create -f raw -o preallocation=falloc mnt/test 1g
      Formatting 'mnt/test', fmt=raw size=1073741824 preallocation=falloc
      
      real	0m11.601s
      user	0m0.016s
      sys	0m0.525s
      
      $ time dd if=/dev/zero of=mnt/test bs=1M count=1024 oflag=direct
      1024+0 records in
      1024+0 records out
      1073741824 bytes (1.1 GB, 1.0 GiB) copied, 15.6627 s, 68.6 MB/s
      
      real	0m16.104s
      user	0m0.009s
      sys	0m0.220s
      
      Running with strace we can see that without this change we do one
      pread() and one pwrite() for each block. With this change, we do only
      one pwrite() per block.
      
      $ strace ./qemu-img-master create -f raw -o preallocation=falloc mnt/test 8192
      ...
      pread64(9, "\0", 1, 4095)               = 1
      pwrite64(9, "\0", 1, 4095)              = 1
      pread64(9, "\0", 1, 8191)               = 1
      pwrite64(9, "\0", 1, 8191)              = 1
      
      $ strace ./qemu-img-fix create -f raw -o preallocation=falloc mnt/test 8192
      ...
      pwrite64(9, "\0", 1, 4095)              = 1
      pwrite64(9, "\0", 1, 8191)              = 1
      
      This happens because posix_fallocate is checking if each block is
      allocated before writing a byte to the block, and when truncating the
      file before preallocation, all blocks are unallocated.
      Signed-off-by: NNir Soffer <nirsof@gmail.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f6a72404
  4. 23 2月, 2017 1 次提交
  5. 21 2月, 2017 17 次提交
  6. 12 2月, 2017 7 次提交
    • A
      qcow2: Optimize the refcount-block overlap check · 7061a078
      Alberto Garcia 提交于
      The metadata overlap checks introduced in a40f1c2a help detect
      corruption in the qcow2 image by verifying that data writes don't
      overlap with existing metadata sections.
      
      The 'refcount-block' check in particular iterates over the refcount
      table in order to get the addresses of all refcount blocks and check
      that none of them overlap with the region where we want to write.
      
      The problem with the refcount table is that since it always occupies
      complete clusters its size is usually very big. With the default
      values of cluster_size=64KB and refcount_bits=16 this table holds 8192
      entries, each one of them enough to map 2GB worth of host clusters.
      
      So unless we're using images with several TB of allocated data this
      table is going to be mostly empty, and iterating over it is a waste of
      CPU. If the storage backend is fast enough this can have an effect on
      I/O performance.
      
      This patch keeps the index of the last used (i.e. non-zero) entry in
      the refcount table and updates it every time the table changes. The
      refcount-block overlap check then uses that index instead of reading
      the whole table.
      
      In my tests with a 4GB qcow2 file stored in RAM this doubles the
      amount of write IOPS.
      Signed-off-by: NAlberto Garcia <berto@igalia.com>
      Message-id: 20170201123828.4815-1-berto@igalia.com
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      7061a078
    • P
      block/nfs: fix naming of runtime opts · f67409a5
      Peter Lieven 提交于
      commit 94d6a7a7 accidentally left the naming of runtime opts and QAPI
      scheme inconsistent. As one consequence passing of parameters in the
      URI is broken. Sync the naming of the runtime opts to the QAPI
      scheme.
      
      Please note that this is technically backwards incompatible with the 2.8
      release, but the 2.8 release is the only version that had the wrong naming.
      Furthermore release 2.8 suffered from a NULL pointer dereference during
      URI parsing.
      
      Fixes: 94d6a7a7
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Message-id: 1485942829-10756-3-git-send-email-pl@kamp.de
      [mreitz: Fixed commit message]
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      f67409a5
    • P
      block/nfs: fix NULL pointer dereference in URI parsing · 8d20abe8
      Peter Lieven 提交于
      parse_uint_full wants to put the parsed value into the
      variable passed via its second argument which is NULL.
      
      Fixes: 94d6a7a7
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 1485942829-10756-2-git-send-email-pl@kamp.de
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      8d20abe8
    • D
      block/qapi: reduce the execution time of qmp_query_blockstats · a6baa608
      Dou Liyang 提交于
      In order to reduce the execution time, this patch optimize
      the qmp_query_blockstats():
      Remove the next_query_bds function.
      Remove the bdrv_query_stats function.
      Remove some judgement sentence.
      
      The original qmp_query_blockstats calls next_query_bds to get
      the next objects in each loops. In the next_query_bds, it checks
      the query_nodes and blk. It also call bdrv_query_stats to get
      the stats, In the bdrv_query_stats, it checks blk and bs each
      times. This waste more times, which may stall the main loop a
      bit. And if the disk is too many and donot use the dataplane
      feature, this may affect the performance in main loop thread.
      
      This patch removes that two functions, and makes the structure
      clearly.
      Signed-off-by: NDou Liyang <douly.fnst@cn.fujitsu.com>
      Message-id: 1484467275-27919-3-git-send-email-douly.fnst@cn.fujitsu.com
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [mreitz: Removed duplicate info->value assignment]
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      a6baa608
    • D
      block/qapi: reduce the coupling between the bdrv_query_stats and bdrv_query_bds_stats · 20a6d768
      Dou Liyang 提交于
      The bdrv_query_stats and bdrv_query_bds_stats functions need to call
      each other, that increases the coupling. it also makes the program
      complicated and makes some unnecessary tests.
      
      Remove the call from bdrv_query_bds_stats to bdrv_query_stats, just
      take some recursion to make it clearly.
      
      Avoid testing whether the blk is NULL during querying the bds stats.
      It is unnecessary.
      Signed-off-by: NDou Liyang <douly.fnst@cn.fujitsu.com>
      Message-id: 1484467275-27919-2-git-send-email-douly.fnst@cn.fujitsu.com
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      20a6d768
    • Q
      block/vmdk: Fix the endian problem of buf_len and lba · 4545d4f4
      QingFeng Hao 提交于
      The problem was triggered by qemu-iotests case 055. It failed when it
      was comparing the compressed vmdk image with original test.img.
      
      The cause is that buf_len in vmdk_write_extent wasn't converted to
      little-endian before it was stored to disk. But later vmdk_read_extent
      read it and converted it from little-endian to cpu endian.
      If the cpu is big-endian like s390, the problem will happen and
      the data length read by vmdk_read_extent will become invalid!
      The fix is to add the conversion in vmdk_write_extent, meanwhile,
      repair the endianness problem of lba field which shall also be converted
      to little-endian before storing to disk.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NQingFeng Hao <haoqf@linux.vnet.ibm.com>
      Signed-off-by: NJing Liu <liujbjl@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Message-id: 20161216052040.53067-2-haoqf@linux.vnet.ibm.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      4545d4f4
    • F
      qapi: Tweak error message of bdrv_query_image_info · 9adceb02
      Fam Zheng 提交于
      @bs doesn't always have a device name, such as when it comes from
      "qemu-img info". Report file name instead.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Message-id: 20170119130759.28319-2-famz@redhat.com
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      9adceb02
  7. 01 2月, 2017 1 次提交