From: Alex Williamson <alex.williamson@hp.com>
To: xen-devel <xen-devel@lists.xensource.com>
Cc: xen-ia64-devel <xen-ia64-devel@lists.xensource.com>
Subject: [PATCH] fix PAGE_SIZE assumptions in blktap
Date: Thu, 13 Jul 2006 17:00:23 -0600 [thread overview]
Message-ID: <1152831623.5674.44.camel@lappy> (raw)
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@hp.com>
---
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 */
reply other threads:[~2006-07-13 23:00 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=1152831623.5674.44.camel@lappy \
--to=alex.williamson@hp.com \
--cc=xen-devel@lists.xensource.com \
--cc=xen-ia64-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.