<feed xmlns='http://www.w3.org/2005/Atom'>
<title>bwlp/qemu.git/block/nbd.c, branch spice_video_codecs</title>
<subtitle>Experimental fork of QEMU with video encoding patches</subtitle>
<id>https://git.openslx.org/bwlp/qemu.git/atom/block/nbd.c?h=spice_video_codecs</id>
<link rel='self' href='https://git.openslx.org/bwlp/qemu.git/atom/block/nbd.c?h=spice_video_codecs'/>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/'/>
<updated>2022-10-26T18:56:42+00:00</updated>
<entry>
<title>block: add BDRV_REQ_REGISTERED_BUF request flag</title>
<updated>2022-10-26T18:56:42+00:00</updated>
<author>
<name>Stefan Hajnoczi</name>
</author>
<published>2022-10-13T18:59:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=e8b6535533be4269e4b7bd23d4bb17dd976dc7a3'/>
<id>urn:sha1:e8b6535533be4269e4b7bd23d4bb17dd976dc7a3</id>
<content type='text'>
Block drivers may optimize I/O requests accessing buffers previously
registered with bdrv_register_buf(). Checking whether all elements of a
request's QEMUIOVector are within previously registered buffers is
expensive, so we need a hint from the user to avoid costly checks.

Add a BDRV_REQ_REGISTERED_BUF request flag to indicate that all
QEMUIOVector elements in an I/O request are known to be within
previously registered buffers.

Always pass the flag through to driver read/write functions. There is
little harm in passing the flag to a driver that does not use it.
Passing the flag to drivers avoids changes across many block drivers.
Filter drivers would need to explicitly support the flag and pass
through to their children when the children support it. That's a lot of
code changes and it's hard to remember to do that everywhere, leading to
silent reduced performance when the flag is accidentally dropped.

The only problematic scenario with the approach in this patch is when a
driver passes the flag through to internal I/O requests that don't use
the same I/O buffer. In that case the hint may be set when it should
actually be clear. This is a rare case though so the risk is low.

Some drivers have assert(!flags), which no longer works when
BDRV_REQ_REGISTERED_BUF is passed in. These assertions aren't very
useful anyway since the functions are called almost exclusively by
bdrv_driver_preadv/pwritev() so if we get flags handling right there
then the assertion is not needed.

Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
Message-id: 20221013185908.1297568-7-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
</content>
</entry>
<entry>
<title>nbd: add missing coroutine_fn annotations</title>
<updated>2022-10-07T10:11:40+00:00</updated>
<author>
<name>Paolo Bonzini</name>
</author>
<published>2022-09-22T08:49:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=8e5a19df670423d5166351c38fa5b849d13ffb2e'/>
<id>urn:sha1:8e5a19df670423d5166351c38fa5b849d13ffb2e</id>
<content type='text'>
Callers of coroutine_fn must be coroutine_fn themselves, or the call
must be within "if (qemu_in_coroutine())".  Apply coroutine_fn to
functions where this holds.

Reviewed-by: Alberto Faria &lt;afaria@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Message-Id: &lt;20220922084924.201610-11-pbonzini@redhat.com&gt;
[kwolf: Fixed up coding style]
Reviewed-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
</content>
</entry>
<entry>
<title>block: use 'unsigned' for in_flight field on driver state</title>
<updated>2022-06-29T07:57:02+00:00</updated>
<author>
<name>Denis V. Lunev</name>
</author>
<published>2022-05-30T10:39:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=1b8f777673985af366de099ad4e41d334b36fb12'/>
<id>urn:sha1:1b8f777673985af366de099ad4e41d334b36fb12</id>
<content type='text'>
This patch makes in_flight field 'unsigned' for BDRVNBDState and
MirrorBlockJob. This matches the definition of this field on BDS
and is generically correct - we should never get negative value here.

Signed-off-by: Denis V. Lunev &lt;den@openvz.org&gt;
CC: John Snow &lt;jsnow@redhat.com&gt;
CC: Vladimir Sementsov-Ogievskiy &lt;vsementsov@yandex-team.ru&gt;
CC: Kevin Wolf &lt;kwolf@redhat.com&gt;
CC: Hanna Reitz &lt;hreitz@redhat.com&gt;
CC: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@yandex-team.ru&gt;
Signed-off-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@yandex-team.ru&gt;
</content>
</entry>
<entry>
<title>nbd: trace long NBD operations</title>
<updated>2022-06-29T07:57:02+00:00</updated>
<author>
<name>Denis V. Lunev</name>
</author>
<published>2022-05-30T10:39:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=8bb100c9e2dc1fe0e33283b0c43252dbaf4eb71b'/>
<id>urn:sha1:8bb100c9e2dc1fe0e33283b0c43252dbaf4eb71b</id>
<content type='text'>
At the moment there are 2 sources of lengthy operations if configured:
* open connection, which could retry inside and
* reconnect of already opened connection
These operations could be quite lengthy and cumbersome to catch thus
it would be quite natural to add trace points for them.

This patch is based on the original downstream work made by Vladimir.

Signed-off-by: Denis V. Lunev &lt;den@openvz.org&gt;
CC: Eric Blake &lt;eblake@redhat.com&gt;
CC: Vladimir Sementsov-Ogievskiy &lt;vsementsov@yandex-team.ru&gt;
CC: Kevin Wolf &lt;kwolf@redhat.com&gt;
CC: Hanna Reitz &lt;hreitz@redhat.com&gt;
CC: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Reviewed-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@yandex-team.ru&gt;
Signed-off-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@yandex-team.ru&gt;
</content>
</entry>
<entry>
<title>nbd: Drop dead code spotted by Coverity</title>
<updated>2022-06-24T15:07:06+00:00</updated>
<author>
<name>Eric Blake</name>
</author>
<published>2022-05-16T21:05:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=2866ddd121f5ccaabf1752a8d25eab9be1309d3f'/>
<id>urn:sha1:2866ddd121f5ccaabf1752a8d25eab9be1309d3f</id>
<content type='text'>
CID 1488362 points out that the second 'rc &gt;= 0' check is now dead
code.

Reported-by: Peter Maydell &lt;peter.maydell@linaro.org&gt;
Fixes: 172f5f1a40(nbd: remove peppering of nbd_client_connected)
Signed-off-by: Eric Blake &lt;eblake@redhat.com&gt;
Message-Id: &lt;20220516210519.76135-1-eblake@redhat.com&gt;
Reviewed-by: Peter Maydell &lt;peter.maydell@linaro.org&gt;
Reviewed-by: Vladimir Sementsov-Ogievskiy &lt;v.sementsov-og@mail.ru&gt;
Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
</content>
</entry>
<entry>
<title>nbd: document what is protected by the CoMutexes</title>
<updated>2022-04-26T18:16:42+00:00</updated>
<author>
<name>Paolo Bonzini</name>
</author>
<published>2022-04-14T17:57:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=620c5cb5da57dc97f655e6218e7ca9bc896394a2'/>
<id>urn:sha1:620c5cb5da57dc97f655e6218e7ca9bc896394a2</id>
<content type='text'>
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Message-Id: &lt;20220414175756.671165-10-pbonzini@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Lukas Straub &lt;lukasstraub2@web.de&gt;
Signed-off-by: Eric Blake &lt;eblake@redhat.com&gt;
</content>
</entry>
<entry>
<title>nbd: take receive_mutex when reading requests[].receiving</title>
<updated>2022-04-26T18:16:41+00:00</updated>
<author>
<name>Paolo Bonzini</name>
</author>
<published>2022-04-14T17:57:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=a80a9a1c7397382fc4c4e6feaa8242b25cadb519'/>
<id>urn:sha1:a80a9a1c7397382fc4c4e6feaa8242b25cadb519</id>
<content type='text'>
requests[].receiving is set by nbd_receive_replies() under the receive_mutex;
Read it under the same mutex as well.  Waking up receivers on errors happens
after each reply finishes processing, in nbd_co_receive_one_chunk().
If there is no currently-active reply, there are two cases:

* either there is no active request at all, in which case no
element of request[] can have .receiving = true

* or nbd_receive_replies() must be running and owns receive_mutex;
in that case it will get back to nbd_co_receive_one_chunk() because
the socket has been shutdown, and all waiting coroutines will wake up
in turn.

Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Message-Id: &lt;20220414175756.671165-9-pbonzini@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@openvz.org&gt;
Reviewed-by: Lukas Straub &lt;lukasstraub2@web.de&gt;
Signed-off-by: Eric Blake &lt;eblake@redhat.com&gt;
</content>
</entry>
<entry>
<title>nbd: move s-&gt;state under requests_lock</title>
<updated>2022-04-26T18:16:39+00:00</updated>
<author>
<name>Paolo Bonzini</name>
</author>
<published>2022-04-14T17:57:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=dba5156c0e9c0362b7c6121f9e1c89bb9be1f227'/>
<id>urn:sha1:dba5156c0e9c0362b7c6121f9e1c89bb9be1f227</id>
<content type='text'>
Remove the confusing, and most likely wrong, atomics.  The only function
that used to be somewhat in a hot path was nbd_client_connected(),
but it is not anymore after the previous patches.

The same logic is used both to check if a request had to be reissued
and also in nbd_reconnecting_attempt().  The former cases are outside
requests_lock, while nbd_reconnecting_attempt() does have the lock,
therefore the two have been separated in the previous commit.
nbd_client_will_reconnect() can simply take s-&gt;requests_lock, while
nbd_reconnecting_attempt() can inline the access now that no
complicated atomics are involved.

Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Message-Id: &lt;20220414175756.671165-8-pbonzini@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@openvz.org&gt;
Reviewed-by: Lukas Straub &lt;lukasstraub2@web.de&gt;
Signed-off-by: Eric Blake &lt;eblake@redhat.com&gt;
</content>
</entry>
<entry>
<title>nbd: code motion and function renaming</title>
<updated>2022-04-26T18:16:38+00:00</updated>
<author>
<name>Paolo Bonzini</name>
</author>
<published>2022-04-14T17:57:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=8d45185cb76fa1dd7c3309940a967dc42d8619d4'/>
<id>urn:sha1:8d45185cb76fa1dd7c3309940a967dc42d8619d4</id>
<content type='text'>
Prepare for the next patch, so that the diff is less confusing.

nbd_client_connecting is moved closer to the definition point.

nbd_client_connecting_wait() is kept only for the reconnection
logic; when it is used to check if a request has to be reissued,
use the renamed function nbd_client_will_reconnect().  In the
next patch, the two cases will have different locking requirements.

Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Message-Id: &lt;20220414175756.671165-7-pbonzini@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@openvz.org&gt;
Reviewed-by: Lukas Straub &lt;lukasstraub2@web.de&gt;
Signed-off-by: Eric Blake &lt;eblake@redhat.com&gt;
</content>
</entry>
<entry>
<title>nbd: use a QemuMutex to synchronize yanking, reconnection and coroutines</title>
<updated>2022-04-26T18:16:37+00:00</updated>
<author>
<name>Paolo Bonzini</name>
</author>
<published>2022-04-14T17:57:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=ee19d953ecff53908a645d38a1b913fdf15a72f4'/>
<id>urn:sha1:ee19d953ecff53908a645d38a1b913fdf15a72f4</id>
<content type='text'>
The condition for waiting on the s-&gt;free_sema queue depends on
both s-&gt;in_flight and s-&gt;state.  The latter is currently using
atomics, but this is quite dubious and probably wrong.

Because s-&gt;state is written in the main thread too, for example by
the yank callback, it cannot be protected by a CoMutex.  Introduce a
separate lock that can be used by nbd_co_send_request(); later on this
lock will also be used for s-&gt;state.  There will not be any contention
on the lock unless there is a yank or reconnect, so this is not
performance sensitive.

Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Message-Id: &lt;20220414175756.671165-6-pbonzini@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Lukas Straub &lt;lukasstraub2@web.de&gt;
Signed-off-by: Eric Blake &lt;eblake@redhat.com&gt;
</content>
</entry>
</feed>
