From: Andre Przywara <andre.przywara@amd.com>
To: keir.fraser@eu.citrix.com
Cc: xen-devel@lists.xensource.com
Subject: [PATCH 1/2] tools - fix and use ROUNDUP macro (bug 1430 part 1)
Date: Wed, 3 Jun 2009 01:27:32 +0200 [thread overview]
Message-ID: <4A25B564.1060809@amd.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 831 bytes --]
Hi,
as pointed out in Xen Bugzilla 1430 in the blktap QCOW driver the
rounding function is wrong in line 824 of block-qcow.c.
This patch replaces this (and other roundings) with the already existing
ROUNDUP macro (and fixes the usual macro pitfall).
(This alone does not fix the bug, the next patch is still needed)
Please also apply to the bugfix trees.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Regards,
Andre.
--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 488-3567-12
----to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Jochen Polster; Thomas M. McCoy; Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
[-- Attachment #2: blktap_roundup.patch --]
[-- Type: text/plain, Size: 2053 bytes --]
# HG changeset patch
# User Andre Przywara <andre.przywara@amd.com>
# Date 1243981525 -7200
# Node ID 3c62e9afafc6a70cb897ea77a99d5da1f6b9652e
# Parent f72d26c0000292889cfe3a85008d2c4482fee772
fix and use ROUNDUP macro in blktap/qcow
diff -r f72d26c00002 -r 3c62e9afafc6 tools/blktap/drivers/block-qcow.c
--- a/tools/blktap/drivers/block-qcow.c Tue Jun 02 11:50:16 2009 +0100
+++ b/tools/blktap/drivers/block-qcow.c Wed Jun 03 00:25:25 2009 +0200
@@ -55,7 +55,7 @@
#define ROUNDUP(l, s) \
({ \
(uint64_t)( \
- (l + (s - 1)) - ((l + (s - 1)) % s)); \
+ ((l) + ((s) - 1)) - (((l) + ((s) - 1)) % (s))); \
})
#undef IOCB_IDX
@@ -800,14 +800,14 @@
/* read the level 1 table */
shift = s->cluster_bits + s->l2_bits;
- s->l1_size = (header->size + (1LL << shift) - 1) >> shift;
+ s->l1_size = ROUNDUP(header->size, 1LL << shift);
s->l1_table_offset = header->l1_table_offset;
/*allocate a 4Kbyte multiple of memory*/
l1_table_size = s->l1_size * sizeof(uint64_t);
if (l1_table_size % 4096 > 0) {
- l1_table_size = ((l1_table_size >> 12) + 1) << 12;
+ l1_table_size = ROUNDUP(l1_table_size, 4096);
}
ret = posix_memalign((void **)&s->l1_table, 4096, l1_table_size);
if (ret != 0) goto fail;
@@ -821,7 +821,7 @@
lseek(fd, 0, SEEK_SET);
l1_table_block = l1_table_size + s->l1_table_offset;
- l1_table_block = l1_table_block + 512 - (l1_table_block % 512);
+ l1_table_block = ROUNDUP(l1_table_block, 512);
ret = posix_memalign((void **)&buf2, 4096, l1_table_block);
if (ret != 0) goto fail;
if (read(fd, buf2, l1_table_block) != l1_table_block)
@@ -1226,11 +1226,11 @@
header_size = (header_size + 7) & ~7;
if (header_size % 4096 > 0) {
- header_size = ((header_size >> 12) + 1) << 12;
+ header_size = ROUNDUP(header_size, 4096);
}
shift = header.cluster_bits + header.l2_bits;
- l1_size = ((size * 512) + (1LL << shift) - 1) >> shift;
+ l1_size = ROUNDUP(size * 512, 1LL << shift);
header.l1_table_offset = cpu_to_be64(header_size);
DPRINTF("L1 Table offset: %d, size %d\n",
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
reply other threads:[~2009-06-02 23:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4A25B564.1060809@amd.com \
--to=andre.przywara@amd.com \
--cc=keir.fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.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.