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 7/9] kvm tools, qcow: Use big endian order for L2 table entries
Date: Sat, 9 Jul 2011 16:02:40 +0300 [thread overview]
Message-ID: <1310216563-17503-8-git-send-email-penberg@kernel.org> (raw)
In-Reply-To: <1310216563-17503-1-git-send-email-penberg@kernel.org>
Don't keep the in-memory array in CPU byte order to simplify delayed L2 table
writeout.
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 | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/tools/kvm/disk/qcow.c b/tools/kvm/disk/qcow.c
index 35408ab..c851e7f 100644
--- a/tools/kvm/disk/qcow.c
+++ b/tools/kvm/disk/qcow.c
@@ -183,7 +183,6 @@ static struct qcow_l2_table *qcow_read_l2_table(struct qcow *q, u64 offset)
struct qcow_header *header = q->header;
struct qcow_l2_table *l2t;
u64 size;
- u64 i;
size = 1 << header->l2_bits;
@@ -205,10 +204,6 @@ static struct qcow_l2_table *qcow_read_l2_table(struct qcow *q, u64 offset)
if (cache_table(q, l2t) < 0)
goto error;
- /* change cached table to CPU's byte-order */
- for (i = 0; i < size; i++)
- be64_to_cpus(&l2t->table[i]);
-
return l2t;
error:
free(l2t);
@@ -259,7 +254,7 @@ static ssize_t qcow_read_cluster(struct qcow *q, u64 offset, void *dst, u32 dst_
if (l2_idx >= l2_table_size)
goto out_error;
- clust_start = l2_table->table[l2_idx] & ~header->oflag_mask;
+ clust_start = be64_to_cpu(l2_table->table[l2_idx]) & ~header->oflag_mask;
if (!clust_start)
goto zero_cluster;
@@ -437,7 +432,7 @@ static ssize_t qcow_write_cluster(struct qcow *q, u64 offset, void *buf, u32 src
if (!f_sz)
goto error;
- clust_start = l2t->table[l2t_idx] & ~header->oflag_mask;
+ clust_start = be64_to_cpu(l2t->table[l2t_idx]) & ~header->oflag_mask;
if (!clust_start) {
clust_start = ALIGN(f_sz, clust_sz);
update_meta = true;
@@ -459,7 +454,7 @@ static ssize_t qcow_write_cluster(struct qcow *q, u64 offset, void *buf, u32 src
}
/* Update the cached level2 entry */
- l2t->table[l2t_idx] = clust_start;
+ l2t->table[l2t_idx] = cpu_to_be64(clust_start);
}
mutex_unlock(&q->mutex);
--
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 ` [PATCH 4/9] kvm tools, qcow: Introduce qcow_disk_flush() Pekka Enberg
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 ` Pekka Enberg [this message]
2011-07-09 13:02 ` [PATCH 8/9] kvm tools, qcow: Delayed " 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-8-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox