WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [BLKTAP] Use lartge enough types to expre

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [BLKTAP] Use lartge enough types to express parameters of large block devices.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Nov 2006 17:00:37 +0000
Delivery-date: Tue, 28 Nov 2006 09:00:14 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 4666710bfc559a92737c3998dc7790418be8ab63
# Parent  99878f3f74eec9981c48d0e5c76e6ba269ae470f
[BLKTAP] Use lartge enough types to express parameters of large block devices.

While the kernel side of blktap drivers is using 64-bit sector numbers
correctly when reporting disk sizing, the userspace parts where this
dat is actually generated is truncating at 32-bit. There are 3 variables
related to disk sizing which are used in the kernel/userspace code
'size', 'sector size' & 'info'. In kernel space these are treated as being
unsigned long long, unsigned long, and unsigned int, respectively. In
the blktap userspace code this were all varyingly long, unsigned long.
This mismatch caused 32-bit wraparound on large disks. The attached
patch updates the blktap userspace to use the same data types as
kernel space for all these params, thus both fixing the 32-bit bug &
giving the code consistency.

This patch has been tested both by comparing /proc/partitions in the
guest, with the image size seen in the host, and by using Stephen
Tweedie's 'verify-data' tool on a variety of multi-TB sized disks.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tools/blktap/drivers/blktapctrl.c |    2 +-
 tools/blktap/drivers/blktapctrl.h |    6 +++---
 tools/blktap/drivers/tapdisk.h    |    6 +++---
 tools/blktap/lib/blktaplib.h      |   12 ++++++------
 tools/blktap/lib/xenbus.c         |    2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff -r 99878f3f74ee -r 4666710bfc55 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Tue Nov 28 13:48:47 2006 +0000
+++ b/tools/blktap/drivers/blktapctrl.c Tue Nov 28 13:50:32 2006 +0000
@@ -420,7 +420,7 @@ static int read_msg(int fd, int msgtype,
                        image->secsize = img->secsize;
                        image->info = img->info;
 
-                       DPRINTF("Received CTLMSG_IMG: %lu, %lu, %lu\n",
+                       DPRINTF("Received CTLMSG_IMG: %llu, %lu, %u\n",
                                image->size, image->secsize, image->info);
                        if(msgtype != CTLMSG_IMG) ret = 0;
                        break;
diff -r 99878f3f74ee -r 4666710bfc55 tools/blktap/drivers/blktapctrl.h
--- a/tools/blktap/drivers/blktapctrl.h Tue Nov 28 13:48:47 2006 +0000
+++ b/tools/blktap/drivers/blktapctrl.h Tue Nov 28 13:50:32 2006 +0000
@@ -30,19 +30,19 @@
  */
 
 
-static inline long int tapdisk_get_size(blkif_t *blkif)
+static inline unsigned long long tapdisk_get_size(blkif_t *blkif)
 {
        image_t *img = (image_t *)blkif->prv;
        return img->size;
 }
 
-static inline long int tapdisk_get_secsize(blkif_t *blkif)
+static inline unsigned long tapdisk_get_secsize(blkif_t *blkif)
 {
        image_t *img = (image_t *)blkif->prv;
        return img->secsize;
 }
 
-static inline unsigned tapdisk_get_info(blkif_t *blkif)
+static inline unsigned int tapdisk_get_info(blkif_t *blkif)
 {
        image_t *img = (image_t *)blkif->prv;
        return img->info;
diff -r 99878f3f74ee -r 4666710bfc55 tools/blktap/drivers/tapdisk.h
--- a/tools/blktap/drivers/tapdisk.h    Tue Nov 28 13:48:47 2006 +0000
+++ b/tools/blktap/drivers/tapdisk.h    Tue Nov 28 13:50:32 2006 +0000
@@ -74,9 +74,9 @@ struct td_state {
        void *ring_info;
        void *fd_entry;
        char backing_file[1024]; /*Used by differencing disks, e.g. qcow*/
-       long int   sector_size;
-       uint64_t   size;
-       long int   info;
+       unsigned long      sector_size;
+       unsigned long long size;
+       unsigned int       info;
 };
 
 /* Prototype of the callback to activate as requests complete.              */
diff -r 99878f3f74ee -r 4666710bfc55 tools/blktap/lib/blktaplib.h
--- a/tools/blktap/lib/blktaplib.h      Tue Nov 28 13:48:47 2006 +0000
+++ b/tools/blktap/lib/blktaplib.h      Tue Nov 28 13:50:32 2006 +0000
@@ -97,9 +97,9 @@ typedef struct {
 } pending_req_t;
 
 struct blkif_ops {
-       long int (*get_size)(struct blkif *blkif);
-       long int (*get_secsize)(struct blkif *blkif);
-       unsigned (*get_info)(struct blkif *blkif);
+       unsigned long long (*get_size)(struct blkif *blkif);
+       unsigned long (*get_secsize)(struct blkif *blkif);
+       unsigned int (*get_info)(struct blkif *blkif);
 };
 
 typedef struct blkif {
@@ -156,9 +156,9 @@ typedef struct domid_translate {
 } domid_translate_t ;
 
 typedef struct image {
-       long int size;
-       long int secsize;
-       long int info;
+       unsigned long long size;
+       unsigned long secsize;
+       unsigned int info;
 } image_t;
 
 typedef struct msg_hdr {
diff -r 99878f3f74ee -r 4666710bfc55 tools/blktap/lib/xenbus.c
--- a/tools/blktap/lib/xenbus.c Tue Nov 28 13:48:47 2006 +0000
+++ b/tools/blktap/lib/xenbus.c Tue Nov 28 13:50:32 2006 +0000
@@ -219,7 +219,7 @@ static void ueblktap_setup(struct xs_han
        }
 
        /* Supply the information about the device to xenstore */
-       er = xs_printf(h, be->backpath, "sectors", "%lu",
+       er = xs_printf(h, be->backpath, "sectors", "%llu",
                        be->blkif->ops->get_size(be->blkif));
 
        if (er == 0) {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [BLKTAP] Use lartge enough types to express parameters of large block devices., Xen patchbot-unstable <=