1. 01 3月, 2017 21 次提交
  2. 28 2月, 2017 1 次提交
  3. 27 2月, 2017 3 次提交
  4. 25 2月, 2017 3 次提交
  5. 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
  6. 23 2月, 2017 1 次提交
  7. 21 2月, 2017 3 次提交