Browse files

Merge branch 'master' of github.com:wscullin/collfs

Conflicts:
	collfs.c
  • Loading branch information...
2 parents 4e166fd + abe9210 commit c23d8ac73f145da9f3b8b513c7c80806ef40cd46 @jedbrown jedbrown committed Feb 17, 2012
Showing with 11 additions and 8 deletions.
  1. +1 −1 Makefile
  2. +10 −7 collfs.c
View
2 Makefile
@@ -1,5 +1,5 @@
#CC = gcc -m64
-CC = gcc
+CC = mpicc
#MPICC = /opt/mpich2/bin/mpicc
#MPICC = gcc -m64
MPICC = mpicc
View
17 collfs.c
@@ -226,6 +226,7 @@ static int collfs_open(const char *pathname, int flags, mode_t mode)
mem = NULL;
if (!rank) {
mem = ((collfs_mmap_fp) unwrap.mmap)(0, totallen, PROT_READ, MAP_PRIVATE, fd, 0);
+ ((collfs_lseek_fp) unwrap.lseek)(fd, 0, SEEK_SET);
} else {
/* Don't use shm_open() here because the shared memory segment is fixed at boot time. */
fd = NextFD++;
@@ -385,23 +386,25 @@ static void *collfs_mmap(void *addr, size_t len, int prot, int flags, int fildes
}
else {
debug_printf(2, "%p requested of length %zd, but link->mem = %p and link->mem+link->totallen = %p",
- addr, len, link->mem, (void*)((char*)link->mem+link->len));
+ addr, len, link->mem, (void*)((char*)link->mem+link->totallen));
set_error(EACCES, "addr < (void*)( (char*) link->mem + off) || addr < (void*) (char*) link->mem+link->totallen");
}
}
if (flags & MAP_SHARED ) {
set_error(ENOTSUP, "flags & MAP_SHARED: cannot do MAP_SHARED for a collective fd");
return MAP_FAILED;
}
- if (len > link->len) {
+ if (len > link->totallen) {
if (link->refct==1) { // no clients have mmaped this file, safe to remap/realloc
+ size_t totallen;
debug_printf(2, "reallocating to size %zd on offset %zd", len, off);
+ totallen = extend_to_page(len);
MPI_Comm_rank(CommStack->comm, &rank);
if (!rank) {
- ((collfs_munmap_fp) unwrap.munmap)(link->mem,link->len);
- mem = ((collfs_mmap_fp) unwrap.mmap)(addr, len, prot, flags, link->fd, off);
+ ((collfs_munmap_fp) unwrap.munmap)(link->mem,link->totallen);
+ mem = ((collfs_mmap_fp) unwrap.mmap)(addr, totallen, prot, flags, link->fd, off);
} else {
- mem = realloc(link->mem, extend_to_page(len));
+ mem = realloc(link->mem, totallen);
}
gotmem = !!mem;
MPI_Allreduce(MPI_IN_PLACE, &gotmem, 1, MPI_INT, MPI_LAND, CommStack->comm);
@@ -411,11 +414,11 @@ static void *collfs_mmap(void *addr, size_t len, int prot, int flags, int fildes
}
link->mem = mem;
link->len = len;
- link->totallen = extend_to_page(len);
+ link->totallen = totallen;
link->offset = off;
}
else {
- set_error(EOVERFLOW, "off + len > link->len");
+ set_error(EOVERFLOW, "off + len > link->totallen");
}
}
if (off < 0) {

0 comments on commit c23d8ac

Please sign in to comment.