[OpenAFS-port-darwin] Is this an OSX or an OpenAFS problem

Henry B. Hotz hotz@jpl.nasa.gov
Fri, 2 Apr 2004 15:30:28 -0800


I hope the cross-posting isn't a big problem.  I'm not sure if this 
is a Darwin or an OpenAFS issue.

We have a checkpointing facility implemented with mmap().  It works 
correctly on all platforms, including OSX, unless it's done on OSX in 
AFS.  Even there it works except that garbage is appended to (I 
assume) the next page boundary.  We're working around it by 
truncating the file after the checkpoint.

Following is a demo program for the problem.

OSX version is 10.2.8, OpenAFS version is 1.2.10a.  I haven't tried 
it under 10.3.  OpenAFS 1.2.8 had a similar, possibly identical, 
problem.

>Date: Fri, 02 Apr 2004 12:58:03 -0800
>From: Dave Skinner <dave@akkt.jpl.nasa.gov>
>Subject: OpenAFS on Macosx Problem Example
>To: Henry.Hotz@jpl.jpl.nasa.gov
>Original-recipient: rfc822;Henry.Hotz@jpl.jpl.nasa.gov
>
>Hank:
>
>Below the dashed line is the C code for a program that illustrates
>the problem in version 1.2.10a of OpenAFS on MacOS X machines.
>On the local disk, the resulting file "tempdata" is 395 bytes
>in size, but on AFS the resulting file "tempdata" is 4096 bytes
>in size.
>
>Dave Skinner
>
>P.S. The resulting file "tempdata" is always 395 bytes in size
>under AFS on hp_ux, linux, sgi, and sun_solaris machines.
>Furthermore, the AFS used on linux is OpenAFS.
>
>----------------------------------------------------------------------
>
>#include <stdio.h>
>#include <sys/types.h>
>#include <sys/stat.h>
>#include <fcntl.h>
>#include <unistd.h>
>#include <sys/mman.h>
>
>main()
>{
>	FILE *fd;
>	int i;
>	int intfd;
>	int istat;
>	long addr;
>	long size;
>
>	/* establish file */
>	fd = fopen("tempdata", "w");
>	(void) fclose(fd);
>	size=395;
>	/* open file */
>	intfd = open("tempdata", O_RDWR);
>	printf("intfd=%d\n",intfd);
>	/* truncate file to desired length */
>	istat = truncate("tempdata",(off_t)size);
>	printf("istat=%d\n",istat);
>	/* mmap file */
>	addr = (long)mmap((caddr_t)0, (size_t)size,
>		(PROT_READ | PROT_WRITE), MAP_SHARED, intfd, 0);
>	printf("addr=%d\n",addr);
>	/* load the file */
>	for(i=0; i<size; ++i)
>	{
>		*((char *)addr+i)='\n';
>	}
>	printf("done loading\n");
>	/* msync file */
>	istat = msync((caddr_t)addr, (size_t)size, MS_SYNC);
>	printf("istat=%d\n",istat);
>	/* close file */
>	(void) close(intfd);
>}


-- 
The opinions expressed in this message are mine,
not those of Caltech, JPL, NASA, or the US Government.
Henry.B.Hotz@jpl.nasa.gov, or hbhotz@oxy.edu