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

Marc Olzheim zlo at
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
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 24 17:20:02 GMT 2005
>Originator:     Marc Olzheim
>Release:        FreeBSD 5.4-PRERELEASE i386
ilse mediz
System: FreeBSD 5.4-PRERELEASE FreeBSD 5.4-PRERELEASE #3: Wed Mar 23 16:18:45 CET 2005     root at  i386

	grep nfs /etc/rc.conf:


	Boot message is at

	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

	writev 60 foo on an NFS mounted filesystem.

/* 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>

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]);

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

	iovcnt = atoi(argv[1]);

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

	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)",
			(unsigned long)(iovcnt * sizeof(buffer)));

	if (close(fd))


More information about the freebsd-bugs mailing list