[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [IA64] The blktap driver hardcodes PAGE_SIZE. Change it to use getpagesize(),



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 43bd4b01df9f77a3115273cc1529ec734709d685
# Parent  3352b5dc6a7c37e58a62f927520ab72642ef8b81
[IA64] The blktap driver hardcodes PAGE_SIZE. Change it to use getpagesize(),
thereby allowing it to build on ia64.

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
---
 tools/blktap/drivers/tapdisk.c |   15 +++++++++------
 tools/blktap/lib/blktaplib.h   |    6 +++---
 2 files changed, 12 insertions(+), 9 deletions(-)

diff -r 3352b5dc6a7c -r 43bd4b01df9f tools/blktap/drivers/tapdisk.c
--- a/tools/blktap/drivers/tapdisk.c    Fri Jul 14 11:45:15 2006 +0100
+++ b/tools/blktap/drivers/tapdisk.c    Fri Jul 14 11:46:28 2006 +0100
@@ -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 3352b5dc6a7c -r 43bd4b01df9f tools/blktap/lib/blktaplib.h
--- a/tools/blktap/lib/blktaplib.h      Fri Jul 14 11:45:15 2006 +0100
+++ b/tools/blktap/lib/blktaplib.h      Fri Jul 14 11:46:28 2006 +0100
@@ -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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.