Re: Something seems weird at main-n287304-8a14fcd23a20
- In reply to: Konstantin Belousov : "Re: Something seems weird at main-n287304-8a14fcd23a20"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 08 Jul 2026 15:50:12 UTC
On Wed, Jul 08, 2026 at 05:55:56PM +0300, Konstantin Belousov wrote:
> ...
> > Hope this helps finding a fix!
>
> Try this
>
> commit 6c34a1e68116cfcebd327fbe93bcf0428dec1ae1
> Author: Konstantin Belousov <kib@FreeBSD.org>
> Date: Wed Jul 8 17:54:25 2026 +0300
>
> kern_filewrite(): unconditionally calculate cnt
>
> Fixes: dfad790c8cca ("sendfile: stop abusing kern_writev()")
>
> diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
> index 079bd7b347d7..d5145d6cf322 100644
> --- a/sys/kern/sys_generic.c
> +++ b/sys/kern/sys_generic.c
> @@ -595,9 +595,9 @@ kern_filewrite(struct thread *td, int fd, struct file *fp, struct uio *auio,
> #endif
> cnt = auio->uio_resid;
> error = fo_write(fp, auio, td->td_ucred, flags, td);
> + cnt -= auio->uio_resid;
> #ifdef KTRACE
> if (ktruio != NULL) {
> - cnt -= auio->uio_resid;
> if (error == 0)
> ktruio->uio_resid = cnt;
> ktrgenio(fd, UIO_WRITE, ktruio, error);
The above worked for me:
freebeast(16.0-C)[1] uname -aUK
FreeBSD freebeast.catwhisker.org 16.0-CURRENT FreeBSD 16.0-CURRENT #628 main-n287304-8a14fcd23a20-dirty: Wed Jul 8 15:37:10 UTC 2026 root@freebeast.catwhisker.org:/common/S3/obj/usr/src/amd64.amd64/sys/GENERIC amd64 1600019 1600019
freebeast(16.0-C)[2] ls -lT s3
-rw-r--r-- 1 david wheel 12490214 Jul 8 08:42:09 2026 s3
freebeast(16.0-C)[3] scp !$ albert:/tmp
scp s3 albert:/tmp
s3 100% 12MB 106.2MB/s 00:00
freebeast(16.0-C)[4]
freebeast(16.0-C)[1] git -C /usr/src status
On branch main
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: sys/kern/sys_generic.c
no changes added to commit (use "git add" and/or "git commit -a")
freebeast(16.0-C)[2] git -C /usr/src -P diff sys/kern/sys_generic.c
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index 079bd7b347d7..d5145d6cf322 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -595,9 +595,9 @@ kern_filewrite(struct thread *td, int fd, struct file *fp, struct uio *auio,
#endif
cnt = auio->uio_resid;
error = fo_write(fp, auio, td->td_ucred, flags, td);
+ cnt -= auio->uio_resid;
#ifdef KTRACE
if (ktruio != NULL) {
- cnt -= auio->uio_resid;
if (error == 0)
ktruio->uio_resid = cnt;
ktrgenio(fd, UIO_WRITE, ktruio, error);
Peace,
david
--
David H. Wolfskill david@catwhisker.org
See https://www.catwhisker.org/~david/publickey.gpg for my public key.