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-devel

[Xen-devel] [PATCH] fix PAGE_SIZE assumptions in blktap

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] fix PAGE_SIZE assumptions in blktap
From: Alex Williamson <alex.williamson@xxxxxx>
Date: Thu, 13 Jul 2006 17:00:23 -0600
Cc: xen-ia64-devel <xen-ia64-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 13 Jul 2006 16:00:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: OSLO R&D
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
   The blktap driver likes to hard code PAGE_SIZE.  This changes it to
use getpagesize(), thereby allowing it to build on ia64.  Thanks,

        Alex

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
---

diff -r f692a0a476c5 tools/blktap/drivers/tapdisk.c
--- a/tools/blktap/drivers/tapdisk.c    Thu Jul 13 15:33:08 2006 +0100
+++ b/tools/blktap/drivers/tapdisk.c    Thu Jul 13 16:52:11 2006 -0600
@@ -83,8 +83,8 @@ static void unmap_disk(struct td_state *
 
        drv->td_close(s);
 
-       if (info != NULL && info->mem > 0) 
-               munmap(info->mem, PAGE_SIZE * BLKTAP_MMAP_REGION_SIZE);
+       if (info != NULL && info->mem > 0)
+               munmap(info->mem, getpagesize() * BLKTAP_MMAP_REGION_SIZE);
 
        ptr = s->fd_entry;
        prev = ptr->prev;
@@ -219,6 +219,7 @@ static int map_new_dev(struct td_state *
        tapdev_info_t *info = s->ring_info;
        char *devname;
        fd_list_entry_t *ptr;
+       int page_size;
 
        asprintf(&devname,"%s/%s%d", BLKTAP_DEV_DIR, BLKTAP_DEV_NAME, minor);
        tap_fd = open(devname, O_RDWR);
@@ -230,7 +231,8 @@ static int map_new_dev(struct td_state *
        info->fd = tap_fd;
 
        /*Map the shared memory*/
-       info->mem = mmap(0, PAGE_SIZE * BLKTAP_MMAP_REGION_SIZE, 
+       page_size = getpagesize();
+       info->mem = mmap(0, page_size * BLKTAP_MMAP_REGION_SIZE, 
                          PROT_READ | PROT_WRITE, MAP_SHARED, info->fd, 0);
        if ((long int)info->mem == -1) 
        {
@@ -240,10 +242,10 @@ static int map_new_dev(struct td_state *
 
        /* assign the rings to the mapped memory */ 
        info->sring = (blkif_sring_t *)((unsigned long)info->mem);
-       BACK_RING_INIT(&info->fe_ring, info->sring, PAGE_SIZE);
+       BACK_RING_INIT(&info->fe_ring, info->sring, page_size);
        
        info->vstart = 
-               (unsigned long)info->mem + (BLKTAP_RING_PAGES << PAGE_SHIFT);
+               (unsigned long)info->mem + (BLKTAP_RING_PAGES * page_size);
 
        ioctl(info->fd, BLKTAP_IOCTL_SENDPID, process );
        ioctl(info->fd, BLKTAP_IOCTL_SETMODE, BLKTAP_MODE_INTERPOSE );
@@ -481,6 +483,7 @@ static void get_io_request(struct td_sta
        struct tap_disk *drv = s->drv;
        blkif_t *blkif = s->blkif;
        tapdev_info_t *info = s->ring_info;
+       int page_size = getpagesize();
 
        if (!run) return; /*We have received signal to close*/
 
@@ -508,7 +511,7 @@ static void get_io_request(struct td_sta
                        nsects = req->seg[i].last_sect - 
                                 req->seg[i].first_sect + 1;
        
-                       if ((req->seg[i].last_sect >= PAGE_SIZE >> 9) ||
+                       if ((req->seg[i].last_sect >= page_size >> 9) ||
                            (nsects <= 0))
                                continue;
 
diff -r f692a0a476c5 tools/blktap/lib/blktaplib.h
--- a/tools/blktap/lib/blktaplib.h      Thu Jul 13 15:33:08 2006 +0100
+++ b/tools/blktap/lib/blktaplib.h      Thu Jul 13 16:52:11 2006 -0600
@@ -41,7 +41,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, getpagesize())
 
 /* size of the extra VMA area to map in attached pages. */
 #define BLKTAP_VMA_PAGES BLK_RING_SIZE
@@ -206,8 +206,8 @@ int xs_fire_next_watch(struct xs_handle 
     (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
 #define MMAP_VADDR(_vstart,_req,_seg)                                   \
     ((_vstart) +                                              \
-     ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +    \
-     ((_seg) * PAGE_SIZE))
+     ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * getpagesize()) +    \
+     ((_seg) * getpagesize()))
 
 /* Defines that are only used by library clients */
 



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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] fix PAGE_SIZE assumptions in blktap, Alex Williamson <=