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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 F2405C433E0 for ; Mon, 18 Jan 2021 09:00:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DC5022227 for ; Mon, 18 Jan 2021 09:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388073AbhARI7p (ORCPT ); Mon, 18 Jan 2021 03:59:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387918AbhARI7g (ORCPT ); Mon, 18 Jan 2021 03:59:36 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B78BC061574 for ; Mon, 18 Jan 2021 00:58:56 -0800 (PST) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1l1QN8-008Aiv-Fy; Mon, 18 Jan 2021 09:58:50 +0100 Message-ID: Subject: Re: Splicing to/from a tty From: Johannes Berg To: Christoph Hellwig Cc: Oliver Giles , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Linus Torvalds , Al Viro Date: Mon, 18 Jan 2021 09:58:49 +0100 In-Reply-To: <20210118085311.GA2735@lst.de> References: <20210118085311.GA2735@lst.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-01-18 at 09:53 +0100, Christoph Hellwig wrote: > 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. Well, it clearly used to work :-) > I think just wiring > up iter_file_splice_write would work. Al? Seems to work for the simple test case that I had, at least: diff --git a/fs/pipe.c b/fs/pipe.c index c5989cfd564d..39c96845a72f 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1206,6 +1206,7 @@ const struct file_operations pipefifo_fops = { .unlocked_ioctl = pipe_ioctl, .release = pipe_release, .fasync = pipe_fasync, + .splice_write = iter_file_splice_write, }; /* johannes