Re: 4.9.0 regression in pipe-backed iov_iter with systemd-nspawn

From: Alan J. Wylie
Date: Fri Jan 13 2017 - 04:55:43 EST


at 09:33 on Fri 13-Jan-2017 Al Viro (viro@xxxxxxxxxxxxxxxxxx) wrote:

> > 1735 splice(5, NULL, 1, NULL, 9223372036854775807, 0) = -1 EAGAIN (Resource temporarily unavailable)
>
> Lovely... So it was getting -EAGAIN all along. Just in case - could you
> try the delta below and see if it triggers? Simply to exclude the possibility
> that it *is* this call of splice() and the change has somehow buggered cleanup
> after the kernel_readv() failure...


$ git checkout linux-4.9.y
$ git apply patch1

$ uname -a
Linux frodo 4.9.3-dirty #1 SMP PREEMPT Fri Jan 13 09:44:42 GMT 2017 x86_64 AMD FX(tm)-8350 Eight-Core Processor AuthenticAMD GNU/Linux

# ps axfu | grep -A10 cron
root 987 0.0 0.0 18764 2128 ? Ss 09:47 0:00 /usr/sbin/cron
root 1662 0.0 0.0 27340 2160 ? S 09:51 0:00 \_ /usr/sbin/cron
root 1664 0.0 0.0 9840 1148 ? Ss 09:51 0:00 \_ /bin/bash -c date; /work/chroot-shared/test.sh; date
root 1668 0.0 0.0 9840 2652 ? S 09:51 0:00 | \_ /bin/bash /work/chroot-shared/test.sh
root 1667 0.0 0.0 76156 5576 ? S 09:51 0:00 \_ /usr/sbin/sendmail -FCronDaemon -odi -oem -oi -t
root 1669 0.0 0.0 76144 5412 ? S 09:51 0:00 \_ /usr/sbin/postdrop -r

Another hang.

# dmesg | tail
[ 22.352442] r8169 0000:03:00.0: loading /lib/firmware/4.9.3-dirty/rtl_nic/rtl8168e-3.fw failed with error -2
[ 22.408814] r8169 0000:03:00.0: direct-loading rtl_nic/rtl8168e-3.fw
[ 22.408821] fw_set_page_data: fw-rtl_nic/rtl8168e-3.fw buf=ffff92b7b1cb8c80 data=ffffad1641179000 size=3872
[ 22.536043] r8169 0000:03:00.0 enp3s0: link down
[ 22.536079] r8169 0000:03:00.0 enp3s0: link down
[ 24.873801] r8169 0000:03:00.0 enp3s0: link up
[ 24.874766] br0: port 1(enp3s0) entered blocking state
[ 24.876622] br0: port 1(enp3s0) entered forwarding state
[ 24.878560] IPv6: ADDRCONF(NETDEV_CHANGE): br0: link becomes ready
[ 219.683974] nr: 0->16, cur: 5->5, buffers: 16->16
#

>
> diff --git a/fs/splice.c b/fs/splice.c
> index 873d83104e79..1a2d1bc7f19e 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -393,6 +393,9 @@ static ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
> size_t offset, dummy, copied = 0;
> ssize_t res;
> int i;
> + unsigned nrbufs = pipe->nrbufs,
> + curbuf = pipe->curbuf,
> + buffers = pipe->buffers;
>
> if (pipe->nrbufs == pipe->buffers)
> return -EAGAIN;
> @@ -445,6 +448,16 @@ static ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
> put_page(pages[i]);
> kvfree(pages);
> iov_iter_advance(&to, copied); /* truncates and discards */
> + if (res == -EAGAIN && (
> + pipe->nrbufs != nrbufs ||
> + pipe->curbuf != curbuf ||
> + pipe->buffers != buffers)
> + ) {
> + printk(KERN_ERR "nr: %d->%d, cur: %d->%d, buffers: %d->%d\n",
> + nrbufs, pipe->nrbufs,
> + curbuf, pipe->curbuf,
> + buffers, pipe->buffers);
> + }
> return res;
> }
>

--
Alan J. Wylie http://www.wylie.me.uk/

Dance like no-one's watching. / Encrypt like everyone is.
Security is inversely proportional to convenience