Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Nov 2013 09:35:07 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Adrian Chadd <adrian@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r258613 - head/sys/kern
Message-ID:  <20131126073507.GR59496@kib.kiev.ua>
In-Reply-To: <201311260202.rAQ225Ux042665@svn.freebsd.org>
References:  <201311260202.rAQ225Ux042665@svn.freebsd.org>

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

--02rv0UQOqTxuETXn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Nov 26, 2013 at 02:02:05AM +0000, Adrian Chadd wrote:
> Author: adrian
> Date: Tue Nov 26 02:02:05 2013
> New Revision: 258613
> URL: http://svnweb.freebsd.org/changeset/base/258613
>=20
> Log:
>   Refactor out the sendfile copyout in order to make vn_sendfile()
>   callable from the kernel.
>  =20
>   Right now vn_sendfile() can't be called from anything other than
>   a syscall handler _and_ return the number of bytes queued.
>   This simply moves the copyout() to do_sendfile() so that any kernel
>   code can initiate vn_sendfile() outside of a syscall context.
>  =20
>   Tested:
>  =20
>   * tiny little sendfile program spitting things out a tcp socket
>  =20
>   Sponsored by:	Netflix, Inc.
>=20
> Modified:
>   head/sys/kern/uipc_syscalls.c
>=20
> Modified: head/sys/kern/uipc_syscalls.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/kern/uipc_syscalls.c	Tue Nov 26 01:30:10 2013	(r258612)
> +++ head/sys/kern/uipc_syscalls.c	Tue Nov 26 02:02:05 2013	(r258613)
> @@ -1908,6 +1908,7 @@ do_sendfile(struct thread *td, struct se
>  	struct file *fp;
>  	cap_rights_t rights;
>  	int error;
> +	off_t sbytes;
> =20
>  	/*
>  	 * File offset must be positive.  If it goes beyond EOF
> @@ -1947,9 +1948,11 @@ do_sendfile(struct thread *td, struct se
>  	}
> =20
>  	error =3D fo_sendfile(fp, uap->s, hdr_uio, trl_uio, uap->offset,
> -	    uap->nbytes, uap->sbytes, uap->flags, compat ? SFK_COMPAT : 0, td);
> +	    uap->nbytes, &sbytes, uap->flags, compat ? SFK_COMPAT : 0, td);
>  	fdrop(fp, td);
> -
> +	if (uap->sbytes !=3D NULL) {
> +		copyout(&sbytes, uap->sbytes, sizeof(off_t));
> +	}
>  out:
>  	free(hdr_uio, M_IOV);
>  	free(trl_uio, M_IOV);
> @@ -2546,7 +2549,7 @@ out:
>  		td->td_retval[0] =3D 0;
>  	}
>  	if (sent !=3D NULL) {
> -		copyout(&sbytes, sent, sizeof(off_t));
> +		(*sent) =3D sbytes;
>  	}
>  	if (obj !=3D NULL)
>  		vm_object_deallocate(obj);

This breaks compat32 sendfile(2).

--02rv0UQOqTxuETXn
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQIcBAEBAgAGBQJSlE8qAAoJEJDCuSvBvK1BJFIP/2c7BJE4lMbe2PKQqSkqY9OV
ZSJHPcVZfX53Jw1tBgx/RVDzA05G/4Iq2gecMWddLL5hJH+IV7KSrlvInAhdrI9B
zawrHMC6FqaGdI2OFAqZYH7Atb+3cLR8dz2sd06s73JE2krO5QFkFAeyp5DSyZe4
F4W+MlJwctea/r6WL18uMnz3izgGsE4obUONvZQKUxlpmgwiqTbo88Wge2j1Lu1u
F+2TmpWP+tBw5zG1nTnpmKBZ0NEuUzPJfoBuDyUoQ/MGf8lXXtt6sdUgB+SR0YIG
wQnsTzw/MEiKxCT+Ca2h5Zyzx4nJveoXSChF9uJ9epWkb6PbYMrwkDegCD+ECB7K
etEtFskvshyA8e8BNWvDiaWuOu12E2vztEheHXPitmygRdoHG8FBt1P0w9SNzCLr
3ZE4IQYPoifgavly0lj3P2C0dnAiSqU2qRbJTTH8zmog8v0sZgfXHm4j/+q8AxOe
/GCzqGyWI0e8INoJ30kV9bfNA1JQn5RqhQiapJESYZrNadznyKPe1YTTFp6d/2Fi
aHZ+fjiI8frAS5hE/QsXA3rjLtwQ+5bRUhGBGYr9zTo4m2q6LxKuBaVdcKvcxLLZ
xYf8PK4KshxA/UD3OTflpxqhxU9chNfReGO9Nv4PpkOjz2V+uFAWLU1Ywx1NwbTz
jsBD+fCgYFjJZDhStxeG
=d6N4
-----END PGP SIGNATURE-----

--02rv0UQOqTxuETXn--



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