Date: Sat, 15 Apr 1995 03:30:14 +0400 From: "Andrey A. Chernov, Black Mage" <ache@astral.msk.su> To: current@FreeBSD.org, "John S. Dyson" <toor@jsdinc.root.com> Subject: Re: Info on VM/VFS changes since 4.4Lite Message-ID: <ZI6MmZlWWA@astral.msk.su> In-Reply-To: <199504141715.RAA05096@jsdinc.root.com>; from "John S. Dyson" at Fri, 14 Apr 1995 17:15:53 GMT References: <199504141715.RAA05096@jsdinc.root.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <199504141715.RAA05096@jsdinc.root.com> John S. Dyson
writes:
>5) The VM system and buffer cache has been merged.
> Now mmap is fully coherent with the read/write system calls. This
> is an initial implementation, and the VOP_GETPAGE and VOP_PUTPAGE
> will be compatibly added soon (Probably V2.2). For example, a
> write to a file immediately causes the data to change immediately
> in the address space of a process that might have the file mapped.
John, please, can you fix munmap() & msync() to modify modification times
as supposed and manpages promise? Now they don't touch modification
times at all. It cause impossibility to use mmap() inside INND, it
suppose modification time changing.
BTW: my local chief shows me that BSDI 2.0 can handle much more articles
quickly with INND then FreeBSD and call it "benchmark". The only one
reason exists: BSDI have INND compiled with mmap() and FreeBSD without
mmap() (it is configurable) due to modification times bug.
Here small test program to demonstrate this bug:
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/mman.h>
#include <stdio.h>
static char ICDactpath[] = "testfile";
static char *ICDactpointer;
static int ICDactfd;
static int ICDactsize;
#if defined(MAP_FILE)
#define MAP__ARG (MAP_FILE | MAP_SHARED)
#else
#define MAP__ARG (MAP_SHARED)
#endif /* defined(MAP_FILE) */
char *
ICDread()
{
struct stat Sb;
int i;
if ((ICDactfd = open(ICDactpath, O_WRONLY|O_TRUNC|O_CREAT, 0666)) < 0) {
perror("open");
fprintf(stderr, "read: cant open %s\n", ICDactpath);
exit(1);
}
for (i = 0; i < 7; i++)
write(ICDactfd, "1234567890", 10);
if (close(ICDactfd) < 0) {
perror("close");
fprintf(stderr, "Close: cant close %s\n", ICDactpath);
exit(1);
}
if ((ICDactfd = open(ICDactpath, O_RDWR)) < 0) {
perror("open");
fprintf(stderr, "read: cant open %s\n", ICDactpath);
exit(1);
}
if (fstat(ICDactfd, &Sb) < 0) {
perror("fstat");
fprintf(stderr, "read: cant fstat %d %s\n", ICDactfd, ICDactpath);
exit(1);
}
ICDactsize = Sb.st_size;
ICDactpointer = mmap((caddr_t)0, ICDactsize, PROT_READ|PROT_WRITE,
MAP__ARG, ICDactfd, (off_t)0);
if (ICDactpointer == (char *)-1) {
perror("mmap");
fprintf(stderr, "read: cant mmap %d %s\n", ICDactfd, ICDactpath);
exit(1);
}
return ICDactpointer;
}
ICDclose()
{
if (ICDactpointer) {
if (msync(ICDactpointer, ICDactsize, 0) < 0) {
perror("msync");
fprintf(stderr, "Close: cant msync %s in closeactive()\n", ICDactpath);
}
if (munmap(ICDactpointer, ICDactsize) < 0) {
perror("munmap");
fprintf(stderr, "Close: cant munmap\n", ICDactpath);
}
ICDactpointer = NULL;
if (close(ICDactfd) < 0) {
perror("close");
fprintf(stderr, "Close: cant close %s\n", ICDactpath);
exit(1);
}
}
}
ICDwrite()
{
/* No-op. */
/* ICDactsize */
if (msync(ICDactpointer, 0, 0) < 0) {
perror("msync");
fprintf(stderr, "Write: cant msync %s\n", ICDactpath);
}
}
spy() {
system("cat testfile; echo; ls -l testfile");
}
main()
{
char *file_p;
int to_sleep = 60;
file_p = ICDread();
fprintf(stderr, "Original file and time\n");
spy();
*(file_p + 20) = '\n';
#if 0
fprintf(stderr, "After 1st write to mapped region\n");
spy();
#endif
sleep(to_sleep);
*(file_p + 30) = '\n';
#if 0
fprintf(stderr, "After 2nd write to mapped region and sleep()\n");
spy();
#endif
ICDwrite();
fprintf(stderr, "After msync(..., 0)\n");
spy();
sleep(to_sleep);
ICDclose();
fprintf(stderr, "After sleep(), msync(..., size) and close()\n");
spy();
unlink(ICDactpath);
}
--
Andrey A. Chernov : And I rest so composedly, /Now, in my bed,
ache@astral.msk.su : That any beholder /Might fancy me dead -
FidoNet: 2:5020/230.3 : Might start at beholding me, /Thinking me dead.
RELCOM Team,FreeBSD Team : E.A.Poe From "For Annie" 1849
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZI6MmZlWWA>
