From: Pekka Enberg <penberg@kernel.org>
To: kvm@vger.kernel.org
Cc: Pekka Enberg <penberg@kernel.org>,
Asias He <asias.hejun@gmail.com>,
Cyrill Gorcunov <gorcunov@gmail.com>, Ingo Molnar <mingo@elte.hu>,
Prasad Joshi <prasadjoshi124@gmail.com>,
Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH 4/9] kvm tools, qcow: Introduce qcow_disk_flush()
Date: Sat, 9 Jul 2011 16:02:37 +0300 [thread overview]
Message-ID: <1310216563-17503-5-git-send-email-penberg@kernel.org> (raw)
In-Reply-To: <1310216563-17503-1-git-send-email-penberg@kernel.org>
This patch introduces a QCOW specific qcow_disk_flush() in preparation for
delaying QCOW metadata writeout until VIRTIO_BLK_T_FLUSH time.
Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
tools/kvm/disk/qcow.c | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/tools/kvm/disk/qcow.c b/tools/kvm/disk/qcow.c
index 939bc61..1a6a969 100644
--- a/tools/kvm/disk/qcow.c
+++ b/tools/kvm/disk/qcow.c
@@ -244,7 +244,7 @@ static ssize_t qcow_read_cluster(struct qcow *q, u64 offset, void *dst, u32 dst_
length = dst_len;
mutex_lock(&q->mutex);
- l2_table_offset = table->l1_table[l1_idx] & ~header->oflag_mask;
+ l2_table_offset = be64_to_cpu(table->l1_table[l1_idx]) & ~header->oflag_mask;
if (!l2_table_offset)
goto zero_cluster;
@@ -400,7 +400,7 @@ static ssize_t qcow_write_cluster(struct qcow *q, u64 offset, void *buf, u32 src
mutex_lock(&q->mutex);
- l2t_off = table->l1_table[l1t_idx] & ~header->oflag_mask;
+ l2t_off = be64_to_cpu(table->l1_table[l1t_idx]) & ~header->oflag_mask;
if (l2t_off) {
/* read and cache l2 table */
l2t = qcow_read_l2_table(q, l2t_off);
@@ -440,7 +440,7 @@ static ssize_t qcow_write_cluster(struct qcow *q, u64 offset, void *buf, u32 src
}
/* Update the in-core entry */
- table->l1_table[l1t_idx] = l2t_off;
+ table->l1_table[l1t_idx] = cpu_to_be64(l2t_off);
}
/* Capture the state of the consistent QCOW image */
@@ -520,6 +520,11 @@ static ssize_t qcow_nowrite_sector(struct disk_image *disk, u64 sector, void *sr
return -1;
}
+static int qcow_disk_flush(struct disk_image *disk)
+{
+ return fsync(disk->fd);
+}
+
static int qcow_disk_close(struct disk_image *disk)
{
struct qcow *q;
@@ -546,6 +551,7 @@ static struct disk_image_operations qcow_disk_readonly_ops = {
static struct disk_image_operations qcow_disk_ops = {
.read_sector = qcow_read_sector,
.write_sector = qcow_write_sector,
+ .flush = qcow_disk_flush,
.close = qcow_disk_close,
};
@@ -553,7 +559,6 @@ static int qcow_read_l1_table(struct qcow *q)
{
struct qcow_header *header = q->header;
struct qcow_table *table = &q->table;
- u64 i;
table->table_size = header->l1_size;
@@ -561,14 +566,7 @@ static int qcow_read_l1_table(struct qcow *q)
if (!table->l1_table)
return -1;
- if (pread_in_full(q->fd, table->l1_table, sizeof(u64) *
- table->table_size, header->l1_table_offset) < 0)
- return -1;
-
- for (i = 0; i < table->table_size; i++)
- be64_to_cpus(&table->l1_table[i]);
-
- return 0;
+ return pread_in_full(q->fd, table->l1_table, sizeof(u64) * table->table_size, header->l1_table_offset);
}
static void *qcow2_read_header(int fd)
--
1.7.0.4
next prev parent reply other threads:[~2011-07-09 13:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-09 13:02 [PATCH 0/9] kvm tools, qcow: Improve QCOW performance Pekka Enberg
2011-07-09 13:02 ` [PATCH 1/9] kvm tools, qcow: Rename struct qcow_l2_cache to struct qcow_l2_table Pekka Enberg
2011-07-09 13:02 ` [PATCH 2/9] kvm tools, qcow: Use 'struct qcow_l2_table' instead of untyped array Pekka Enberg
2011-07-09 13:02 ` [PATCH 3/9] kvm tools, qcow: Fix locking issues Pekka Enberg
2011-07-09 13:02 ` Pekka Enberg [this message]
2011-07-09 13:02 ` [PATCH 5/9] kvm tools, qcow: Delayed L1 table writeout Pekka Enberg
2011-07-09 13:02 ` [PATCH 6/9] kvm tools, qcow: Don't fdatasync() L2 " Pekka Enberg
2011-07-09 13:02 ` [PATCH 7/9] kvm tools, qcow: Use big endian order for L2 table entries Pekka Enberg
2011-07-09 13:02 ` [PATCH 8/9] kvm tools, qcow: Delayed L2 table writeout Pekka Enberg
2011-07-09 13:02 ` [PATCH 9/9] kvm tools, qcow: Flush only dirty L2 tables Pekka Enberg
2011-07-10 17:15 ` [PATCH 0/9] kvm tools, qcow: Improve QCOW performance Ingo Molnar
2011-07-10 18:08 ` Pekka Enberg
2011-07-10 18:17 ` Ingo Molnar
2011-07-10 18:38 ` Pekka Enberg
2011-07-11 9:31 ` Kevin Wolf
2011-07-11 9:41 ` Pekka Enberg
2011-07-11 10:29 ` Kevin Wolf
2011-07-11 10:32 ` Pekka Enberg
2011-07-11 10:36 ` Ingo Molnar
2011-07-11 10:44 ` Pekka Enberg
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=1310216563-17503-5-git-send-email-penberg@kernel.org \
--to=penberg@kernel.org \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=prasadjoshi124@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.