From owner-freebsd-current Sun Aug 11 6:29:33 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4040137B400; Sun, 11 Aug 2002 06:29:30 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id E8F8A43E4A; Sun, 11 Aug 2002 06:29:28 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id XAA17008; Sun, 11 Aug 2002 23:29:26 +1000 Date: Sun, 11 Aug 2002 23:34:24 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Maxim Konovalov Cc: Gavin Atkinson , , Subject: Re: sendfile(2) is broken (Was: ftpd problem: Input/output error) In-Reply-To: <20020811140826.J68457-100000@news1.macomnet.ru> Message-ID: <20020811232049.B20418-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 11 Aug 2002, Maxim Konovalov wrote: > 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. I think the caller (do_sendfile() here?) is at fault for not passing a non-NULL aresid. The EIO case is basically a kludge to handle short i/o's. Since the caller hasn't passed a place to return the (residual) i/o count, it can't even tell if a short i/o occurred, so we pretend that short i/o's are i/o errors. There are a lot of sloppy callers that pass a null aresid. But these are less broken than link_aout_load_file() and link_elf_load_file which pass a non-null one and then never check it. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message