direct-io.hg

changeset 10693:43bd4b01df9f

[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@hp.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jul 14 11:46:28 2006 +0100 (2006-07-14)
parents 3352b5dc6a7c
children 7bf0d46e369a
files tools/blktap/drivers/tapdisk.c tools/blktap/lib/blktaplib.h
line diff
     1.1 --- a/tools/blktap/drivers/tapdisk.c	Fri Jul 14 11:45:15 2006 +0100
     1.2 +++ b/tools/blktap/drivers/tapdisk.c	Fri Jul 14 11:46:28 2006 +0100
     1.3 @@ -83,8 +83,8 @@ static void unmap_disk(struct td_state *
     1.4  
     1.5  	drv->td_close(s);
     1.6  
     1.7 -	if (info != NULL && info->mem > 0) 
     1.8 -	        munmap(info->mem, PAGE_SIZE * BLKTAP_MMAP_REGION_SIZE);
     1.9 +	if (info != NULL && info->mem > 0)
    1.10 +	        munmap(info->mem, getpagesize() * BLKTAP_MMAP_REGION_SIZE);
    1.11  
    1.12  	ptr = s->fd_entry;
    1.13  	prev = ptr->prev;
    1.14 @@ -219,6 +219,7 @@ static int map_new_dev(struct td_state *
    1.15  	tapdev_info_t *info = s->ring_info;
    1.16  	char *devname;
    1.17  	fd_list_entry_t *ptr;
    1.18 +	int page_size;
    1.19  
    1.20  	asprintf(&devname,"%s/%s%d", BLKTAP_DEV_DIR, BLKTAP_DEV_NAME, minor);
    1.21  	tap_fd = open(devname, O_RDWR);
    1.22 @@ -230,7 +231,8 @@ static int map_new_dev(struct td_state *
    1.23  	info->fd = tap_fd;
    1.24  
    1.25  	/*Map the shared memory*/
    1.26 -	info->mem = mmap(0, PAGE_SIZE * BLKTAP_MMAP_REGION_SIZE, 
    1.27 +	page_size = getpagesize();
    1.28 +	info->mem = mmap(0, page_size * BLKTAP_MMAP_REGION_SIZE, 
    1.29  			  PROT_READ | PROT_WRITE, MAP_SHARED, info->fd, 0);
    1.30  	if ((long int)info->mem == -1) 
    1.31  	{
    1.32 @@ -240,10 +242,10 @@ static int map_new_dev(struct td_state *
    1.33  
    1.34  	/* assign the rings to the mapped memory */ 
    1.35  	info->sring = (blkif_sring_t *)((unsigned long)info->mem);
    1.36 -	BACK_RING_INIT(&info->fe_ring, info->sring, PAGE_SIZE);
    1.37 +	BACK_RING_INIT(&info->fe_ring, info->sring, page_size);
    1.38  	
    1.39  	info->vstart = 
    1.40 -	        (unsigned long)info->mem + (BLKTAP_RING_PAGES << PAGE_SHIFT);
    1.41 +	        (unsigned long)info->mem + (BLKTAP_RING_PAGES * page_size);
    1.42  
    1.43  	ioctl(info->fd, BLKTAP_IOCTL_SENDPID, process );
    1.44  	ioctl(info->fd, BLKTAP_IOCTL_SETMODE, BLKTAP_MODE_INTERPOSE );
    1.45 @@ -481,6 +483,7 @@ static void get_io_request(struct td_sta
    1.46  	struct tap_disk *drv = s->drv;
    1.47  	blkif_t *blkif = s->blkif;
    1.48  	tapdev_info_t *info = s->ring_info;
    1.49 +	int page_size = getpagesize();
    1.50  
    1.51  	if (!run) return; /*We have received signal to close*/
    1.52  
    1.53 @@ -508,7 +511,7 @@ static void get_io_request(struct td_sta
    1.54  			nsects = req->seg[i].last_sect - 
    1.55  				 req->seg[i].first_sect + 1;
    1.56  	
    1.57 -			if ((req->seg[i].last_sect >= PAGE_SIZE >> 9) ||
    1.58 +			if ((req->seg[i].last_sect >= page_size >> 9) ||
    1.59  			    (nsects <= 0))
    1.60  				continue;
    1.61  
     2.1 --- a/tools/blktap/lib/blktaplib.h	Fri Jul 14 11:45:15 2006 +0100
     2.2 +++ b/tools/blktap/lib/blktaplib.h	Fri Jul 14 11:46:28 2006 +0100
     2.3 @@ -41,7 +41,7 @@
     2.4  #include <sys/types.h>
     2.5  #include <unistd.h>
     2.6  
     2.7 -#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
     2.8 +#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, getpagesize())
     2.9  
    2.10  /* size of the extra VMA area to map in attached pages. */
    2.11  #define BLKTAP_VMA_PAGES BLK_RING_SIZE
    2.12 @@ -206,8 +206,8 @@ int xs_fire_next_watch(struct xs_handle 
    2.13      (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
    2.14  #define MMAP_VADDR(_vstart,_req,_seg)                                   \
    2.15      ((_vstart) +                                              \
    2.16 -     ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +    \
    2.17 -     ((_seg) * PAGE_SIZE))
    2.18 +     ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * getpagesize()) +    \
    2.19 +     ((_seg) * getpagesize()))
    2.20  
    2.21  /* Defines that are only used by library clients */
    2.22