From owner-freebsd-questions@FreeBSD.ORG Sun Mar 30 23:33:32 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9EC70106566C for ; Sun, 30 Mar 2008 23:33:32 +0000 (UTC) (envelope-from heathn@gmail.com) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.178]) by mx1.freebsd.org (Postfix) with ESMTP id 64DB98FC17 for ; Sun, 30 Mar 2008 23:33:32 +0000 (UTC) (envelope-from heathn@gmail.com) Received: by wa-out-1112.google.com with SMTP id k17so1641284waf.3 for ; Sun, 30 Mar 2008 16:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=XsasMo6w9jch6MIUqd8DQrt+5IS7HSmiaBRkqrLWo1M=; b=CQDA82TcXHNOU2jmUGRqzorq4po20myS/iNMDh4aJPekfJyQIRwpvAUS4yJ54J7Yfi9JcowRyTo2Lsmb9QjW7gi6g2rHn+DP4VwgV+zMU9OS3+lUWKMYBb58iodWHDQ0+5RWbcnjPNaaw63Zi90xlrGgc5uaD7MOTsROmKT86ro= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=kmJi47LGpUcb81sDLBNSJJWAFHQ129aRcQ2cAkr8SZSvsrG8Ujnn9aJR9iXI/aOeGOqWMhEgOasoEHDg21I6SPPMQ6+tFPJDxx8cgTjBzUpDQKLHsTltZHVISbn5/CTaolyQb589JzaOnC1rwlXlcVUTQ2S1A6RVYHDTa39SHHM= Received: by 10.115.79.1 with SMTP id g1mr8798202wal.2.1206918479374; Sun, 30 Mar 2008 16:07:59 -0700 (PDT) Received: by 10.114.158.4 with HTTP; Sun, 30 Mar 2008 16:07:59 -0700 (PDT) Message-ID: <92e211670803301607w32fc48ffl7438476e4f273cc3@mail.gmail.com> Date: Sun, 30 Mar 2008 17:07:59 -0600 From: "Heath Nielson" To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Non-Blocking write over NFS fails X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Mar 2008 23:33:32 -0000 Hi all. It's been some time since posted here but I hope someone can see if I'm doing something stupid or if I really have found a problem. On my FreeBSD 7 client (192.168.0.50) I mounted an NFS-share from a FreeBSD 7 server (192.168.0.5). When I try to write a large file from the client to the share in non-blocking mode, the write() call always returns EAGAIN. I whipped up a small little test program to illustrate the behavior: #include #include #include #include #include #include #include int main(int argc, char* argv[]) { int bufSz = 1172767; fprintf(stderr, "Creating file: %s\n", argv[1]); int fd = open(argv[1], O_CREAT|O_RDWR); if(fd < 0) perror(0); int ret = fcntl(fd, F_SETFL, O_NONBLOCK); if(ret < 0) { perror(0); } char* buf = (char*)malloc(bufSz); memset(buf, 0, bufSz); ret = -1; while(ret < 0) { ret = write(fd, buf, bufSz); fprintf(stderr, "write: %d\n", ret); if(ret < 0) perror(0); sleep(1); } free(buf); close(fd); return 0; } If the size is one byte less (1172766) the write succeeds so I guess I'm hitting some buffer limit. The mount in an NFSv3 mount and the error occurs both over UDP and TCP. When I do a tcpdump from the client, I see (NFS over TCP): 01:47:18.308353 IP 192.168.0.50.835170573 > 192.168.0.5.nfs: 112 lookup fh 1073,399698/4993024 "t.txt" 01:47:18.308548 IP 192.168.0.5.nfs > 192.168.0.50.835170573: reply ok 120 lookup ERROR: No such file or directory 01:47:18.308575 IP 192.168.0.50.835170574 > 192.168.0.5.nfs: 144 create fh 1073,399698/4993024 "t.txt" 01:47:18.308856 IP 192.168.0.5.nfs > 192.168.0.50.835170574: reply ok 272 create fh 1073,399698/4993038 01:47:18.409715 IP 192.168.0.50.859 > 192.168.0.5.nfsd: . ack 2113663444 win 16588 None of the data appears to be sent over the wire. The program loops indefinitely returning EAGAIN with the write() call. When I run the program with a smaller buffer size I get: 01:50:31.624967 IP 192.168.0.50.835170584 > 192.168.0.5.nfs: 112 lookup fh 1073,399698/4993024 "t.txt" 01:50:31.625116 IP 192.168.0.5.nfs > 192.168.0.50.835170584: reply ok 120 lookup ERROR: No such file or directory 01:50:31.625140 IP 192.168.0.50.835170585 > 192.168.0.5.nfs: 144 create fh 1073,399698/4993024 "t.txt" 01:50:31.625411 IP 192.168.0.5.nfs > 192.168.0.50.835170585: reply ok 272 create fh 1073,399698/4993039 01:50:31.626582 IP 192.168.0.50.835170586 > 192.168.0.5.nfs: 1448 write fh 1073,399698/4993039 32768 (32768) bytes @ 0 01:50:31.626592 IP 192.168.0.50.0 > 192.168.0.5.nfs: 1448 null 01:50:31.626598 IP 192.168.0.50.0 > 192.168.0.5.nfs: 1448 null 01:50:31.626605 IP 192.168.0.50.0 > 192.168.0.5.nfs: 1448 null 01:50:31.626612 IP 192.168.0.50.0 > 192.168.0.5.nfs: 1448 null 01:50:31.626625 IP 192.168.0.50.0 > 192.168.0.5.nfs: 1448 null 01:50:31.626633 IP 192.168.0.50.0 > 192.168.0.5.nfs: 1448 null 01:50:31.627062 IP 192.168.0.5.nfsd > 192.168.0.50.859: . ack 175520546 win 28946 [....] 01:50:31.726744 IP 192.168.0.5.nfsd > 192.168.0.50.859: . ack 1172801 win 28946 01:50:31.727005 IP 192.168.0.5.nfs > 192.168.0.50.835170621: reply ok 164 write [|nfs] Since I'm not familiar with the NFS code does anyone know if this should work (or not)? If it is a problem, where should I go looking for the source of the problem? I'm assuming somewhere in src/sys/nfsclient. Thanks, Heath (Please CC me since I'm not on the list)