kern/92243: sendfile(2) returns early on files > 4GB

Yar Tikhiy yar at comp.chem.msu.su
Tue Jan 31 05:00:18 PST 2006


The following reply was made to PR kern/92243; it has been noted by GNATS.

From: Yar Tikhiy <yar at comp.chem.msu.su>
To: bug-followup at FreeBSD.org, dkelly at hiwaay.net
Cc: "David G. Lawrence" <dg at dglawrence.com>, alc at FreeBSD.org
Subject: Re: kern/92243: sendfile(2) returns early on files > 4GB
Date: Tue, 31 Jan 2006 15:49:48 +0300

 Just experimented with the issue.  It appears easily reproducable
 on a local filesystem.  The problem boils down to the fact that in
 the following code:
 
    sys/kern/uipc_syscalls.c:do_sendfile()
    1864:                /*
    1865:                 * Calculate the amount to transfer. Not to exceed a page,
    1866:                 * the EOF, or the passed in nbytes.
    1867:                 */
    1868:                xfsize = obj->un_pager.vnp.vnp_size - off;
 
 obj->un_pager.vnp.vnp_size is somehow truncated to 32 bits when the
 vnode comes from disk.  I added a printf after line 1868 and I saw
 that for a recently created file, 2^32+10000 bytes in size,
 obj->un_pager.vnp.vnp_size was the full size of the file.  The
 file's vnode was presumably still cached.  However, after a reboot
 obj->un_pager.vnp.vnp_size for the same file was just 10000.
 
    # truncate -s 4294977296 ~ftp/4g
    # ftp ftp://127.1/4g
    obj->un_pager.vnp.vnp_size = 4294977296
    # reboot
    ...
    # ftp ftp://127.1/4g
    obj->un_pager.vnp.vnp_size = 10000
    # rm ~ftp/4g
    # truncate -s 4294977296 ~ftp/4g
    # ftp ftp://127.1/4g
    obj->un_pager.vnp.vnp_size = 4294977296
 
 -- 
 Yar


More information about the freebsd-bugs mailing list