From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEE18C433E0 for ; Mon, 18 Jan 2021 08:54:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6251722226 for ; Mon, 18 Jan 2021 08:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388012AbhARIxz (ORCPT ); Mon, 18 Jan 2021 03:53:55 -0500 Received: from verein.lst.de ([213.95.11.211]:47062 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387937AbhARIxx (ORCPT ); Mon, 18 Jan 2021 03:53:53 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id 66CE968AFE; Mon, 18 Jan 2021 09:53:11 +0100 (CET) Date: Mon, 18 Jan 2021 09:53:11 +0100 From: Christoph Hellwig To: Johannes Berg Cc: Oliver Giles , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Christoph Hellwig , Linus Torvalds , Al Viro Subject: Re: Splicing to/from a tty Message-ID: <20210118085311.GA2735@lst.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 16, 2021 at 05:46:33PM +0100, Johannes Berg wrote: > > For my case, I attempted to instead implement splice_write and > > splice_read in tty_fops; I managed to get splice_write working calling > > ld->ops->write, but splice_read is not so simple because the > > tty_ldisc_ops read method expects a userspace buffer. So I cannot see > > how to implement this without either (a) using set_fs, or (b) > > implementing iter ops on all line disciplines. > > > > Is splice()ing between a tty and a pipe worth supporting at all? Not a > > big deal for my use case at least, but it used to work. > > Is it even strictly related to the tty? > > I was just now looking into why my cgit/fcgi/nginx setup no longer > works, and the reason is getting -EINVAL from sendfile() when the input > is a file and the output is a pipe(). Yes, pipes do not support ->splice_write currenly. I think just wiring up iter_file_splice_write would work. Al? > So I wrote a simple test program (below) and that errors out on kernel > 5.10.4, while it works fine on the 5.9.16 I currently have. Haven't > tried reverting anything yet, but now that I haev a test program it > should be simple to even bisect. > > johannes > > > #include > #include > #include > #include > #include > #include > #include > > int main(int argc, char **argv) > { > int in = open(argv[0], O_RDONLY); > int p[2], out; > off_t off = 0; > int err; > > assert(in >= 0); > assert(pipe(p) >= 0); > out = p[1]; > err = sendfile(out, in, &off, 1024); > if (err < 0) > perror("sendfile"); > assert(err == 1024); > > return 0; > } > ---end quoted text---