mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
nbd patches for 2019-08-15
- Addition of InetSocketAddress keep-alive - Addition of BDRV_REQ_PREFETCH for more efficient copy-on-read - Initial refactoring in preparation of NBD reconnect -----BEGIN PGP SIGNATURE----- iQEcBAABCAAGBQJdVaRZAAoJEKeha0olJ0NqrGoIAJSvVLMDeWZIkHr3CQ5AbMHy 6IHUntBwv4PEHw0FyyDU7lLgEWubTwe/7RfvyJ69kQYSJLjvHa3KEic0aa7SOETK hGUlSoIFHEugi+XDcYyy9EG+ItUR7jnunkwomxvFRm4XzjEHFO9ck8fOS+uq/23e LGDHwdoZI6vawUPftbBuRAlB3egCEcBtTWXYMk8lm3MXHOHL7O18DRkfWvwcHfl6 mNIKgTVMtl1gYoJznCUmC5VLHL4jQy+kSNXnyHBQOEEvTcORu0EztJS81H+BODni sxa9seem7JL9NLUTmkJsbGfSM6RKdfypX34oik9yakqUnXRrlxkxI+IX26XfdQ4= =2MAO -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-08-15' into staging nbd patches for 2019-08-15 - Addition of InetSocketAddress keep-alive - Addition of BDRV_REQ_PREFETCH for more efficient copy-on-read - Initial refactoring in preparation of NBD reconnect # gpg: Signature made Thu 15 Aug 2019 19:28:41 BST # gpg: using RSA key A7A16B4A2527436A # gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full] # gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full] # gpg: aka "[jpeg image of size 6874]" [full] # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A * remotes/ericb/tags/pull-nbd-2019-08-15: block/nbd: refactor nbd connection parameters block/nbd: add cmdline and qapi parameter reconnect-delay block/nbd: move from quit to state block/nbd: use non-blocking io channel for nbd negotiation block/nbd: split connection_co start out of nbd_client_connect nbd: improve CMD_CACHE: use BDRV_REQ_PREFETCH block/stream: use BDRV_REQ_PREFETCH block: implement BDRV_REQ_PREFETCH qapi: Add InetSocketAddress member keep-alive Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
c6a2225a5a
11 changed files with 233 additions and 121 deletions
43
nbd/server.c
43
nbd/server.c
|
@ -2105,12 +2105,15 @@ static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
req->data = blk_try_blockalign(client->exp->blk, request->len);
|
||||
if (req->data == NULL) {
|
||||
error_setg(errp, "No memory");
|
||||
return -ENOMEM;
|
||||
if (request->type != NBD_CMD_CACHE) {
|
||||
req->data = blk_try_blockalign(client->exp->blk, request->len);
|
||||
if (req->data == NULL) {
|
||||
error_setg(errp, "No memory");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (request->type == NBD_CMD_WRITE) {
|
||||
if (nbd_read(client->ioc, req->data, request->len, "CMD_WRITE data",
|
||||
errp) < 0)
|
||||
|
@ -2195,7 +2198,7 @@ static coroutine_fn int nbd_do_cmd_read(NBDClient *client, NBDRequest *request,
|
|||
int ret;
|
||||
NBDExport *exp = client->exp;
|
||||
|
||||
assert(request->type == NBD_CMD_READ || request->type == NBD_CMD_CACHE);
|
||||
assert(request->type == NBD_CMD_READ);
|
||||
|
||||
/* XXX: NBD Protocol only documents use of FUA with WRITE */
|
||||
if (request->flags & NBD_CMD_FLAG_FUA) {
|
||||
|
@ -2207,7 +2210,7 @@ static coroutine_fn int nbd_do_cmd_read(NBDClient *client, NBDRequest *request,
|
|||
}
|
||||
|
||||
if (client->structured_reply && !(request->flags & NBD_CMD_FLAG_DF) &&
|
||||
request->len && request->type != NBD_CMD_CACHE)
|
||||
request->len)
|
||||
{
|
||||
return nbd_co_send_sparse_read(client, request->handle, request->from,
|
||||
data, request->len, errp);
|
||||
|
@ -2215,7 +2218,7 @@ static coroutine_fn int nbd_do_cmd_read(NBDClient *client, NBDRequest *request,
|
|||
|
||||
ret = blk_pread(exp->blk, request->from + exp->dev_offset, data,
|
||||
request->len);
|
||||
if (ret < 0 || request->type == NBD_CMD_CACHE) {
|
||||
if (ret < 0) {
|
||||
return nbd_send_generic_reply(client, request->handle, ret,
|
||||
"reading from file failed", errp);
|
||||
}
|
||||
|
@ -2234,6 +2237,28 @@ static coroutine_fn int nbd_do_cmd_read(NBDClient *client, NBDRequest *request,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* nbd_do_cmd_cache
|
||||
*
|
||||
* Handle NBD_CMD_CACHE request.
|
||||
* Return -errno if sending fails. Other errors are reported directly to the
|
||||
* client as an error reply.
|
||||
*/
|
||||
static coroutine_fn int nbd_do_cmd_cache(NBDClient *client, NBDRequest *request,
|
||||
Error **errp)
|
||||
{
|
||||
int ret;
|
||||
NBDExport *exp = client->exp;
|
||||
|
||||
assert(request->type == NBD_CMD_CACHE);
|
||||
|
||||
ret = blk_co_preadv(exp->blk, request->from + exp->dev_offset, request->len,
|
||||
NULL, BDRV_REQ_COPY_ON_READ | BDRV_REQ_PREFETCH);
|
||||
|
||||
return nbd_send_generic_reply(client, request->handle, ret,
|
||||
"caching data failed", errp);
|
||||
}
|
||||
|
||||
/* Handle NBD request.
|
||||
* Return -errno if sending fails. Other errors are reported directly to the
|
||||
* client as an error reply. */
|
||||
|
@ -2247,8 +2272,10 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,
|
|||
char *msg;
|
||||
|
||||
switch (request->type) {
|
||||
case NBD_CMD_READ:
|
||||
case NBD_CMD_CACHE:
|
||||
return nbd_do_cmd_cache(client, request, errp);
|
||||
|
||||
case NBD_CMD_READ:
|
||||
return nbd_do_cmd_read(client, request, data, errp);
|
||||
|
||||
case NBD_CMD_WRITE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue