Comment 5 for bug 2025591

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Tests with the incremental debug patch (below)
to determine which scenarios have any changes
with the fix patch applied:

Results:

The only behavior change occurs with the HWE/6.2 kernel
when the 4096-bytes size is used in the host.

To be clear, only the *broken* case changed, and is now *fixed*:

 GA/5.15 kernel, 512 bytes: old = 512, new = 512 (no change)
 GA/5.15 kernel, 4096 bytes: old = 4096, new = 4096 (no change)

 HWE/6.2 kernel, 512 bytes: old = 512, new = 512 (no change)
 HWE/6.2 kernel, 4096 bytes: old = 512, new = 4096 (changed; fixed)

More details below.

Debug patch:
(qemu trace event showing the old/new value changed by [1])

 $ quilt diff
 Index: qemu-6.2+dfsg/block/io.c
 ===================================================================
 --- qemu-6.2+dfsg.orig/block/io.c
 +++ qemu-6.2+dfsg/block/io.c
 @@ -3244,6 +3244,8 @@ bool bdrv_qiov_is_aligned(BlockDriverSta
      size_t alignment = bdrv_min_mem_align(bs);
      size_t len = bs->bl.request_alignment;

 + trace_bdrv_qiov_is_aligned(alignment, len);
 +
      for (i = 0; i < qiov->niov; i++) {
   if ((uintptr_t) qiov->iov[i].iov_base % alignment) {
       return false;
 Index: qemu-6.2+dfsg/block/trace-events
 ===================================================================
 --- qemu-6.2+dfsg.orig/block/trace-events
 +++ qemu-6.2+dfsg/block/trace-events
 @@ -14,6 +14,7 @@ blk_root_detach(void *child, void *blk,
  bdrv_co_preadv_part(void *bs, int64_t offset, int64_t bytes, unsigned int flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x"
  bdrv_co_pwritev_part(void *bs, int64_t offset, int64_t bytes, unsigned int flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x"
  bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int64_t bytes, int flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x"
 +bdrv_qiov_is_aligned(size_t alignment, size_t len) "alignment %zu len %zu"
  bdrv_co_do_copy_on_readv(void *bs, int64_t offset, int64_t bytes, int64_t cluster_offset, int64_t cluster_bytes) "bs %p offset %" PRId64 " bytes %" PRId64 " cluster_offset %" PRId64 " cluster_bytes %" PRId64
  bdrv_co_copy_range_from(void *src, int64_t src_offset, void *dst, int64_t dst_offset, int64_t bytes, int read_flags, int write_flags) "src %p offset %" PRId64 " dst %p offset %" PRId64 " bytes %" PRId64 " rw flags 0x%x 0x%x"
  bdrv_co_copy_range_to(void *src, int64_t src_offset, void *dst, int64_t dst_offset, int64_t bytes, int read_flags, int write_flags) "src %p offset %" PRId64 " dst %p offset %" PRId64 " bytes %" PRId64 " rw flags 0x%x 0x%x"

Testing:

 # qemu-system-x86_64 -trace help | grep bdrv_qiov_is_aligned
 bdrv_qiov_is_aligned

Details:

GA/5.15 kernel, 512 bytes: old = 512, new = 512.

 # uname -r
 5.15.0-1035-kvm

 # LOOPDEV=$(losetup --find --show jammy.raw)
 # qemu-system-x86_64 -drive file=$LOOPDEV,format=raw,cache=none -boot order=c -nodefaults -no-user-config -nographic -serial stdio -enable-kvm \
   -trace bdrv_qiov_is_aligned 2>&1 | tee qemu-5.15-512.log
 ...

 # grep 'login:' qemu-5.15-512.log
  login: bdrv_qiov_is_aligned alignment 512 len 512

 # cat qemu-5.15-512.log | grep -o 'bdrv_qiov_is_aligned alignment [0-9]\+ len [0-9]\+' | sort -u
 bdrv_qiov_is_aligned alignment 512 len 512

GA/5.15 kernel, 4096 bytes: old = 4096, new = 4096.

 # uname -r
 5.15.0-1035-kvm

 # losetup -d $LOOPDEV
 # LOOPDEV=$(losetup --find --show --sector-size 4096 jammy.raw)
 # qemu-system-x86_64 -drive file=$LOOPDEV,format=raw,cache=none -boot order=c -nodefaults -no-user-config -nographic -serial stdio -enable-kvm -trace bdrv_qiov_is_aligned 2>&1 | tee qemu-5.15-4096.log
 ...

 # grep 'login:' qemu-5.15-4096.log
 ubuntu login: bdrv_qiov_is_aligned alignment 4096 len 4096

 # cat qemu-5.15-4096.log | grep -o 'bdrv_qiov_is_aligned alignment [0-9]\+ len [0-9]\+' | sort -u
 bdrv_qiov_is_aligned alignment 4096 len 4096

HWE/6.2 kernel, 512 bytes: old = 512, new = 512.

 # uname -r
 6.2.0-23-generic

 # LOOPDEV=$(losetup --find --show jammy.raw)
 # qemu-system-x86_64 -drive file=$LOOPDEV,format=raw,cache=none -boot order=c -nodefaults -no-user-config -nographic -serial stdio -enable-kvm -trace bdrv_qiov_is_aligned 2>&1 | tee qemu-6.2-512.log

 # grep 'login:' qemu-6.2-512.log
  login: bdrv_qiov_is_aligned alignment 512 len 512

 # cat qemu-6.2-512.log | grep -o 'bdrv_qiov_is_aligned alignment [0-9]\+ len [0-9]\+' | sort -u
 bdrv_qiov_is_aligned alignment 512 len 512

HWE/6.2 kernel, 4096 bytes: old = 512, new = 4096.

 # uname -r
 6.2.0-23-generic

 # losetup -d $LOOPDEV
 # LOOPDEV=$(losetup --find --show --sector-size 4096 jammy.raw)
 # qemu-system-x86_64 -drive file=$LOOPDEV,format=raw,cache=none -boot order=c -nodefaults -no-user-config -nographic -serial stdio -enable-kvm -trace bdrv_qiov_is_aligned 2>&1 | tee qemu-6.2-4096.log
 ...

 # grep 'login:' qemu-6.2-4096.log
  login: bdrv_qiov_is_aligned alignment 512 len 4096

 # cat qemu-6.2-4096.log | grep -o 'bdrv_qiov_is_aligned alignment [0-9]\+ len [0-9]\+' | sort -u
 bdrv_qiov_is_aligned alignment 512 len 4096