Re: [PATCH v3 0/1] Patch to adjust coroutine pool size adaptively

2022-03-17 Thread Maxim Levitsky
Just FYI. As a workaround I reduced the virtio-blk queue-size to 16 and it seems to work again. I am only keeping this configuration to test that it boots thus performance is not an issue. Option to override the coroutine pool size would be ideal in this case IMHO though. Best regards, Maxim Levitsky

Re: [PATCH] qemu-img: Add -F shorthand to convert

2021-09-15 Thread Maxim Levitsky
t_img -b "$TEST_IMG".base -F $IMGFMT > > $QEMU_IO -c "write -P 0 0 3M" "$TEST_IMG" 2>&1 | _filter_qemu_io | > _filter_testdir > -$QEMU_IMG convert -O $IMGFMT -B "$TEST_IMG".base -o backing_fmt=$IMGFMT \ > +$QEMU_IMG convert -O $IMGFMT -B "$TEST_IMG".base -F $IMGFMT \ > "$TEST_IMG" "$TEST_IMG".orig > $QEMU_IO -c "read -P 0 0 3M" "$TEST_IMG".orig 2>&1 | _filter_qemu_io | > _filter_testdir > $QEMU_IMG convert -O $IMGFMT -c -B "$TEST_IMG".base -o backing_fmt=$IMGFMT \ I have seen that warning few times already in my scripts, so good to have this option. Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky

Re: [PATCH] block/nvme: Fix VFIO_MAP_DMA failed: No space left on device

2021-06-17 Thread Maxim Levitsky
OMEM and -ENOSPC and recycle the mappings in both cases? I think that would work on both old and new kernels. What do you think? Best regards, Maxim Levitsky > > Should I check uname(2)'s utsname.release[]? Is it reliable? > > > The block driver started to mis-beha

Re: [PATCH v4 2/7] scsi-generic: pass max_segments via max_iov field in BlockLimits

2021-06-09 Thread Maxim Levitsky
max iovec number. https://www.mail-archive.com/qemu-devel@nongnu.org/msg768264.html Best regards, Maxim Levitsky > } > } > > diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c > index 98c30c5d5c..82e1e2ee79 100644 > --- a/hw/scsi/scsi-generi

Re: [PATCH v4 4/7] file-posix: try BLKSECTGET on block devices too, do not round to power of 2

2021-06-09 Thread Maxim Levitsky
looks correct, but I might have missed something as well. This is roughly the same as patches from Tom Yan which I carried in my series https://www.mail-archive.com/qemu-devel@nongnu.org/msg768258.html https://www.mail-archive.com/qemu-devel@nongnu.org/msg768262.html I like a bit more how he created separate functions for /dev/sg and for all other block devices. Please take a look. Also not related to this patch, you are missing my fix I did to the VPD limit emulation, please consider taking it into the series: https://www.mail-archive.com/qemu-devel@nongnu.org/msg768260.html Best regards, Maxim Levitsky

Re: [PATCH v4 3/7] block: add max_hw_transfer to BlockLimits

2021-06-09 Thread Maxim Levitsky
ssed something as I haven't touched this area for a long time. Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky > --- > block/block-backend.c | 12 > block/file-posix.c | 2 +- > block/io.c | 1 + > hw/scsi

Re: [PATCH v4 1/7] file-posix: fix max_iov for /dev/sg devices

2021-06-09 Thread Maxim Levitsky
ot;/sys/dev/block/%u:%u/queue/max_segments", > > major(st.st_rdev), minor(st.st_rdev)); > > sysfd = open(sysfspath, O_RDONLY); > > > > Other than that, this is the same as the patch from Tom Yan: https://www.mail-archive.com/qemu-devel@nongnu.org/msg768262.html In this version he does check if the SG_GET_SG_TABLESIZE is defined, so you might want to do this as well. Best regards, Maxim Levitsky

Re: [PATCH v3 0/7] block: file-posix queue

2021-06-07 Thread Maxim Levitsky
h I think is similar to this patch series. Sorry that I kind of forgot about it for too much time. https://www.mail-archive.com/qemu-devel@nongnu.org/msg768261.html I'll need some time to swap-in this area so that I could compare our patches to see if we missed something. Best regards, Maxim Levitsky

Re: [PATCH 2/2] qemu-img: align next status sector on destination alignment.

2021-03-18 Thread Maxim Levitsky
On Thu, 2020-11-12 at 17:04 +0200, Maxim Levitsky wrote: > On Thu, 2020-11-12 at 07:45 -0600, Eric Blake wrote: > > On 11/12/20 6:40 AM, Peter Lieven wrote: > > > > > > /* > > > > - * Avoid that s->sector_next_statu

Re: [PATCH 1/2] file-posix: allow -EBUSY errors during write zeros on raw block devices

2021-01-07 Thread Maxim Levitsky
On Mon, 2020-11-16 at 15:48 +0100, Kevin Wolf wrote: > Am 11.11.2020 um 16:39 hat Maxim Levitsky geschrieben: > > On Linux, fallocate(fd, FALLOC_FL_PUNCH_HOLE) when it is used on a block > > device, > > without O_DIRECT can return -EBUSY if it races with another write

Re: [PATCH v3 0/5] SCSI: fix transfer limits for SCSI passthrough

2021-01-07 Thread Maxim Levitsky
On Thu, 2020-12-17 at 18:56 +0200, Maxim Levitsky wrote: > This patch series attempts to provide a solution to the problem of the > transfer > limits of the raw file driver (host_device/file-posix), some of which I > already tried to fix in the past. > > I included 2 patches

Re: [PATCH v6 0/3] qcow2: don't leave partially initialized file on image creation

2021-01-07 Thread Maxim Levitsky
On Thu, 2020-12-17 at 19:09 +0200, Maxim Levitsky wrote: > Use the bdrv_co_delete_file interface to delete the underlying > file if qcow2 initialization fails (e.g due to bad encryption secret) > > This makes the qcow2 driver behave the same way as the luks driver behaves. > &

[PATCH v6 3/3] block: qcow2: remove the created file on initialization error

2020-12-17 Thread Maxim Levitsky
If the qcow initialization fails, we should remove the file if it was already created, to avoid leaving stale files around. We already do this for luks raw images. Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia --- block/qcow2.c | 8 +--- 1 file changed, 5 insertions(+), 3

[PATCH v6 0/3] qcow2: don't leave partially initialized file on image creation

2020-12-17 Thread Maxim Levitsky
, Maxim Levitsky Maxim Levitsky (3): crypto: luks: Fix tiny memory leak block: add bdrv_co_delete_file_noerr block: qcow2: remove the created file on initialization error block.c | 22 ++ block/crypto.c| 13 ++--- block/qcow2.c

[PATCH v6 2/3] block: add bdrv_co_delete_file_noerr

2020-12-17 Thread Maxim Levitsky
This function wraps bdrv_co_delete_file for the common case of removing a file, which was just created by format driver, on an error condition. It hides the -ENOTSUPP error, and reports all other errors otherwise. Use it in luks driver Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia

[PATCH v6 1/3] crypto: luks: Fix tiny memory leak

2020-12-17 Thread Maxim Levitsky
When the underlying block device doesn't support the bdrv_co_delete_file interface, an 'Error' object was leaked. Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/crypto.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block

[PATCH v3 3/5] block: add max_ioctl_transfer to BlockLimits

2020-12-17 Thread Maxim Levitsky
, and simultaneously, the block devices that implement scsi passthrough will switch to 'blk_get_max_ioctl_transfer' to query and to pass it to the guest. Signed-off-by: Maxim Levitsky --- block/block-backend.c | 12 block/io.c | 2 ++ include/block/block_int.h

[PATCH v3 1/5] file-posix: split hdev_refresh_limits from raw_refresh_limits

2020-12-17 Thread Maxim Levitsky
From: Tom Yan We can and should get max transfer length and max segments for all host devices / cdroms (on Linux). Also use MIN_NON_ZERO instead when we clamp max transfer length against max segments. Signed-off-by: Tom Yan Signed-off-by: Maxim Levitsky --- block/file-posix.c | 57

[PATCH v3 5/5] block/scsi: correctly emulate the VPD block limits page

2020-12-17 Thread Maxim Levitsky
, thus the guest never sees the VPD block limits page as supported. Bump the transfer size by 1 in this case. Signed-off-by: Maxim Levitsky --- hw/scsi/scsi-generic.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index

[PATCH v3 2/5] file-posix: add sg_get_max_segments that actually works with sg

2020-12-17 Thread Maxim Levitsky
Signed-off-by: Maxim Levitsky --- block/file-posix.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index cbf1271773..2bf4d095a7 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1179,6 +1179,26 @@ static

[PATCH v3 4/5] block: use blk_get_max_ioctl_transfer for SCSI passthrough

2020-12-17 Thread Maxim Levitsky
blk_get_max_ioctl_transfer interface. Fixes: 867eccfed8 ("file-posix: Use max transfer length/segment count only for SCSI passthrough") Signed-off-by: Maxim Levitsky --- block/file-posix.c | 7 --- block/iscsi.c | 1 + hw/scsi/scsi-generic.c | 4 ++-- 3 files

[PATCH v3 0/5] SCSI: fix transfer limits for SCSI passthrough

2020-12-17 Thread Maxim Levitsky
if this should be solved. V2: fixed an issue in a patch from Tom Yan (thanks), and removed refactoring from last patch according to Paulo's request. V3: few cosmitic changes due to the review feedback. Maxim Levitsky (3): block: add max_ioctl_transfer to BlockLimits block: use

Re: [PATCH v2 1/5] file-posix: split hdev_refresh_limits from raw_refresh_limits

2020-12-17 Thread Maxim Levitsky
On Thu, 2020-12-10 at 18:36 +0800, Tom Yan wrote: > On Wed, 9 Dec 2020 at 21:54, Maxim Levitsky wrote: > > From: Tom Yan > > > > We can and should get max transfer length and max segments for all host > > devices / cdroms (on Linux). > > > > Also use

Re: [PATCH v5 2/4] block: add bdrv_co_delete_file_noerr

2020-12-10 Thread Maxim Levitsky
On Thu, 2020-12-10 at 13:54 +0300, Vladimir Sementsov-Ogievskiy wrote: > 09.12.2020 23:33, Maxim Levitsky wrote: > > This function wraps bdrv_co_delete_file for the common case of removing a > > file, > > which was just created by format driver, on an error conditi

Re: [PATCH v5 4/4] block: qcow2: remove the created file on initialization error

2020-12-10 Thread Maxim Levitsky
On Thu, 2020-12-10 at 14:00 +0300, Vladimir Sementsov-Ogievskiy wrote: > 09.12.2020 23:33, Maxim Levitsky wrote: > > If the qcow initialization fails, we should remove the file if it was > > already created, to avoid leaving stale files around. > > > > We already

Re: [PATCH v2 0/5] SCSI: fix transfer limits for SCSI passthrough

2020-12-10 Thread Maxim Levitsky
= OUTPUT END === > > > > Test command exited with code: 1 > > > > > > The full log is available at > > http://patchew.org/logs/20201209135355.561745-1-mlevi...@redhat.com/testing.checkpatch/?type=message. > > --- > > Email generated automatically by Patchew [https://patchew.org/]. > > Please send your feedback to patchew-de...@redhat.com > > > > Time for v3? I am waiting a bit to see if anything else pops up, to avoid doing too much noise. Best regards, Maxim Levitsky > > Paolo >

[PATCH v5 2/4] block: add bdrv_co_delete_file_noerr

2020-12-09 Thread Maxim Levitsky
This function wraps bdrv_co_delete_file for the common case of removing a file, which was just created by format driver, on an error condition. It hides the -ENOTSUPP error, and reports all other errors otherwise. Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia --- block.c

[PATCH v5 1/4] crypto: luks: Fix tiny memory leak

2020-12-09 Thread Maxim Levitsky
When the underlying block device doesn't support the bdrv_co_delete_file interface, an 'Error' object was leaked. Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia --- block/crypto.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/crypto.c b/block/crypto.c index aef5a5721a

[PATCH v5 0/4] qcow2: don't leave partially initialized file on image creation

2020-12-09 Thread Maxim Levitsky
feedback and reworked commit messages V4: got rid of code duplication by adding bdrv_co_delete_file_noerr and made the qcow2 driver use this function to delete both the main and the data file. V5: addresssed review feedback on reworked version. Best regards, Maxim Levitsky Maxim Levitsky (4

[PATCH v5 3/4] crypto: luks: use bdrv_co_delete_file_noerr

2020-12-09 Thread Maxim Levitsky
This refactoring is now possible thanks to this function. Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia --- block/crypto.c | 15 ++- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/block/crypto.c b/block/crypto.c index b3a5275132..1d30fde38e 100644

[PATCH v5 4/4] block: qcow2: remove the created file on initialization error

2020-12-09 Thread Maxim Levitsky
If the qcow initialization fails, we should remove the file if it was already created, to avoid leaving stale files around. We already do this for luks raw images. Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia --- block/qcow2.c | 6 -- 1 file changed, 4 insertions(+), 2

Re: [PATCH v4 4/4] block: qcow2: remove the created file on initialization error

2020-12-09 Thread Maxim Levitsky
On Wed, 2020-12-09 at 18:41 +0100, Alberto Garcia wrote: > On Wed 09 Dec 2020 05:44:41 PM CET, Maxim Levitsky wrote: > > @@ -3847,12 +3847,13 @@ static int coroutine_fn > > qcow2_co_create_opts(BlockDriver *drv, > > > > /* Create the qcow2 image (fo

Re: [PATCH v4 2/4] block: add bdrv_co_delete_file_noerr

2020-12-09 Thread Maxim Levitsky
On Wed, 2020-12-09 at 18:34 +0100, Alberto Garcia wrote: > On Wed 09 Dec 2020 05:44:39 PM CET, Maxim Levitsky wrote: > > +void coroutine_fn bdrv_co_delete_file_noerr(BlockDriverState *bs) > > +{ > > +Error *local_err = NULL; > > + > > +

[PATCH v4 1/4] crypto: luks: Fix tiny memory leak

2020-12-09 Thread Maxim Levitsky
When the underlying block device doesn't support the bdrv_co_delete_file interface, an 'Error' object was leaked. Signed-off-by: Maxim Levitsky Reviewed-by: Alberto Garcia --- block/crypto.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/crypto.c b/block/crypto.c index aef5a5721a

[PATCH v4 2/4] block: add bdrv_co_delete_file_noerr

2020-12-09 Thread Maxim Levitsky
This function wraps bdrv_co_delete_file for the common case of removing a file, which was just created by format driver, on an error condition. It hides the -ENOTSUPP error, and reports all other errors otherwise. Signed-off-by: Maxim Levitsky --- block.c | 23

[PATCH v4 4/4] block: qcow2: remove the created file on initialization error

2020-12-09 Thread Maxim Levitsky
If the qcow initialization fails, we should remove the file if it was already created, to avoid leaving stale files around. We already do this for luks raw images. Signed-off-by: Maxim Levitsky --- block/qcow2.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block

[PATCH v4 3/4] crypto: luks: use bdrv_co_delete_file_noerr

2020-12-09 Thread Maxim Levitsky
This refactoring is now possible thanks to this function. Signed-off-by: Maxim Levitsky --- block/crypto.c | 15 ++- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/block/crypto.c b/block/crypto.c index b3a5275132..1d30fde38e 100644 --- a/block/crypto.c +++ b/block

[PATCH v4 0/4] qcow2: don't leave partially initialized file on image creation

2020-12-09 Thread Maxim Levitsky
feedback and reworked commit messages V4: got rid of code duplication by adding bdrv_co_delete_file_noerr and made the qcow2 driver use this function to delete both the main and the data file. Best regards, Maxim Levitsky Maxim Levitsky (4): crypto: luks: Fix tiny memory leak block: add

Re: [PATCH v2 0/5] SCSI: fix transfer limits for SCSI passthrough

2020-12-09 Thread Maxim Levitsky
blk_get_max_ioctl_transfer for > SCSI passthrough) > 5/5 Checking commit 77c9000b7c30 (block/scsi: correctly emulate the VPD block > limits page) > ERROR: braces {} are necessary for all arms of this statement > #39: FILE: hw/scsi/scsi-generic.c:204: > +if (len &

[PATCH v2 5/5] block/scsi: correctly emulate the VPD block limits page

2020-12-09 Thread Maxim Levitsky
, thus the guest never sees the VPD block limits page as supported. Bump the transfer size by 1 in this case. Signed-off-by: Maxim Levitsky --- hw/scsi/scsi-generic.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index

[PATCH v2 4/5] block: use blk_get_max_ioctl_transfer for SCSI passthrough

2020-12-09 Thread Maxim Levitsky
blk_get_max_ioctl_transfer interface. Fixes: 867eccfed8 ("file-posix: Use max transfer length/segment count only for SCSI passthrough") Signed-off-by: Maxim Levitsky --- block/file-posix.c | 4 ++-- block/iscsi.c | 1 + hw/scsi/scsi-generic.c | 4 ++-- 3 files changed, 5

[PATCH v2 2/5] file-posix: add sg_get_max_segments that actually works with sg

2020-12-09 Thread Maxim Levitsky
Signed-off-by: Maxim Levitsky --- block/file-posix.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 226ddbbdad..10ebc4c5b7 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1181,6 +1181,26 @@ static

[PATCH v2 3/5] block: add max_ioctl_transfer to BlockLimits

2020-12-09 Thread Maxim Levitsky
, and simultaneously, the block devices that implement scsi passthrough will switch to 'blk_get_max_ioctl_transfer' to query and to pass it to the guest. Signed-off-by: Maxim Levitsky --- block/block-backend.c | 12 block/io.c | 2 ++ include/block/block_int.h

[PATCH v2 1/5] file-posix: split hdev_refresh_limits from raw_refresh_limits

2020-12-09 Thread Maxim Levitsky
From: Tom Yan We can and should get max transfer length and max segments for all host devices / cdroms (on Linux). Also use MIN_NON_ZERO instead when we clamp max transfer length against max segments. Signed-off-by: Tom Yan Signed-off-by: Maxim Levitsky --- block/file-posix.c | 59

[PATCH v2 0/5] SCSI: fix transfer limits for SCSI passthrough

2020-12-09 Thread Maxim Levitsky
if this should be solved. V2: fixed an issue in a patch from Tom Yan (thanks), and removed refactoring from last patch according to Paulo's request. Maxim Levitsky (3): block: add max_ioctl_transfer to BlockLimits block: use blk_get_max_ioctl_transfer for SCSI passthrough block/scsi: correctly

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Maxim Levitsky
On Tue, 2020-12-08 at 19:54 +0300, Vladimir Sementsov-Ogievskiy wrote: > 08.12.2020 19:27, Maxim Levitsky wrote: > > On Tue, 2020-12-08 at 18:47 +0300, Vladimir Sementsov-Ogievskiy wrote: > > > 08.12.2020 17:21, Maxim Levitsky wrote: > > > > If the qcow initiali

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Maxim Levitsky
On Tue, 2020-12-08 at 18:47 +0300, Vladimir Sementsov-Ogievskiy wrote: > 08.12.2020 17:21, Maxim Levitsky wrote: > > If the qcow initialization fails, we should remove the file if it was > > already created, to avoid leaving stale files around. > > > > We already

Re: [PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Maxim Levitsky
On Tue, 2020-12-08 at 16:26 +0100, Alberto Garcia wrote: > On Tue 08 Dec 2020 03:21:59 PM CET, Maxim Levitsky wrote: > > If the qcow initialization fails, we should remove the file if it was > > already created, to avoid leaving stale files around. > > > > We already

[PATCH v3 2/2] block: qcow2: remove the created file on initialization error

2020-12-08 Thread Maxim Levitsky
If the qcow initialization fails, we should remove the file if it was already created, to avoid leaving stale files around. We already do this for luks raw images. Signed-off-by: Maxim Levitsky --- block/qcow2.c | 13 + 1 file changed, 13 insertions(+) diff --git a/block/qcow2.c b

[PATCH v3 1/2] crypto: luks: Fix tiny memory leak

2020-12-08 Thread Maxim Levitsky
When the underlying block device doesn't support the bdrv_co_delete_file interface, an 'Error' object was leaked. Signed-off-by: Maxim Levitsky --- block/crypto.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/crypto.c b/block/crypto.c index aef5a5721a..b3a5275132 100644

[PATCH v3 0/2] qcow2: don't leave partially initialized file on image creation

2020-12-08 Thread Maxim Levitsky
feedback and reworked commit messages Best regards, Maxim Levitsky Maxim Levitsky (2): crypto: luks: Fix tiny memory leak block: qcow2: remove the created file on initialization error block/crypto.c | 2 ++ block/qcow2.c | 13 + 2 files changed, 15 insertions(+) -- 2.26.2

Re: [PATCH 0/2] RFC: Issue with discards on raw block device without O_DIRECT

2020-12-07 Thread Maxim Levitsky
On Thu, 2020-11-12 at 14:08 -0800, Darrick J. Wong wrote: > On Thu, Nov 12, 2020 at 01:00:56PM +0100, Jan Kara wrote: > > On Thu 12-11-20 12:19:51, Jan Kara wrote: > > > [added some relevant people and lists to CC] > > > > > > On Wed 11-11-20 17:44:05, Maxim

Re: [PATCH 0/5] SCSI: fix transfer limits for SCSI passthrough

2020-12-03 Thread Maxim Levitsky
On Wed, 2020-11-04 at 19:32 +0200, Maxim Levitsky wrote: > This patch series attempts to provide a solution to the problem of the > transfer > limits of the raw file driver (host_device/file-posix), some of which I > already tried to fix in the past. > > I included 2 patches

Re: [PATCH] iotests: Add test for the regression fixed in c8bf9a9169

2020-11-26 Thread Maxim Levitsky
On Wed, 2020-11-25 at 19:55 +0100, Alberto Garcia wrote: > Signed-off-by: Alberto Garcia > Suggested-by: Maxim Levitsky > --- > tests/qemu-iotests/313 | 103 + > tests/qemu-iotests/313.out | 29 +++ > tests/qemu-iotests/group

Re: [PATCH 1/1] Fix qcow2 corruption on discard

2020-11-24 Thread Maxim Levitsky
On Tue, 2020-11-24 at 20:59 +0200, Maxim Levitsky wrote: > On Tue, 2020-11-24 at 19:59 +0100, Alberto Garcia wrote: > > On Tue 24 Nov 2020 10:17:23 AM CET, Kevin Wolf wrote: > > > We can then continue work to find a minimal reproducer and merge the > > > test

Re: [PATCH 1/1] Fix qcow2 corruption on discard

2020-11-24 Thread Maxim Levitsky
yet, do you have any > findings? > > Berto > I have a working reproducer script. I'll send it in a hour or so. Best regards, Maxim Levitsky

Re: [PATCH 1/1] Fix qcow2 corruption on discard

2020-11-23 Thread Maxim Levitsky
; > set_l2_entry(s, l2_slice, l2_index + i, new_l2_entry); > > > +qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); > > > > Good catch, but I think your order is wrong, too. We need the original > > order from before 205fa50750: > > > > 1. qcow2_cache_entry_mark_dirty() > >set_l2_entry() + set_l2_bitmap() > > > > 2. qcow2_free_any_cluster() > > I agree with Kevin on this. I also agree, I haven't thought about this. Best regards, Maxim Levitsky > > Berto >

Re: [PATCH 1/1] Fix qcow2 corruption on discard

2020-11-23 Thread Maxim Levitsky
On Mon, 2020-11-23 at 18:38 +0100, Kevin Wolf wrote: > Am 23.11.2020 um 16:49 hat Maxim Levitsky geschrieben: > > Commit 205fa50750 ("qcow2: Add subcluster support to zero_in_l2_slice()") > > introduced a subtle change to code in zero_in_l2_slice: > > > &g

[PATCH 0/1] Fix qcow2 corruption after addition of subcluster support

2020-11-23 Thread Maxim Levitsky
. Best regards, Maxim Levitsky (*)https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg02760.html (**) https://patchwork.kernel.org/project/qemu-devel/patch/20180328133845.20632-1-be...@igalia.com/ (***) https://patchwork.kernel.org/project/qemu-devel/cover/1578990137-308222-1-git-send-email

[PATCH 1/1] Fix qcow2 corruption on discard

2020-11-23 Thread Maxim Levitsky
dd subcluster support to zero_in_l2_slice()") Signed-off-by: Maxim Levitsky --- block/qcow2-cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 485b4cb92e..267b46a4ca 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-clus

Re: [PATCH 0/2] RFC: Issue with discards on raw block device without O_DIRECT

2020-11-12 Thread Maxim Levitsky
On Thu, 2020-11-12 at 12:19 +0100, Jan Kara wrote: > [added some relevant people and lists to CC] > > On Wed 11-11-20 17:44:05, Maxim Levitsky wrote: > > On Wed, 2020-11-11 at 17:39 +0200, Maxim Levitsky wrote: > > > clone of "starship_production" > >

Re: [PATCH 2/2] qemu-img: align next status sector on destination alignment.

2020-11-12 Thread Maxim Levitsky
ring the same page. Another thing that can be discussed is why is_allocated_sectors was patched to convert short discards to writes. Probably because underlying hardware ignores them or something? In theory we should detect this and fail back to regular zeroing in this case. Again though, while in

Re: [PATCH 0/2] RFC: Issue with discards on raw block device without O_DIRECT

2020-11-11 Thread Maxim Levitsky
On Wed, 2020-11-11 at 17:39 +0200, Maxim Levitsky wrote: > clone of "starship_production" The git-publish destroyed the cover letter: For the reference this is for bz #1872633 The issue is that current kernel code that implements 'fallocate' on kernel block devices roughly works

[PATCH 2/2] qemu-img: align next status sector on destination alignment.

2020-11-11 Thread Maxim Levitsky
This helps avoid unneeded writes and discards. Signed-off-by: Maxim Levitsky --- qemu-img.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index c2c56fc797..7e9b0f659f 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1722,7 +1722,7

[PATCH 1/2] file-posix: allow -EBUSY errors during write zeros on raw block devices

2020-11-11 Thread Maxim Levitsky
On Linux, fallocate(fd, FALLOC_FL_PUNCH_HOLE) when it is used on a block device, without O_DIRECT can return -EBUSY if it races with another write to the same page. Since this is rare and discard is not a critical operation, ignore this error Signed-off-by: Maxim Levitsky --- block/file

[PATCH 0/2] RFC: Issue with discards on raw block device without O_DIRECT

2020-11-11 Thread Maxim Levitsky
clone of "starship_production" Maxim Levitsky (2): file-posix: allow -EBUSY errors during write zeros on raw block devices qemu-img: align next status sector on destination alignment. block/file-posix.c | 1 + qemu-img.c | 13 - 2 files changed, 9 insert

Re: [PATCH 1/5] file-posix: split hdev_refresh_limits from raw_refresh_limits

2020-11-05 Thread Maxim Levitsky
> See logical_to_sectors() in sd.h of the kernel. I see it now. I'll respin the patches in a few days I guess after the rest of the patches are reviewed. Best regards, Maxim Levitsky > > On Thu, 5 Nov 2020 at 01:32, Maxim Levitsky wrote: > > From: Tom Yan > >

Re: [PATCH v2 2/2] iotests: rewrite iotest 240 in python

2020-11-04 Thread Maxim Levitsky
On Tue, 2020-11-03 at 13:53 +0100, Max Reitz wrote: > On 01.11.20 17:15, Maxim Levitsky wrote: > > The recent changes that brought RCU delayed device deletion, > > broke few tests and this test breakage went unnoticed. > > > > Fix this test by rewriting it in pytho

[PATCH v3 2/2] iotests: rewrite iotest 240 in python

2020-11-04 Thread Maxim Levitsky
The recent changes that brought RCU delayed device deletion, broke few tests and this test breakage went unnoticed. Fix this test by rewriting it in python (which allows to wait for DEVICE_DELETED events before continuing). Signed-off-by: Maxim Levitsky Tested-by: Christian Borntraeger

[PATCH v3 1/2] iotests: add filter_qmp_virtio_scsi function

2020-11-04 Thread Maxim Levitsky
filter_qmp_virtio_scsi can be used to filter virtio-scsi-pci/ccw differences. Note that this patch was only tested on x86. Suggested-by: Paolo Bonzini Signed-off-by: Maxim Levitsky Tested-by: Christian Borntraeger Reviewed-by: Paolo Bonzini --- tests/qemu-iotests/iotests.py | 10

[PATCH v3 0/2] Assorted fixes to tests that were broken by recent scsi changes

2020-11-04 Thread Maxim Levitsky
review feedback Best regards, Maxim Levitsky Maxim Levitsky (2): iotests: add filter_qmp_virtio_scsi function iotests: rewrite iotest 240 in python tests/qemu-iotests/240| 219 ++ tests/qemu-iotests/240.out| 76 ++-- tests/qemu

Re: [PATCH 0/5] SCSI: fix transfer limits for SCSI passthrough

2020-11-04 Thread Maxim Levitsky
: correctly emulate the VPD block > limits page) > ERROR: braces {} are necessary for all arms of this statement > #51: FILE: hw/scsi/scsi-generic.c:196: > +if (page_idx >= r->buflen) Sorry about that. Triple checked this code for correctness, but didn't run checkpatch

[PATCH 4/5] block: use blk_get_max_ioctl_transfer for SCSI passthrough

2020-11-04 Thread Maxim Levitsky
blk_get_max_ioctl_transfer interface. Fixes: 867eccfed8 ("file-posix: Use max transfer length/segment count only for SCSI passthrough") Signed-off-by: Maxim Levitsky --- block/file-posix.c | 4 ++-- block/iscsi.c | 1 + hw/scsi/scsi-generic.c | 4 ++-- 3 files changed, 5

[PATCH 1/5] file-posix: split hdev_refresh_limits from raw_refresh_limits

2020-11-04 Thread Maxim Levitsky
From: Tom Yan We can and should get max transfer length and max segments for all host devices / cdroms (on Linux). Also use MIN_NON_ZERO instead when we clamp max transfer length against max segments. Signed-off-by: Tom Yan Signed-off-by: Maxim Levitsky --- block/file-posix.c | 61

[PATCH 5/5] block/scsi: correctly emulate the VPD block limits page

2020-11-04 Thread Maxim Levitsky
, thus the guest never sees the VPD block limits page as supported. Bump the transfer size by 1 in this case. I also refactored the code a bit, and I hopefully didn't introduce another buffer overflow to this code... Signed-off-by: Maxim Levitsky --- hw/scsi/scsi-generic.c | 28

[PATCH 2/5] file-posix: add sg_get_max_segments that actually works with sg

2020-11-04 Thread Maxim Levitsky
Signed-off-by: Maxim Levitsky --- block/file-posix.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 6581f41b2b..c4df757504 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1181,6 +1181,26 @@ static

[PATCH 3/5] block: add max_ioctl_transfer to BlockLimits

2020-11-04 Thread Maxim Levitsky
, and simultaneously, the block devices that implement scsi passthrough will switch to 'blk_get_max_ioctl_transfer' to query and to pass it to the guest. Signed-off-by: Maxim Levitsky --- block/block-backend.c | 12 block/io.c | 2 ++ include/block/block_int.h

[PATCH 0/5] SCSI: fix transfer limits for SCSI passthrough

2020-11-04 Thread Maxim Levitsky
if this should be solved. Maxim Levitsky (3): block: add max_ioctl_transfer to BlockLimits block: use blk_get_max_ioctl_transfer for SCSI passthrough block/scsi: correctly emulate the VPD block limits page Tom Yan (2): file-posix: split hdev_refresh_limits from raw_refresh_limits file-posix

[PATCH v2 2/2] iotests: rewrite iotest 240 in python

2020-11-01 Thread Maxim Levitsky
The recent changes that brought RCU delayed device deletion, broke few tests and this test breakage went unnoticed. Fix this test by rewriting it in python (which allows to wait for DEVICE_DELETED events before continuing). Signed-off-by: Maxim Levitsky --- tests/qemu-iotests/240 | 228

[PATCH v2 1/2] iotests: add filter_qmp_virtio_scsi function

2020-11-01 Thread Maxim Levitsky
filter_qmp_virtio_scsi can be used to filter virtio-scsi-pci/ccw differences. Note that this patch was only tested on x86. Suggested-by: Paolo Bonzini Signed-off-by: Maxim Levitsky --- tests/qemu-iotests/iotests.py | 10 ++ 1 file changed, 10 insertions(+) diff --git a/tests/qemu

[PATCH v2 0/2] Assorted fixes to tests that were broken by recent scsi changes

2020-11-01 Thread Maxim Levitsky
, Maxim Levitsky Maxim Levitsky (2): iotests: add filter_qmp_virtio_scsi function iotests: rewrite iotest 240 in python tests/qemu-iotests/240| 228 +++--- tests/qemu-iotests/240.out| 76 +++- tests/qemu-iotests/iotests.py | 10 ++ 3 files

[PATCH 4/4] iotests: rewrite iotest 240 in python

2020-10-19 Thread Maxim Levitsky
The recent changes that brought RCU delayed device deletion, broke few tests and this test breakage went unnoticed. Fix this test by rewriting it in python (which allows to wait for DEVICE_DELETED events before continuing). Signed-off-by: Maxim Levitsky --- tests/qemu-iotests/240 | 228

[PATCH 3/4] libqtest: fix memory leak in the qtest_qmp_event_ref

2020-10-19 Thread Maxim Levitsky
The g_list_remove_link doesn't free the link element, opposed to what I thought. Switch to g_list_delete_link that does free it. Also refactor the code a bit. Thanks for Max Reitz for helping me with this. Signed-off-by: Maxim Levitsky --- tests/qtest/libqtest.c | 11 --- 1 file

[PATCH 1/4] qdev: Fix two typos

2020-10-19 Thread Maxim Levitsky
Signed-off-by: Maxim Levitsky --- include/hw/qdev-core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 868973319e..3761186804 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -163,8 +163,8

[PATCH 2/4] libqtest: fix the order of buffered events

2020-10-19 Thread Maxim Levitsky
By a mistake I added the pending events in a wrong order. Fix this by using g_list_append. Signed-off-by: Maxim Levitsky --- tests/qtest/libqtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 08929f5ff6..bd96cb6fdd

[PATCH 0/4] Assorted fixes to tests that were broken by recent scsi changes

2020-10-19 Thread Maxim Levitsky
Just few fixes, for some stuff that slipped thorough. Tested with make check, and qcow2/raw/nbd iotests. Best regards, Maxim Levitsky Maxim Levitsky (4): qdev: Fix two typos libqtest: fix the order of buffered events libqtest: fix memory leak in the qtest_qmp_event_ref iotests

Re: [PATCH v2 1/2] crypto: luks: fix tiny memory leak

2020-10-13 Thread Maxim Levitsky
On Tue, 2020-10-13 at 14:26 +0200, Alberto Garcia wrote: > On Sun 11 Oct 2020 12:21:35 PM CEST, Maxim Levitsky wrote: > > In the case when underlying block device doesn't support the > > bdrv_co_delete_file interface, an 'Error' wasn't freed. > > > > Si

[PATCH v2 2/2] block: qcow2: remove the created file on initialization error

2020-10-11 Thread Maxim Levitsky
If the qcow initialization fails after we created the storage file, we should remove it to avoid leaving stale files around. We already do this for luks raw images. Signed-off-by: Maxim Levitsky --- block/qcow2.c | 12 1 file changed, 12 insertions(+) diff --git a/block/qcow2.c b

[PATCH v2 0/2] qcow2: don't leave partially initialized file on image creation

2020-10-11 Thread Maxim Levitsky
Use the bdrv_co_delete_file interface to delete the underlying file if qcow2 initilization fails (e.g due to bad encryption secret) This gives the qcow2 the same treatment as to luks. V2: added a patch to fix a memory leak. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1845353 Maxim

[PATCH v2 1/2] crypto: luks: fix tiny memory leak

2020-10-11 Thread Maxim Levitsky
In the case when underlying block device doesn't support the bdrv_co_delete_file interface, an 'Error' wasn't freed. Signed-off-by: Maxim Levitsky --- block/crypto.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/crypto.c b/block/crypto.c index 0807557763..9b61fd4aa8 100644

Re: [PATCH] qcow2: cleanup created file when qcow2_co_create

2020-10-11 Thread Maxim Levitsky
On Tue, 2020-09-01 at 15:30 +0200, Alberto Garcia wrote: > On Thu 16 Jul 2020 01:33:59 PM CEST, Maxim Levitsky wrote: > > if (ret < 0) { > > + > > +Error *local_delete_err = NULL; > > +int r_del = bdrv_co_delete_file(bs, _delete_err); > >

Re: [PATCH v7 03/13] qtest: switch users back to qtest_qmp_receive

2020-10-06 Thread Maxim Levitsky
On Tue, 2020-10-06 at 14:56 +0200, Paolo Bonzini wrote: > On 06/10/20 14:38, Maxim Levitsky wrote: > > The only remaining users of qtest_qmp_receive_dict are tests > > that fuzz the QMP protocol. > > > > Tested with 'make check-qtest'. > > Probably the qtest_qmp_

[PATCH v7 13/13] scsi/scsi_bus: fix races in REPORT LUNS

2020-10-06 Thread Maxim Levitsky
can avoid iterating twice, and therefore we avoid this race. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1866707 Signed-off-by: Maxim Levitsky Reviewed-by: Stefan Hajnoczi Message-Id: <20200913160259.32145-10-mlevi...@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.

[PATCH v7 11/13] scsi/scsi_bus: Add scsi_device_get

2020-10-06 Thread Maxim Levitsky
Add scsi_device_get which finds the scsi device and takes a reference to it. Suggested-by: Stefan Hajnoczi Signed-off-by: Maxim Levitsky Message-Id: <20200913160259.32145-8-mlevi...@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.c | 11 +++ include/hw/scsi/

[PATCH v7 04/13] qdev: add "check if address free" callback for buses

2020-10-06 Thread Maxim Levitsky
From: Paolo Bonzini Check if an address is free on the bus before plugging in the device. This makes it possible to do the check without any side effects, and to detect the problem early without having to do it in the realize callback. Signed-off-by: Paolo Bonzini --- hw/core/qdev.c

[PATCH v7 05/13] scsi: switch to bus->check_address

2020-10-06 Thread Maxim Levitsky
From: Paolo Bonzini Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.c | 122 - 1 file changed, 75 insertions(+), 47 deletions(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 3284a5d1fb..94921c04b1 100644 --- a/hw/scsi/scsi-bus.c +++

[PATCH v7 10/13] scsi/scsi-bus: scsi_device_find: don't return unrealized devices

2020-10-06 Thread Maxim Levitsky
Bonzini Signed-off-by: Maxim Levitsky Reviewed-by: Stefan Hajnoczi Message-Id: <20200913160259.32145-7-mlevi...@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.c | 83 +- 1 file changed, 53 insertions(+), 30 deletions(-) diff --gi

[PATCH v7 12/13] virtio-scsi: use scsi_device_get

2020-10-06 Thread Maxim Levitsky
This will help us to avoid the scsi device disappearing after we took a reference to it. It doesn't by itself forbid case when we try to access an unrealized device Suggested-by: Stefan Hajnoczi Signed-off-by: Maxim Levitsky Reviewed-by: Stefan Hajnoczi Message-Id: <20200913160259.3214

[PATCH v7 03/13] qtest: switch users back to qtest_qmp_receive

2020-10-06 Thread Maxim Levitsky
The only remaining users of qtest_qmp_receive_dict are tests that fuzz the QMP protocol. Tested with 'make check-qtest'. Signed-off-by: Maxim Levitsky --- tests/qtest/ahci-test.c | 4 +- tests/qtest/device-plug-test.c | 2 +- tests/qtest/drive_del-test.c| 9 ++--- tests/qtest

[PATCH v7 01/13] qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict

2020-10-06 Thread Maxim Levitsky
In the next patch a new version of qtest_qmp_receive will be reintroduced that will buffer received qmp events for later consumption in qtest_qmp_eventwait_ref No functional change intended. Suggested-by: Paolo Bonzini Signed-off-by: Maxim Levitsky --- tests/qtest/ahci-test.c| 4

  1   2   3   4   5   6   7   8   9   10   >