From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751284AbdAMUIc (ORCPT ); Fri, 13 Jan 2017 15:08:32 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:56000 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751048AbdAMUIa (ORCPT ); Fri, 13 Jan 2017 15:08:30 -0500 Date: Fri, 13 Jan 2017 20:08:27 +0000 From: Al Viro To: Linus Torvalds Cc: "Alan J. Wylie" , Thorsten Leemhuis , linux-kernel Subject: Re: 4.9.0 regression in pipe-backed iov_iter with systemd-nspawn Message-ID: <20170113200826.GP1555@ZenIV.linux.org.uk> References: <22647.59020.331664.632444@wylie.me.uk> <22648.1838.747474.51727@wylie.me.uk> <22648.32903.752857.203733@wylie.me.uk> <20170113093359.GJ1555@ZenIV.linux.org.uk> <22648.41914.351371.678606@wylie.me.uk> <20170113102019.GK1555@ZenIV.linux.org.uk> <20170113111842.GL1555@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 13, 2017 at 11:33:18AM -0800, Linus Torvalds wrote: > What am I missing? The fact that we want to free the _tail_, not the beginning of the damn thing. > Why is "pipe_advance()" written in that incomprehensible form? Why > don't we do the pipe_buf_release() as we advance through it, instead > of doing it at the end? > > Also, the line > > buf->len = size; > > in that pipe_advance() function looks buggy. "size" is how much we > *remove* from buf->len, shouldn't we update buf->len by subtracting > size? Because it's "truncate to size", not "throw everything up to that point out". We have some amount of data pushed into pipe (in this case - 0) and we have some buffers allocated by ..._get_pages() past the end of it. Some of that we want to keep (again, in this case - none) and have the next copy_to_iter() go after those, the rest we discard.