RFC: NFS client patch to reduce sychronous writes

Rick Macklem rmacklem at uoguelph.ca
Thu Nov 28 00:25:46 UTC 2013


Ok, the attchment seemed to get stripped off. Here's the code.
Apologies if the mail system I use eats the whitespace, rick
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
main(int argc, char *argv[]) {
	int x, i;
	char *cp;

	printf("before open\n");
	x = open(argv[1], O_RDWR | O_CREAT, 0666);
	printf("aft open=%d\n", x);
	cp = mmap((void *)0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED,
	    x, 0);
#ifdef WRITEIT
	lseek(x, 4090, SEEK_SET);
	write(x, "B", 1);
	printf("wrote B at 4090\n");
#endif
	if (cp != NULL) {
		*(cp + 4080) = 'A';
		if (msync(cp, 0, MS_SYNC) < 0)
			printf("msync failed\n");
	}
	close(x);
}

----- Original Message -----
> > Date: Wed, 27 Nov 2013 17:50:48 -0500 (EST)
> > From: Rick Macklem <rmacklem at uoguelph.ca>
> > To: Konstantin Belousov <kostikbel at gmail.com>
> > Subject: Re: RFC: NFS client patch to reduce sychronous writes
> > 
> > Kostik wrote:
> >> Sorry, I do not understand the question. mmap(2) itself does not
> >> change
> >> file size.  But if mmaped area includes the last page, I still
> >> think
> >> that the situation I described before is possible.
> > 
> > Yes, I'll need to look at this. If it is a problem, all I can think
> > of
> > is bzeroing all new pages when they're allocated to the buffer
> > cache.
> > 
> > Thanks for looking at it, rick
> > ps: Btw, jhb@'s patch didn't have the bzeroing in it.
> 
> The ``fix'' of bzero'ing every buffer cache page was made to UFS/FFS
> for this problem and it killed write performance of the filesystem
> by nearly half. We corrected this by only doing the bzero when the
> file is mmap'ed which helped things considerably (since most files
> being written are not also bmap'ed).
> 
> 	Kirk
> 


More information about the freebsd-fs mailing list