TDB on OpenBSD problem.

MCCALL,DON (HP-USA,ex1) don_mccall at hp.com
Fri May 4 15:36:50 GMT 2001


Hi Andrew,
I compiled and ran your test program on my test box here. (added a start and
end printf, just cause I am suspicious by nature of programs that don't talk
to me... ;->)
Note-  this is a test box, and getting no real useage, and I have not been
able to make the tdb expansion problem occur here yet.  But I saw another
post that indicated that someone else HAD gotten errors when they ran your
test program on 10.20, and 11.0 so I wanted to give you my experience as
well. 
 
HPUX 10.20: cc -Ae -D_HPUX_SOURCE -D_POSIX_SOURCE tdbtest.c -o tdbtest
HPUX 10.20: ./tdbtest
Program started
Program ended
HPUX 11.00:cc -Ae -D_HPUX_SOURCE -D_POSIX_SOURCE tdbtest.c -o tdbtest
HPUX 11.00: ./tdbtest
Program started
mismatch at 3000 (17 0)
not equal on line 58!

I have been checking our patch database for 10.20 and 11.0, and there were a
number of
issues with consistency between mmap and filesystem writes, so I believe on
the HP-UX side of things, if someone is having this issue they just need to
get the latest OS patches installed to address this.  Might  I suggest that
if we are going to remain dependent on mmap in 2.2.x, we make your little
test a part of the configure; spouting out a warning about "mmap and write
inconsistency possibility on this machine; contact your vendor for
information on possible patches to this problem" ?
I believe that PHKL_18543 is the patch that addresses this on 11.0, but I
have not had time to install and test this as of yet.

I'll let you know what I find out.

Virginia - were you able to run Tridge's test program on your 10.20 box yet?

Hope this helps,
Don
 "Reason, not volume, is the primary
differentiator between a discussion, and an
argument."

-----Original Message-----
From: tridge at samba.org [mailto:tridge at samba.org]
Sent: Friday, May 04, 2001 9:39 AM
To: jeremy at valinux.com; vmn at bom.gov.AU; samba-technical at lists.samba.org
Subject: Re: TDB on OpenBSD problem.


> I think I've just reproduced it using tdbtorture on a OpenBSD vmware
> session. I'm looking into it.

I now have a tiny test program that shows the basic problem. It seems
that on OpenBSD mmap and read are not coherent. I've written to Theo
to ask him about it.

Can those of you seeing the tdb expansion bug please try the following
test program and see if it reports an error.

btw, I think we could make tdb not rely on mmap/read coherence, but
I'd rather first understand whats going on. 

Cheers, Tridge


/*
  trivial test program to see if file IO and mmap are coherent. 
  tridge at samba.org, May 2001
*/

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/stat.h>

#define SIZE 20000

static void test(char *map, int fd, int line)
{
	unsigned char buf1[SIZE], buf2[SIZE];

	memcpy(buf1, map, SIZE);
	lseek(fd, 0, SEEK_SET);
	read(fd, buf2, SIZE);
	if (memcmp(buf1, buf2, SIZE) != 0) {
		int i;
		for (i=0;i<SIZE;i++) {
			if (buf1[i] != buf2[i]) {
				printf("mismatch at %d (%d %d)\n",
				       i, buf1[i], buf2[i]);
			}
		}
		printf("not equal on line %d!\n", line);
		exit(1);
	}
}

#ifndef MAP_FILE
#define MAP_FILE 0
#endif

int main(void)
{
	int fd;
	char *map;
	char b = 0;

	fd = open("test.dat", O_RDWR|O_CREAT|O_TRUNC, 0600);

	lseek(fd, SIZE-1, SEEK_SET);
	write(fd, &b, 1);

	map = mmap(NULL,SIZE,PROT_READ|PROT_WRITE,MAP_SHARED|MAP_FILE, fd,
0);

	map[3000] = 17;
	fsync(fd);
	test(map, fd, __LINE__);

	lseek(fd, 76, SEEK_SET);
	write(fd, &fd, sizeof(fd));
	
	test(map, fd, __LINE__);
	return 0;
}




More information about the samba-technical mailing list