From patchwork Mon May 22 13:50:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250594 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 E06D8C77B73 for ; Mon, 22 May 2023 13:51:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84EAC280004; Mon, 22 May 2023 09:51:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FF00280002; Mon, 22 May 2023 09:51:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EE23280004; Mon, 22 May 2023 09:51:31 -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 616B0280002 for ; Mon, 22 May 2023 09:51:31 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 313751C67F3 for ; Mon, 22 May 2023 13:51:31 +0000 (UTC) X-FDA: 80818028382.09.4CC292C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 5A25AC001E for ; Mon, 22 May 2023 13:51:29 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DuNWzf55; spf=pass (imf10.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=1684763489; 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=3P+FOs1njQUxSqylXnXlO9wiVhuujp6lAryk+mz03wc=; b=0Jbvm9uEjklVu/a7FqEbo/xnW3LZR1ZJq34LXDhpWDGYdweEIIcQiKM+xhSduBO+zf1WoD cFYokOhW4ZSuxndxBMguJmaq7EATVqQcXDmVZaA/cbCqyLpjXWs2vTNTC829U56RkJVwCP ttgP2Jf0y2ZAcPnqvla+iZ7WwnrJZ9o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763489; a=rsa-sha256; cv=none; b=jfe08bpU9gNR6k3n40bYMn8XpNvRMC5fMB6X0lP//UNgeQCoHM9xglMlCcwGx3wfZxl88e LvSuJzEXJOvoUhHIyJrr0n39XN5VHTqXl/ibPMShAfVDBYFfN7Cy1Ql1UKSLaCNTVVDe2y 5WQ9u0N7q7zh3q2YApq1rsBs2bAHMeQ= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DuNWzf55; spf=pass (imf10.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=1684763488; 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=3P+FOs1njQUxSqylXnXlO9wiVhuujp6lAryk+mz03wc=; b=DuNWzf5541iqoqmcxsDnKmGDMYFTYGHvY/wcJXFjdi8wCmiytqddAnpG0eKLp3OmDL20xx d9B0IXGZiHc9lmRGdnRngzl6gw9k6yUkn2p0OmaajWhX30COiogjG0gfqVoEUaHpj9OPA0 /GQ6qiXTSRiGIuV+lNwsbbD4X2AE1kU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-626-t6IcFv94Ov-E8ijVu7uUwg-1; Mon, 22 May 2023 09:51:22 -0400 X-MC-Unique: t6IcFv94Ov-E8ijVu7uUwg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A23F0185A78B; Mon, 22 May 2023 13:51:20 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42CD0C1ED99; Mon, 22 May 2023 13:51:17 +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 , Dominique Martinet , Eric Van Hensbergen , Latchesar Ionkov , Christian Schoenebeck , v9fs@lists.linux.dev Subject: [PATCH v22 14/31] 9p: Add splice_read wrapper Date: Mon, 22 May 2023 14:50:01 +0100 Message-Id: <20230522135018.2742245-15-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.8 X-Rspamd-Queue-Id: 5A25AC001E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: xn1pqgrgm9tcq9hcx1sa6n3ytniuiuwk X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leUq1FUEtRbKfJ/6Q146HFEGlRdhh4JwMVTfui64zy1igNpeO1d1PZDfiYKnLlJJ711wAIvOJ0Brt11tj/6KBUz/3mkI8kO3+xV3acyu1095N2TtLh0C02FBlQjIoNE3m8fIHGjA3Pv4hxXqvPVeUYXMOK6aR/x+0OudV1aL+unPNspt16xp/SuQHqqRBi7r6ifPrP/RThz1iw9MBakXTuUZP600ZJJLXKxCAwzNvS23mTX86fFjlVEtLrAZQkaIfdZ+Qqh2y2EgnGrzjrMJRYSaBsy3D6Ba+XDCXW2miwD4OkSiLji3CfjJhxcA6414jo26NOLcYAuGDcIGyP/CxwJMbaEUevq1OkSEVc4HkfpfYrRUaw+tJxINyuDvXMrokP2NR01N57bEqW2mQ5RMSw/WmU+ea6ymNzDqF6M4StR8JiEJ8G0kLsffl+PJd/lRIODynperwK0j76tEiLrd1lMXy+eAzuObhIKENXIMl5jdRQkwOUm8WDBNcLcKVwHk+3EfH92ay+ruWQUHh46z111XU= 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: Add a splice_read wrapper for 9p. We should use copy_splice_read() if 9PL_DIRECT is set and filemap_splice_read() otherwise. Note that this doesn't seem to be particularly related to O_DIRECT. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Dominique Martinet cc: Eric Van Hensbergen cc: Latchesar Ionkov cc: Christian Schoenebeck cc: v9fs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/9p/vfs_file.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 6c31b8c8112d..2996fb00387f 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -374,6 +374,28 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +/* + * v9fs_file_splice_read - splice-read from a file + * @in: The 9p file to read from + * @ppos: Where to find/update the file position + * @pipe: The pipe to splice into + * @len: The maximum amount of data to splice + * @flags: SPLICE_F_* flags + */ +static ssize_t v9fs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct p9_fid *fid = in->private_data; + + p9_debug(P9_DEBUG_VFS, "fid %d count %zu offset %lld\n", + fid->fid, len, *ppos); + + if (fid->mode & P9L_DIRECT) + return copy_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); +} + /** * v9fs_file_write_iter - write to a file * @iocb: The operation parameters @@ -569,7 +591,7 @@ const struct file_operations v9fs_file_operations = { .release = v9fs_dir_release, .lock = v9fs_file_lock, .mmap = generic_file_readonly_mmap, - .splice_read = generic_file_splice_read, + .splice_read = v9fs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync, }; @@ -583,7 +605,7 @@ const struct file_operations v9fs_file_operations_dotl = { .lock = v9fs_file_lock_dotl, .flock = v9fs_file_flock_dotl, .mmap = v9fs_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = v9fs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync_dotl, };