kern/79208: Deadlock or starvation doing heavy NFS writes with writev

Marc Olzheim zlo at zlo.nu
Thu Mar 24 09:20:03 PST 2005


>Number:         79208
>Category:       kern
>Synopsis:       Deadlock or starvation doing heavy NFS writes with writev
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 24 17:20:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Marc Olzheim
>Release:        FreeBSD 5.4-PRERELEASE i386
>Organization:
ilse mediz
>Environment:
System: FreeBSD techno.ilse.net 5.4-PRERELEASE FreeBSD 5.4-PRERELEASE #3: Wed Mar 23 16:18:45 CET 2005     root at rave.ilse.net:/usr/obj/usr/src/sys/SE3DEBUG  i386

	grep nfs /etc/rc.conf:

	nfs_client_enable="YES"
	nfs_reserved_port_only="YES"
	nfs_server_enable="YES"

	Boot message is at
	http://www.stack.nl/~marcolz/FreeBSD/techno.bootlog.txt


>Description:
	Doing 60 MB of writev() over NFS, results in exactly 58638336
	bytes (57264K) ariving at the NFS server, _during_ which the
	machine becomes unresponsive to almost everything but pings...
	The resposiveness stops before 10 MB are written, maybe even as
	soon as the writev() starts.

	Running an "rtprio 0 cat" on console gives me a cat that
	responds to ^T (stty status ^T) with:

	load: 0.72  cmd: cat 673 [flswai] 0.00u 0.00s 0% 652k
	load: 8.87  cmd: cat 673 [flswai] 0.00u 0.29s 0% 652k

	and that still consumes input, but doesn't output anything
	anymore.


>How-To-Repeat:
	writev 60 foo on an NFS mounted filesystem.

Source:
----------------------------------------------------------------------
/* Copyright (C) 2005 by ilse technology - Marc Olzheim */

#include	<err.h>
#include	<fcntl.h>
#include	<stdio.h>
#include	<stdlib.h>
#include	<strings.h>
#include	<sys/stat.h>
#include	<sys/types.h>
#include	<sys/uio.h>
#include	<unistd.h>

int
main(int argc, char *argv[])
{
	int		fd, i, iovcnt;
	struct iovec	*iov;
	char		buffer[1048576];
	ssize_t		written;

	if (3 != argc)
	{
		fprintf(stderr, "Usage: %s <megabytes> <file>\n", argv[0]);
		return(1);
	}

	if (-1 == (fd = open(argv[2], O_WRONLY | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)))
		perror("open()");

	iovcnt = atoi(argv[1]);

	iov = malloc(iovcnt * sizeof(struct iovec));
	if (!iov)
		perror("malloc()");

	for (i = 0; i < iovcnt; i++)
	{
		iov[i].iov_base = buffer;
		iov[i].iov_len = sizeof(buffer);
	}

	bzero(buffer, sizeof(buffer));

	written = writev(fd, iov, iovcnt);
	if (written == (ssize_t)-1)
		err(1, "writev()");

	if (written != (ssize_t)(iovcnt * sizeof(buffer)))
		err(1, "Short write (%ld of %lu)",
			(long)written,
			(unsigned long)(iovcnt * sizeof(buffer)));

	if (close(fd))
		perror("close()");

	return(0);
}
----------------------------------------------------------------------
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list