From patchwork Sat May 20 00:00:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248995 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 95D8DC77B7A for ; Sat, 20 May 2023 00:01:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35CBB28000B; Fri, 19 May 2023 20:01:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E58F280001; Fri, 19 May 2023 20:01:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1629B28000B; Fri, 19 May 2023 20:01:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 02121280001 for ; Fri, 19 May 2023 20:01:46 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CA91040B8D for ; Sat, 20 May 2023 00:01:45 +0000 (UTC) X-FDA: 80808679770.14.4F3E80A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 112FA80016 for ; Sat, 20 May 2023 00:01:43 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c8QJFDuy; spf=pass (imf30.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540904; a=rsa-sha256; cv=none; b=x+M2l45FDd5tksqNk/l0fvgXfBd2zHYjpPnTHM89amZl0UHnV5RloXIMdSFsuHGnnqlMPV UQ80HWvIpGPZbaNGDQVUaknu1qjJPVFIPBVqYnDDoGVcEBqQJcR1iIYLe3KkbjX4LznnP+ +054DMUGO5Ur/BNWD57NnOqQZdlc7Qg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c8QJFDuy; spf=pass (imf30.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=1684540904; 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=L0untNcr1icklU0hwhU0ty94Xf23B/VjszjVy/DS5Ow=; b=MB/81mkE0qyZW7+CXD1M8vKzLAs25+bt5yAp7CMidqLedUJozqQzbiL91vSa7sfqsUPnsS /GZwn91MbXP1k3OV/WsyHJPkImqiHgtAEB7qwUsPDXrgdluQjB0IOCI9dnsyCeFA3pryKX TMupFjSgj49j8dtQTebLv60aBQI2NF0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540903; 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=L0untNcr1icklU0hwhU0ty94Xf23B/VjszjVy/DS5Ow=; b=c8QJFDuy5MYbgzbTt6diemFHS40briWr/q8WQ9sNyEW3tK6WA0cV3ech6dozvi8y814/hX U8Vj4ZVB+WDtvUS4m/V0M4Dfs1hnZqTkAU3ZsiUWilp+kIAI7Z11vne3SiWuI3vE6iXtqt j5Ph1MK9us8BMwFpssTLnv7XDRc1zg4= 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-144-ZoV9UQXCOsyihBFlh8yZBw-1; Fri, 19 May 2023 20:01:39 -0400 X-MC-Unique: ZoV9UQXCOsyihBFlh8yZBw-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 C79A38032FA; Sat, 20 May 2023 00:01:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0872492B0A; Sat, 20 May 2023 00:01:34 +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 v21 14/30] 9p: Add splice_read stub Date: Sat, 20 May 2023 01:00:33 +0100 Message-Id: <20230520000049.2226926-15-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 112FA80016 X-Stat-Signature: guutrnkx39s3sncucigxpf9isafowt6t X-Rspam-User: X-HE-Tag: 1684540903-539626 X-HE-Meta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MqCWhEj7kpeQU5ocPOwnMHIClsMVm7647fqoppiARvrQ582n0+MHY2ywrqNkz34OGAtg9X4Sbr/5jS86gi9hhmfS9c2vqyyrvdp3SrpcufgTYJDBX/10WNy7KogUrvw8mQmO/fHYfC0XaoK17UjCwsm742ZQjW+vQVO1uOzoWZOu9/y0nURsSyFv6cUcG5TVIkF8VzP/S4Ck4/pvdD0eSnm5Hbo8kj3oFUKVkeL0DtwaxjoXmOW/vWoDm+M4eDxZ/zULVPMxdyE/wDCb/6cqO1dwR5IsUvwkXxZc7dntbqQRrLU343c84ap7TcAREwM59oYX4hT/BZpdKzMO3as0znD9MYwXB96Vsr/vg749gjZFGWY1xsoI45oC+VXiaGfPT5qBANJ7QMdkS1XqFNDLD7gRNlsC9p9XXyQuSdmkgLdA05wkGMjZMEHWfhgG3NVfHqlUKss8LG5DrIAj+QcunfMrp05k4wGhWU4DJimb1IIGltqs= 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 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, };