From patchwork Sat May 20 00:00:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248988 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 28C4CC77B7F for ; Sat, 20 May 2023 00:01:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2618280005; Fri, 19 May 2023 20:01:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AADA3280001; Fri, 19 May 2023 20:01:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9010F280005; Fri, 19 May 2023 20:01:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7D7C1280001 for ; Fri, 19 May 2023 20:01:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5FA58AE749 for ; Sat, 20 May 2023 00:01:22 +0000 (UTC) X-FDA: 80808678804.05.7360E2D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 8D8521A0025 for ; Sat, 20 May 2023 00:01:20 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AZwqWMR3; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684540880; 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=dIGb/7Nt7dNT7r5bxwMphLPrFmTGpxHZQXf9F5C0+vE=; b=z2Rf4k4WCNjH/FN6SZmwmlQdSwjTj8UNYrN5nP+/nzU1mFOG/SG+mH+8dGDFUvwRLHrbS0 BBJoYcvKIK6tU2cOj++0sH7JYPa544/nTV3VtXQ3nGukHT9hmsOeW+8ekxTGxp8GaT3PKm gjiEaUDvUGPW/zx/dBdJHjnvBZ8+ALI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540880; a=rsa-sha256; cv=none; b=SbCrJOnk+VonyrLVzBAQtaA7Rh3hF56BKgwIcIS1BA4DqKZTiv3fUJFsnBVDE2E+IvsQaD T3pYCgy98zo8heZEBpyj9RN5cV0AJoWbG6qHGRiSRGhMEw4zq4pBIiKd42qulv9Pl5U+zB KUWSAxsrzhf8AqnGGBNVjDXU4ib30HI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AZwqWMR3; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Stat-Signature: z9ntjdssoks3skuhgepjtes6bnem8diu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8D8521A0025 X-Rspam-User: X-HE-Tag: 1684540880-128463 X-HE-Meta: U2FsdGVkX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aRRwEXu2xSJpRPZ/UApWF7YGVzRtyoF+vNMEuGgQ2WkzUIz7zjRlEUiSNQ4G8AaONxztcAztJi8Qm/3UtQziZs5GqY+g1PvKgu/9Hbw3kt4dPL7fq6K81eGWrL//iuFwLENcww8mcs1kp0+fk60OYaPXUvXiF546cp03UVMUJ65/EwVTGsbaaEyuCRLxTi3sSGvmScpzLRozd2Y9Y9UteWHwXbTf8WhAcsxIO94lCKf0+G7BZpCNmrN62IL3wlgmW2hifsDSYKbdOlK4tVwoYbjyIYYszAfGAimIpvB1F7U= 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 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 Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner --- 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);