From patchwork Mon May 22 13:49:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D18FC77B73 for ; Mon, 22 May 2023 13:51:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7F5F280005; Mon, 22 May 2023 09:51:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2F18280002; Mon, 22 May 2023 09:51:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF753280005; Mon, 22 May 2023 09:51:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B25D3280002 for ; Mon, 22 May 2023 09:51:02 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7E51840313 for ; Mon, 22 May 2023 13:51:02 +0000 (UTC) X-FDA: 80818027164.21.1B2D35C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id A235980015 for ; Mon, 22 May 2023 13:51:00 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JFoE160n; spf=pass (imf30.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684763460; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NlJ+5nt1dbN0CXPyG6Okiwr3pDsREkSTcJAeP67H8Fs=; b=GNdwE7RYIk1hkGQ3makuvxH91vuelOBrcQdpz9irItTbqKymjT3oRAbOJNidtO0JfttHy7 VGdiwcTWWR5QgcWRsvNwBgFFQndU3w1lHeSnxgZMYXlpjcUWUcHhHO0an955Oz0u12RgiI OgJ8FzFkr89iW0DK+lAdJWPA3hqlskw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763460; a=rsa-sha256; cv=none; b=JFAf5xs9LzdweUkgLu0Kt2hL+e4sr5NTEimt1xmbuOVJngWv8ylc09T5z+sVZokAlmt+vS vgHs4htYhbswEm6IVTv2WJKAD1yAt08fSgjcx/jZZplE4Jzg7P23gbXRciG+/E4NVNb/ro RPd0HSoWuyIXpRpPg/0076NnGQ/b2TQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JFoE160n; spf=pass (imf30.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763460; 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=NlJ+5nt1dbN0CXPyG6Okiwr3pDsREkSTcJAeP67H8Fs=; b=JFoE160nuha9gtZkkvLiBf5ASfxOHJ3aQoLexBSrvUj1kgDEizbaD3OvQK50waagVvJk0/ sVLrSLKilYWg2XazPcuCX8/6PmC+KUJycKFhr+IGtaFWkIK3RLYhyRLxhE3Htu80jtkuwl M5QJtVZhKAQHWZRhSFsdgDS+qc5tAXw= 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-443-RuncnEKyNrCpayNrIultIA-1; Mon, 22 May 2023 09:50:52 -0400 X-MC-Unique: RuncnEKyNrCpayNrIultIA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E38F1C01702; Mon, 22 May 2023 13:50:51 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7E3F40C6CD8; Mon, 22 May 2023 13:50:48 +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 v22 07/31] splice: Make splice from an O_DIRECT fd use copy_splice_read() Date: Mon, 22 May 2023 14:49:54 +0100 Message-Id: <20230522135018.2742245-8-dhowells@redhat.com> In-Reply-To: <20230522135018.2742245-1-dhowells@redhat.com> References: <20230522135018.2742245-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: A235980015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: pbhtrspwi1hrr5zzof3itqrmqhr4pq1m X-HE-Tag: 1684763460-583980 X-HE-Meta: U2FsdGVkX1+8B6HyXgLAFBOdU9iquKrHu6ipKwxNPt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G77k/WJZsGrJY8bux48B0n1EBHWEspYcolhhCWDQ3ESmakinLGx10VWOUJngePU3+maBc6G2xa5NNeReOXDEVKRCiQuQfifVZWp8bmKFzmyzAe+VYf8Mr3UTvCZDcVZHPri5sqBSRjd+klkQZeIwkL0oeVd82eRJ9Uo3wbA+G61lODMvABSZCNTX3fnBRHN47dZOHcetTJKCNTE+3s8j64e9KsemGaifp3MEiR7+tW62k+4jTFoAUG+A6qxwUPk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner 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);