mirror of https://github.com/xemu-project/xemu.git
nbd: Use BDRV_REQ_FUA for better FUA where supported
Rather than always flushing ourselves, let the block layer forward the FUA on to the underlying device - where all underlying layers also understand FUA, we are now more efficient; and where any underlying layer doesn't understand it, now the block layer takes care of the full flush fallback on our behalf. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1463006384-7734-2-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
37146e7eaf
commit
a0c303693e
16
nbd/server.c
16
nbd/server.c
|
@ -1038,6 +1038,7 @@ static void nbd_trip(void *opaque)
|
||||||
struct nbd_reply reply;
|
struct nbd_reply reply;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
uint32_t command;
|
uint32_t command;
|
||||||
|
int flags;
|
||||||
|
|
||||||
TRACE("Reading request.");
|
TRACE("Reading request.");
|
||||||
if (client->closing) {
|
if (client->closing) {
|
||||||
|
@ -1114,23 +1115,18 @@ static void nbd_trip(void *opaque)
|
||||||
|
|
||||||
TRACE("Writing to device");
|
TRACE("Writing to device");
|
||||||
|
|
||||||
|
flags = 0;
|
||||||
|
if (request.type & NBD_CMD_FLAG_FUA) {
|
||||||
|
flags |= BDRV_REQ_FUA;
|
||||||
|
}
|
||||||
ret = blk_pwrite(exp->blk, request.from + exp->dev_offset,
|
ret = blk_pwrite(exp->blk, request.from + exp->dev_offset,
|
||||||
req->data, request.len, 0);
|
req->data, request.len, flags);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LOG("writing to file failed");
|
LOG("writing to file failed");
|
||||||
reply.error = -ret;
|
reply.error = -ret;
|
||||||
goto error_reply;
|
goto error_reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.type & NBD_CMD_FLAG_FUA) {
|
|
||||||
ret = blk_co_flush(exp->blk);
|
|
||||||
if (ret < 0) {
|
|
||||||
LOG("flush failed");
|
|
||||||
reply.error = -ret;
|
|
||||||
goto error_reply;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nbd_co_send_reply(req, &reply, 0) < 0) {
|
if (nbd_co_send_reply(req, &reply, 0) < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue