mirror of https://github.com/xemu-project/xemu.git
nbd patches for 2017-09-25
- Eric Blake: nbd-client: Use correct macro parenthesization - Vladimir Sementsov-Ogievskiy: 0/3 nbd client refactoring and fixing -----BEGIN PGP SIGNATURE----- Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAABCAAGBQJZyQcJAAoJEKeha0olJ0NqGugIAJhLUn/vJjOXvoB7A+ipyXSL M5LhwIdgwRV/47qHzb4Io7ed0QmZ5ogp+XJLmgNBWiykEkTqgdc2CJVZPNTQQ3t4 3rfmesk+J1wQd2+RqTD6qOnhzxnWvUIWyCUbhnnxollKrNxLsDgw5T8VNUMDTKbw tyLnuMlp2/8uQ4HRDOlj1HFyPkQz2oa3MQKWM05WANHBisQkkGvrs878AqOmyJFP UUWFwACpyhy5gGvJLIdksgD2TdoF6RQRTP6WOX4AV8U7hWInlKtrIht+zmij7Tir Li38cUVwY9UQqn5NBJmKtmq2n7qnb3dD0MK1WRbOhv26EcsFwKjk03ytJiKV7O0= =8z+7 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-09-25' into staging nbd patches for 2017-09-25 - Eric Blake: nbd-client: Use correct macro parenthesization - Vladimir Sementsov-Ogievskiy: 0/3 nbd client refactoring and fixing # gpg: Signature made Mon 25 Sep 2017 14:39:21 BST # gpg: using RSA key 0xA7A16B4A2527436A # gpg: Good signature from "Eric Blake <eblake@redhat.com>" # gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" # gpg: aka "[jpeg image of size 6874]" # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A * remotes/ericb/tags/pull-nbd-2017-09-25: block/nbd-client: nbd_co_send_request: fix return code block/nbd-client: simplify check in nbd_co_receive_reply block/nbd-client: refactor nbd_co_receive_reply nbd-client: Use correct macro parenthesization Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
2b521a654c
|
@ -31,8 +31,8 @@
|
|||
#include "qapi/error.h"
|
||||
#include "nbd-client.h"
|
||||
|
||||
#define HANDLE_TO_INDEX(bs, handle) ((handle) ^ ((uint64_t)(intptr_t)bs))
|
||||
#define INDEX_TO_HANDLE(bs, index) ((index) ^ ((uint64_t)(intptr_t)bs))
|
||||
#define HANDLE_TO_INDEX(bs, handle) ((handle) ^ (uint64_t)(intptr_t)(bs))
|
||||
#define INDEX_TO_HANDLE(bs, index) ((index) ^ (uint64_t)(intptr_t)(bs))
|
||||
|
||||
static void nbd_recv_coroutines_wake_all(NBDClientSession *s)
|
||||
{
|
||||
|
@ -161,6 +161,8 @@ static int nbd_co_send_request(BlockDriverState *bs,
|
|||
NULL) < 0) {
|
||||
rc = -EIO;
|
||||
}
|
||||
} else if (rc >= 0) {
|
||||
rc = -EIO;
|
||||
}
|
||||
qio_channel_set_cork(s->ioc, false);
|
||||
} else {
|
||||
|
@ -178,26 +180,27 @@ err:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static void nbd_co_receive_reply(NBDClientSession *s,
|
||||
NBDRequest *request,
|
||||
NBDReply *reply,
|
||||
QEMUIOVector *qiov)
|
||||
static int nbd_co_receive_reply(NBDClientSession *s,
|
||||
NBDRequest *request,
|
||||
QEMUIOVector *qiov)
|
||||
{
|
||||
int ret;
|
||||
int i = HANDLE_TO_INDEX(s, request->handle);
|
||||
|
||||
/* Wait until we're woken up by nbd_read_reply_entry. */
|
||||
s->requests[i].receiving = true;
|
||||
qemu_coroutine_yield();
|
||||
s->requests[i].receiving = false;
|
||||
*reply = s->reply;
|
||||
if (reply->handle != request->handle || !s->ioc || s->quit) {
|
||||
reply->error = EIO;
|
||||
if (!s->ioc || s->quit) {
|
||||
ret = -EIO;
|
||||
} else {
|
||||
if (qiov && reply->error == 0) {
|
||||
assert(s->reply.handle == request->handle);
|
||||
ret = -s->reply.error;
|
||||
if (qiov && s->reply.error == 0) {
|
||||
assert(request->len == iov_size(qiov->iov, qiov->niov));
|
||||
if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov,
|
||||
NULL) < 0) {
|
||||
reply->error = EIO;
|
||||
ret = -EIO;
|
||||
s->quit = true;
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +220,8 @@ static void nbd_co_receive_reply(NBDClientSession *s,
|
|||
s->in_flight--;
|
||||
qemu_co_queue_next(&s->free_sema);
|
||||
qemu_co_mutex_unlock(&s->send_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int nbd_co_request(BlockDriverState *bs,
|
||||
|
@ -224,7 +229,6 @@ static int nbd_co_request(BlockDriverState *bs,
|
|||
QEMUIOVector *qiov)
|
||||
{
|
||||
NBDClientSession *client = nbd_get_client_session(bs);
|
||||
NBDReply reply;
|
||||
int ret;
|
||||
|
||||
assert(!qiov || request->type == NBD_CMD_WRITE ||
|
||||
|
@ -232,12 +236,11 @@ static int nbd_co_request(BlockDriverState *bs,
|
|||
ret = nbd_co_send_request(bs, request,
|
||||
request->type == NBD_CMD_WRITE ? qiov : NULL);
|
||||
if (ret < 0) {
|
||||
reply.error = -ret;
|
||||
} else {
|
||||
nbd_co_receive_reply(client, request, &reply,
|
||||
request->type == NBD_CMD_READ ? qiov : NULL);
|
||||
return ret;
|
||||
}
|
||||
return -reply.error;
|
||||
|
||||
return nbd_co_receive_reply(client, request,
|
||||
request->type == NBD_CMD_READ ? qiov : NULL);
|
||||
}
|
||||
|
||||
int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
|
||||
|
|
Loading…
Reference in New Issue