nbd: move s->state under requests_lock
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Apr 2022 17:57:54 +0000 (19:57 +0200)
committerEric Blake <eblake@redhat.com>
Tue, 26 Apr 2022 18:16:39 +0000 (13:16 -0500)
commitdba5156c0e9c0362b7c6121f9e1c89bb9be1f227
tree926943dbe6f7b1248c10b30cc3ae0d77a7a58adf
parent8d45185cb76fa1dd7c3309940a967dc42d8619d4
nbd: move s->state under requests_lock

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->requests_lock, while
nbd_reconnecting_attempt() can inline the access now that no
complicated atomics are involved.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20220414175756.671165-8-pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Lukas Straub <lukasstraub2@web.de>
Signed-off-by: Eric Blake <eblake@redhat.com>
block/nbd.c