1 From 34e3152b64368d4a3672084ebae565d55f320f5d Mon Sep 17 00:00:00 2001 2 From: Lucas Meneghel Rodrigues <lmr (a] redhat.com> 3 Date: Tue, 18 May 2010 10:40:15 -0300 4 Subject: [PATCH 1/2] Minor fixes to PAGE_SIZE handling 5 6 Signed-off-by: Suzuki <suzuki (a] in.ibm.com> 7 --- 8 fsx-linux.c | 10 +++++++--- 9 1 files changed, 7 insertions(+), 3 deletions(-) 10 11 diff --git a/fsx-linux.c b/fsx-linux.c 12 index a1642d2..33eb770 100644 13 --- a/fsx-linux.c 14 +++ b/fsx-linux.c 15 @@ -10,6 +10,8 @@ 16 * 17 * Small changes to work under Linux -- davej (a] suse.de 18 * 19 + * Minor fixes to PAGE_SIZE handling -- Suzuki <suzuki (a] in.ibm.com>. 20 + * 21 */ 22 23 #undef _XOPEN_SOURCE 24 @@ -74,7 +76,7 @@ int logcount = 0; /* total ops */ 25 #define OP_SKIPPED 7 26 27 #ifndef PAGE_SIZE 28 -#define PAGE_SIZE 4096 29 +#define PAGE_SIZE pagesize 30 #endif 31 #define PAGE_MASK (PAGE_SIZE - 1) 32 33 @@ -129,6 +131,7 @@ int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset); 34 FILE * fsxlogf = NULL; 35 int badoff = -1; 36 int closeopen = 0; 37 +int pagesize = 0; 38 39 static void *round_up(void *ptr, unsigned long align, unsigned long offset) 40 { 41 @@ -493,7 +496,7 @@ domapread(unsigned offset, unsigned size) 42 offset, offset + size - 1, size); 43 44 pg_offset = offset & PAGE_MASK; 45 - map_size = pg_offset + size; 46 + map_size = (pg_offset + size + PAGE_MASK) & ~PAGE_MASK; 47 48 #ifdef linux 49 if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_SHARED, fd, 50 @@ -638,7 +641,7 @@ domapwrite(unsigned offset, unsigned size) 51 } 52 } 53 pg_offset = offset & PAGE_MASK; 54 - map_size = pg_offset + size; 55 + map_size = (pg_offset + size + PAGE_MASK) & ~PAGE_MASK; 56 57 if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE, 58 MAP_FILE | MAP_SHARED, fd, 59 @@ -1106,6 +1109,7 @@ main(int argc, char **argv) 60 if (argc != 1) 61 usage(); 62 fname = argv[0]; 63 + pagesize = getpagesize(); 64 65 signal(SIGHUP, cleanup); 66 signal(SIGINT, cleanup); 67 -- 68 1.7.0.1 69 70