Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Aug 2002 14:28:38 +0400 (MSD)
From:      Maxim Konovalov <maxim@FreeBSD.org>
To:        Gavin Atkinson <gavin@ury.york.ac.uk>
Cc:        current@FreeBSD.org, <rwatson@FreeBSD.org>
Subject:   sendfile(2) is broken (Was: ftpd problem: Input/output error)
Message-ID:  <20020811140826.J68457-100000@news1.macomnet.ru>
In-Reply-To: <Pine.BSF.4.33.0208101431050.38162-100000@ury.york.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help

Hello,

On 14:43+0100, Aug 10, 2002, Gavin Atkinson wrote:

>
> Hi,
>
> For a few months now I have been seeing the following problems with the
> ftpd in current. When transferring a large file, ftpd seems to
> consistantly fail after almost all of the file hass been transferred. The
> example transcript below shows all but 4096 bytes of a file being
> transferred before stopping. This also happens across networks, with
> 4-stable ftp clients - i am confident that it is the ftp server in
> current.
>
> gavin@epsilon:/home/gavin> grep ^ftp /etc/inetd.conf
> ftp     stream  tcp     nowait  root    /usr/libexec/ftpd       ftpd -ll
>
> gavin@epsilon:/home/gavin> ls -l foo
> -rw-------  1 gavin  users  31969280 Aug  4 18:19 foo
>
> gavin@epsilon:/home/gavin> ftp localhost
> Trying ::1...
> ftp: connect to address ::1: Connection refused
> Trying 127.0.0.1...
> Connected to localhost.
> 220 epsilon.ury.york.ac.uk FTP server (Version 6.00LS) ready.
> Name (localhost:gavin):
> 331 Password required for gavin.
> Password:
> 230 User gavin logged in.
> Remote system type is UNIX.
> Using binary mode to transfer files.
> ftp> lcd test
> Local directory now /usr/home/gavin/test
> ftp> get foo
> local: foo remote: foo
> 229 Entering Extended Passive Mode (|||49152|)
> 150 Opening BINARY mode data connection for 'foo' (31969280 bytes).
>  99% |************************************ | 31216 KB    3.25 MB/s    00:09
> 426 Data connection: Input/output error.
> 31965184 bytes received in 00:09 (3.25 MB/s)
> ftp>
>
> gavin@epsilon:/home/gavin> ls -l test/foo
> -rw-r--r--  1 gavin  users  31965184 Aug  4 18:19 test/foo
>
> epsilon# tail -3
> /var/log/ftp.log
> Aug 10 14:28:28 epsilon ftpd[345]: connection from localhost (127.0.0.1)
> Aug 10 14:29:03 epsilon ftpd[345]: FTP LOGIN FROM localhost as gavin
> Aug 10 14:29:36 epsilon ftpd[345]: get /usr/home/gavin/foo = 31965184 bytes
>
> As can be seen, the file is 31969280 bytes in size, but ftpd only sends
> 31963184 bytes. The log file reads the smaller size.
>
> World and kernel are from source supped midnight GMT 10th August. I can
> help debug this or provide an account for someone else to look at this
> problem.

This is sendfile(2) mis-behaviour arised after rev.1.109
sys/kern/uipc_syscalls.c but I think the real problem in vn_rdwr(),
sys/kern/vfs_vnops.c. Here is my patch but I really need somebody with
vfs clue. I CC'ed Robert Watson as an author of sendfile(2)
modification and our vfs expert.

Index: sys/kern/vfs_vnops.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/vfs_vnops.c,v
retrieving revision 1.159
diff -u -r1.159 vfs_vnops.c
--- sys/kern/vfs_vnops.c	8 Aug 2002 12:45:30 -0000	1.159
+++ sys/kern/vfs_vnops.c	11 Aug 2002 10:19:47 -0000
@@ -401,7 +401,7 @@
 	if (aresid)
 		*aresid = auio.uio_resid;
 	else
-		if (auio.uio_resid && error == 0)
+		if (auio.uio_resid && error != 0)
 			error = EIO;
 	if ((ioflg & IO_NODELOCKED) == 0) {
 		if (rw == UIO_WRITE)

%%%

With this patch sendfile(2) and ftpd(8) work as expected but I cannot
believe vn_rdwr() has been broken since 1994.

As a temporal solution you can revert rev. 1.109 uipc_syscalls.c,
recompile and reinstall your kernel.

-- 
Maxim Konovalov, maxim@FreeBSD.org


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020811140826.J68457-100000>