From patchwork Sun Dec 18 20:30:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 9479397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 891CC60237 for ; Sun, 18 Dec 2016 20:30:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62F7628497 for ; Sun, 18 Dec 2016 20:30:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4545C2848D; Sun, 18 Dec 2016 20:30:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50D292848D for ; Sun, 18 Dec 2016 20:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753043AbcLRUaG (ORCPT ); Sun, 18 Dec 2016 15:30:06 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:51276 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751014AbcLRUaF (ORCPT ); Sun, 18 Dec 2016 15:30:05 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1cIi5r-0002ra-56; Sun, 18 Dec 2016 20:30:03 +0000 Date: Sun, 18 Dec 2016 20:30:03 +0000 From: Al Viro To: Linus Torvalds Cc: Andreas Schwab , Dave Chinner , CAI Qian , linux-xfs , xfs@oss.sgi.com, Jens Axboe , Nick Piggin , linux-fsdevel Subject: Re: [PATCH 04/12] splice: lift pipe_lock out of splice_to_pipe() Message-ID: <20161218203003.GZ1555@ZenIV.linux.org.uk> References: <20160917190023.GA8039@ZenIV.linux.org.uk> <20160923190032.GA25771@ZenIV.linux.org.uk> <20160923190326.GB2356@ZenIV.linux.org.uk> <20160923201025.GJ2356@ZenIV.linux.org.uk> <20160924035951.GN2356@ZenIV.linux.org.uk> <87shpmxrey.fsf@linux-m68k.org> <20161218201207.GY1555@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161218201207.GY1555@ZenIV.linux.org.uk> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sun, Dec 18, 2016 at 08:12:07PM +0000, Al Viro wrote: > On Sun, Dec 18, 2016 at 11:28:44AM -0800, Linus Torvalds wrote: > > On Sat, Dec 17, 2016 at 11:54 AM, Andreas Schwab wrote: > > > This break EPIPE handling inside splice when SIGPIPE is ignored: > > > > > > Before: > > > $ { sleep 1; strace -e splice pv -q /dev/zero; } | : > > > > Where is that "splice" program from? Google isn't helpful, and fedora > > doesn't seem to have it. I'm assuming it was posted in one of the > > threads, but if so I've long since lost sight of it.. > > It's pv(1), actually. I'm looking into that - debian-packaged pv reproduced > that crap. OK, I see what's going on - it's wait_for_space() lifted past the checks for lack of readers. The fix, AFAICS, is simply --- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/splice.c b/fs/splice.c index 6a2b0db5..aeba2b7 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1082,6 +1082,10 @@ EXPORT_SYMBOL(do_splice_direct); static int wait_for_space(struct pipe_inode_info *pipe, unsigned flags) { + if (unlikely(!pipe->readers)) { + send_sig(SIGPIPE, current, 0); + return -EPIPE; + } while (pipe->nrbufs == pipe->buffers) { if (flags & SPLICE_F_NONBLOCK) return -EAGAIN; @@ -1090,6 +1094,10 @@ static int wait_for_space(struct pipe_inode_info *pipe, unsigned flags) pipe->waiting_writers++; pipe_wait(pipe); pipe->waiting_writers--; + if (unlikely(!pipe->readers)) { + send_sig(SIGPIPE, current, 0); + return -EPIPE; + } } return 0; }