From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 01/11] nvme: implement the Flush command
Date: Tue, 14 Jul 2015 17:39:22 +0200 [thread overview]
Message-ID: <1436888372-27871-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1436888372-27871-1-git-send-email-kwolf@redhat.com>
From: Christoph Hellwig <hch@lst.de>
Implement a real flush instead of faking it. This is especially important
as Qemu assume Write back cashing by default and thus requires a working
cache flush operation for data integrity.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/block/nvme.c | 19 ++++++++++++++++---
hw/block/nvme.h | 1 +
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index c6a6a0e..dc9caf0 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -207,11 +207,23 @@ static void nvme_rw_cb(void *opaque, int ret)
} else {
req->status = NVME_INTERNAL_DEV_ERROR;
}
-
- qemu_sglist_destroy(&req->qsg);
+ if (req->has_sg) {
+ qemu_sglist_destroy(&req->qsg);
+ }
nvme_enqueue_req_completion(cq, req);
}
+static uint16_t nvme_flush(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
+ NvmeRequest *req)
+{
+ req->has_sg = false;
+ block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0,
+ BLOCK_ACCT_FLUSH);
+ req->aiocb = blk_aio_flush(n->conf.blk, nvme_rw_cb, req);
+
+ return NVME_NO_COMPLETE;
+}
+
static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
NvmeRequest *req)
{
@@ -235,6 +247,7 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
}
assert((nlb << data_shift) == req->qsg.size);
+ req->has_sg = true;
dma_acct_start(n->conf.blk, &req->acct, &req->qsg,
is_write ? BLOCK_ACCT_WRITE : BLOCK_ACCT_READ);
req->aiocb = is_write ?
@@ -256,7 +269,7 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
ns = &n->namespaces[nsid - 1];
switch (cmd->opcode) {
case NVME_CMD_FLUSH:
- return NVME_SUCCESS;
+ return nvme_flush(n, ns, cmd, req);
case NVME_CMD_WRITE:
case NVME_CMD_READ:
return nvme_rw(n, ns, cmd, req);
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index b6ccb65..bf3a3cc 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -638,6 +638,7 @@ typedef struct NvmeRequest {
struct NvmeSQueue *sq;
BlockAIOCB *aiocb;
uint16_t status;
+ bool has_sg;
NvmeCqe cqe;
BlockAcctCookie acct;
QEMUSGList qsg;
--
1.8.3.1
next prev parent reply other threads:[~2015-07-14 15:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-14 15:39 [Qemu-devel] [PULL 00/11] Block layer patches for 2.4.0-rc1 Kevin Wolf
2015-07-14 15:39 ` Kevin Wolf [this message]
2015-07-14 15:39 ` [Qemu-devel] [PULL 02/11] nvme: properly report volatile write caches Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 03/11] block: Move bdrv_attach_child() calls up the call chain Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 04/11] block: Introduce bdrv_open_child() Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 05/11] block: Introduce bdrv_unref_child() Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 06/11] block: Reorder cleanups in bdrv_close() Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 07/11] block: Fix backing file child when modifying graph Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 08/11] rbd: remove unused constants and fields Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 09/11] MAINTAINERS: update email address Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 10/11] rbd: make qemu's cache setting override any ceph setting Kevin Wolf
2015-07-14 15:39 ` [Qemu-devel] [PULL 11/11] rbd: fix ceph settings precedence Kevin Wolf
2015-07-14 17:50 ` [Qemu-devel] [PULL 00/11] Block layer patches for 2.4.0-rc1 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436888372-27871-2-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).