Date: Sun, 30 Dec 2001 11:48:20 -0800 From: Justin Erenkrantz <jerenkrantz@ebuilt.com> To: Sheldon Hearn <sheldonh@starjuice.net> Cc: Michal Mertl <mime@traveller.cz>, current@freebsd.org Subject: [PATCH] Re: ntfs and sendfile problem (corrupted data) Message-ID: <20011230194820.GB3904@ebuilt.com> In-Reply-To: <91552.1009724501@axl.seasidesoftware.co.za> References: <Pine.BSF.4.41.0112301541390.77500-100000@prg.traveller.cz> <91552.1009724501@axl.seasidesoftware.co.za>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Dec 30, 2001 at 05:01:41PM +0200, Sheldon Hearn wrote: > On Sun, 30 Dec 2001 15:47:45 +0100, Michal Mertl wrote: > > > I did use the "goto oldway;" and the problem went away. I tried to look at > > /sys/kern/uipc_syscalls.c sendfile implementation but it is too complex > > for me :-(. > > I've added your feedback to the audit trail of PR bin/31692, thanks. > > > I tried ktrace on ftpd but only saw the call to sendfile(2). If you > > give me some guidance I can try to look into problem deeper. I don't > > have any experience in kernel debugging but would like to learn it. > > No idea. I was just trying to narrow this down so we know who to nag. > > This smells like one of those things someone like dillon or bmilekic > could fix. Gents, any takers? I don't know if this is correct, but I find the usage of cnt for the loop to be very suspicious. Could you try this patch (against -CURRENT, but should apply to -STABLE)? Consider that sendfile may be executed many times and cnt will only be the value of how much was written that last iteration. Therefore, you need to check whether the *entire* file has been written. And, I would wonder with a network-based FS, it would potentially take multiple sendfile(2) calls - therefore the check against cnt is invalid. And, of course, ftpd.c isn't built against libc_r. Otherwise, I'd say to upgrade your kernel. Alfred got the libc_r sendfile working again a few weeks ago. -- justin --- libexec/ftpd/ftpd.c.old Mon Nov 19 13:52:03 2001 +++ libexec/ftpd/ftpd.c Sun Dec 30 11:33:26 2001 @@ -1811,7 +1811,7 @@ len = filesize; err = cnt = offset = 0; - while (err != -1 && cnt < filesize) { + while (err != -1 && len > 0) { err = sendfile(filefd, netfd, offset, len, (struct sf_hdtr *) NULL, &cnt, 0); byte_count += cnt; 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?20011230194820.GB3904>