Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp196517rwd; Fri, 19 May 2023 18:11:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5iKufF9cWuPsKJzYQtxu3FReivKQCwXr7FRo1GeQAt0qwuvSeDLl1iybYj9F9N4d2PmYzi X-Received: by 2002:a05:6a20:938f:b0:103:90ab:d79 with SMTP id x15-20020a056a20938f00b0010390ab0d79mr4452433pzh.25.1684545062764; Fri, 19 May 2023 18:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684545062; cv=none; d=google.com; s=arc-20160816; b=FCiViDfk6m94BFhxhLzV2v/UR3ESu6+y50D0XM6J7v809hgplIHZFrwQJqd10w6k6U 1005niceBNvQc+lYeZptv1/MhBIv9qkwSw7Ir2LAvkkGLP23PnPmxTxl6k9moZJkmySj p4VK0pxH+fLMfbO5lBUTcL9hIGiw09ZBRJwoW3uOaSkxGtbt4RxWv6iRDVt+81Ha5wbZ 03XTp+00AwDCl+zlrLsCsxMKJTiagSd5BKDDuVhMpuiN8GIlbeZjLShFbxLahMSjmA5n FS0v0syTpk8uk5O2eKSC+fngDNE/Rdvpi6q8HaZjlnJYHI0NVBR7cJvYTbzSiDyk/EW+ kj8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dIGb/7Nt7dNT7r5bxwMphLPrFmTGpxHZQXf9F5C0+vE=; b=zOxprJQEFhO97CZXeAZbT0TVVF3pTDl2IB1KjMnLz8Dhn51icXO4EZMz5CEu+GekD6 p+q0P51H+ocpr+cWyMqyV7SIY/jy90jzxL+4o7SuXHj1+pSPEJrBAk3+gqh9qZIJbhAO 5At5Urlq+GoT7wPaDH1kxS++nG/T7nPpQOfObDFI2not2T4KItiNwwWMZfmcujnwFZcV LPqEia63sRsaY8vm+kkbwLWxfcq1h9iTGDq9vZdl95ZcLhfri9cwzn32wYACDpYS1w89 Fg7q8BpQ6vaYXIeA3clk5zkJQ7ZpQJ6scPTgJmQRb2nTVkWWlIiR4yAWzN58XWUx10X8 CpFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AZwqWMR3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020a637e03000000b0052c2b1efee2si525081pgc.339.2023.05.19.18.10.48; Fri, 19 May 2023 18:11:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AZwqWMR3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbjETADC (ORCPT + 99 others); Fri, 19 May 2023 20:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbjETACy (ORCPT ); Fri, 19 May 2023 20:02:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCBEB10D2 for ; Fri, 19 May 2023 17:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540879; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dIGb/7Nt7dNT7r5bxwMphLPrFmTGpxHZQXf9F5C0+vE=; b=AZwqWMR3vFEGbXbDSBBUGJ4eIC4uHYrvxC/0Fjf/AD9ztuOWdpbfwq3bl7bxguL9pN/RAJ iB8bFiNXXBsvXG58ioLq1l+58JCjVh4VX7iH8WP7orFaN2+PxrWRojm6525h1bka+7CcYm xn/CHimXIl9OoWgNRCFMc1gQU3WTR58= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-kv-DotIFPiO6JnwvLiQGkg-1; Fri, 19 May 2023 20:01:15 -0400 X-MC-Unique: kv-DotIFPiO6JnwvLiQGkg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D7391C05EDC; Sat, 20 May 2023 00:01:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55785492B0A; Sat, 20 May 2023 00:01:12 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig Subject: [PATCH v21 07/30] splice: Make splice from an O_DIRECT fd use copy_splice_read() Date: Sat, 20 May 2023 01:00:26 +0100 Message-Id: <20230520000049.2226926-8-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make a read splice from a file descriptor that's open O_DIRECT use copy_splice_read() to do the reading as filemap_splice_read() is unlikely to find any pagecache to splice. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #21) - Needs to be in vfs_splice_read(), not generic_file_splice_read(). fs/splice.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index fe3309ffeb26..76126b1aafcb 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -907,6 +907,12 @@ long vfs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!in->f_op->splice_read)) return warn_unsupported(in, "read"); + /* + * O_DIRECT doesn't deal with the pagecache, so we allocate a buffer, + * copy into it and splice that into the pipe. + */ + if ((in->f_flags & O_DIRECT)) + return copy_splice_read(in, ppos, pipe, len, flags); return in->f_op->splice_read(in, ppos, pipe, len, flags); } EXPORT_SYMBOL_GPL(vfs_splice_read);