From patchwork Fri May 19 07:40: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: 13247766 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 ACCD8C77B7A for ; Fri, 19 May 2023 07:41:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54371900011; Fri, 19 May 2023 03:41:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CBC1900003; Fri, 19 May 2023 03:41:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36CA5900011; Fri, 19 May 2023 03:41:49 -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 26397900003 for ; Fri, 19 May 2023 03:41:49 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F2492140955 for ; Fri, 19 May 2023 07:41:48 +0000 (UTC) X-FDA: 80806210296.26.493CABC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 2E473A0006 for ; Fri, 19 May 2023 07:41:46 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Y1Y4ogU9; spf=pass (imf15.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=1684482107; 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=g820KSNTP7OMqJOKF462B/JivphTXg8NZzTw8fVuImA=; b=lJtftJirDTagA19rRrdDD7JuJkWGgr/9H6rQTWerx7fuL1LhJoDy1yOgmafZjCdM2kgAyW 5aLdQD9x247r9oPbBfgdTmOsGc9x1YVLp2WVYFQENCtMF6iZtL8+0B2DWOuycams70+WXM owCNINzu/UgWM0D7JdO8FqU4YWBlx3U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684482107; a=rsa-sha256; cv=none; b=WWEupISHd5ChglXvdy9U7/KsLjjD/t0Yre+oIvYPRfWQyT9raWmJMU1EDKwmWxFCAwWe1c NtzgE/Ks9xqybNO9ls4avsqMoBybtyiKEavjjuTBcUb9oNV/f9lFMX77b9XKrzYUUtnQhc 2OEBAodQzRJsw3OJzS28eklhR091BWs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Y1Y4ogU9; spf=pass (imf15.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=1684482106; 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=g820KSNTP7OMqJOKF462B/JivphTXg8NZzTw8fVuImA=; b=Y1Y4ogU9sVFKhucR6tVRqjC7fEBt3N7wXjv1pxFWgr0x3HNU2528XdrNM7UttaghDTDSMR TinyBQAE/7rNU+8Gh3ZeGqMYFIQdXFHRrkrgxBUx+9UOulFt2jifSHczl5mMWQ0xxjRtEI Ee14dxk42yx7COKtGjSQ51q0GMTI9cY= 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-438-CWsHB0HDM6aXruJL4c8kbg-1; Fri, 19 May 2023 03:41:40 -0400 X-MC-Unique: CWsHB0HDM6aXruJL4c8kbg-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 B8C7E29AB3F4; Fri, 19 May 2023 07:41:39 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id D58D7C0004B; Fri, 19 May 2023 07:41:36 +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 v20 11/32] 9p: Add splice_read stub Date: Fri, 19 May 2023 08:40:26 +0100 Message-Id: <20230519074047.1739879-12-dhowells@redhat.com> In-Reply-To: <20230519074047.1739879-1-dhowells@redhat.com> References: <20230519074047.1739879-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 2E473A0006 X-Rspam-User: X-Stat-Signature: 7w51s7w5c95u5bmsnnqtrsp9eupkaamo X-Rspamd-Server: rspam03 X-HE-Tag: 1684482106-268632 X-HE-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JWrvv2yusLyDj19vm2FDJPtv8ESFQDBvsU+MhuxyyMUjtirx+tNllCZW9a58k122smeIf8V3WKj/LQ/HuT7HQBpkoiowdAWkdw2k4QQJkL2X72garD2dTX0gRB/QrqcwjVxe5QawRuS+ztfB1s2NaAHxSY5YbJOL+HICW88Mkw7PdBX49S+61cb/Up5PHzFYbjjbsGzPngUaDD/4lEYzktA+Q8TmUJ0u7yUtWjAvKyIb6ucTEZqi6QIoGUpBWvoWOUxbHOrXzaew5xxWqk6D/1GC1uozaWTGPxz4dzsYrySkS5Mfp/JTX/Dw8WSDGyZue8U4vHre+zdlUDS1jm3aTyx9uSXJk4bUJU5KYuNYN1kU+c86nBRbLqPJCAbBv5lphay7WyBjh7Gj440rhOj6+Im2DptUwBzLt8OmeathrgJTA7bK64S7+OxDTy3/eY1Mi+h1zuXdOD8+6bJmCg4W1BZD/85z3Br1geg0urBbQLh0maHUzUgz9YE= 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 stub for 9p. We should use direct_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..0f3cb439ab2d 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 direct_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, };