From patchwork Mon May 22 13:49:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250591 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 89BBCC77B75 for ; Mon, 22 May 2023 13:51:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF3E2900006; Mon, 22 May 2023 09:51:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA442900003; Mon, 22 May 2023 09:51:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6C40900006; Mon, 22 May 2023 09:51:20 -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 B84AA900003 for ; Mon, 22 May 2023 09:51:20 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8EAE9402E4 for ; Mon, 22 May 2023 13:51:20 +0000 (UTC) X-FDA: 80818027920.26.FA28115 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id AF045140012 for ; Mon, 22 May 2023 13:51:18 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AcDOrehg; spf=pass (imf23.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=1684763478; 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=Mo6NWBR6hkfydtMnZeO+F5U5GhN+vbQRFCzRyccP/1I=; b=6cNXasheo1DF46I8TVOzmcRUgJUblvwT7UioRDV99LqTXmsDzc/mQ8gYYpxMW2KGQp27Rk UIcSgu4AkgpZPGXjAqbf5oDbjWdRqNcDPG8cU0EWqd/MxxepJTRw+/2B3QCxNhvc4jYiFM QxOUTB/ksmna9jeljRVPugc4Emj8LQE= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AcDOrehg; spf=pass (imf23.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=1684763478; a=rsa-sha256; cv=none; b=kXUjO2jzjIK0Z7ZALuNzxKCIiDusAmtuK3HoggisV/Y9ZCfjy6EaP0m8bfZVckixQYidXL 4+O/PG1dtk+JsXssRj5agOD5oovxY/slTBmkx6jNTHt1k0ePzsegLUA0MWMhDaoooIZXoG Pa3A2/8iH2OUdGv6aoo2DB0RjtO3pGs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763478; 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=Mo6NWBR6hkfydtMnZeO+F5U5GhN+vbQRFCzRyccP/1I=; b=AcDOrehgxeuY/GqGNz6QtYRIMn4UBAq5o6X7A9JPd0dvWrDAesY91UlR+rsuDbwBPfSMKv hIs3bKtqbZp3Almjzw+29Vow9F+Gxi4URbljXe2YU6YIzKkW9/ph6KFSkSrTR+ybqTzaG2 1DBBo8/JiUfuhEqTfBi4hPXp09GMk6c= 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-658-FSbafaL7MteAr1zv4BBI7w-1; Mon, 22 May 2023 09:51:10 -0400 X-MC-Unique: FSbafaL7MteAr1zv4BBI7w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0AA3F3C11C7C; Mon, 22 May 2023 13:51:09 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB6AF40CFD45; Mon, 22 May 2023 13:51:05 +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, Jan Harkes , Christoph Hellwig , John Hubbard , coda@cs.cmu.edu, codalist@coda.cs.cmu.edu, linux-unionfs@vger.kernel.org Subject: [PATCH v22 11/31] coda: Implement splice-read Date: Mon, 22 May 2023 14:49:58 +0100 Message-Id: <20230522135018.2742245-12-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.1 X-Rspamd-Queue-Id: AF045140012 X-Rspam-User: X-Stat-Signature: eu1rs9ncwqas99fzyz86fr9b7oppgf4g X-Rspamd-Server: rspam01 X-HE-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h4R3XsE57B9UOeuQ53vCRfOVU3FkxtclmAyxqf398C/6u0y/ZSgUlQv7c6qEoZfaGpErHAapOHdds3v2WfMGzTVIRrTCGLX25bk3OZlN7AlsQKpx4Xz97WS+80xTBZ6k7M0SQpHydzFUgQOLHLGpPuvzdI+5ysYtQv/Z1dTlmyJwslYKQqbe9SDNBfH187BmPL2++P7d2rznMZu+i4VOxQLsnpzG9TP1NqBA/nDhb3TiuGPPe48gybc9NPs3E3hFYix6lA9OIYxZ7p3Z0qAeMaxsXPHMT/kbVMbWsWPKctCUgHa1bOKtTDolVCzhzVRO/jfnQ2nr0f43zZCCTwfwr5O/HAe5N78iM7oPIpEliAnORlNHy1GledurnP1OAw== 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: Implement splice-read for coda by passing the request down a layer rather than going through generic_file_splice_read() which is going to be changed to assume that ->read_folio() is present on buffered files. Signed-off-by: David Howells Acked-by: Jan Harkes cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: coda@cs.cmu.edu cc: codalist@coda.cs.cmu.edu cc: linux-unionfs@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #17) - Use vfs_splice_read() helper rather than open-coding checks. fs/coda/file.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/fs/coda/file.c b/fs/coda/file.c index 3f3c81e6b1ab..12b26bd13564 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "coda_psdev.h" @@ -94,6 +95,32 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +static ssize_t +coda_file_splice_read(struct file *coda_file, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *coda_inode = file_inode(coda_file); + struct coda_file_info *cfi = coda_ftoc(coda_file); + struct file *in = cfi->cfi_container; + loff_t ki_pos = *ppos; + ssize_t ret; + + ret = venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), + &cfi->cfi_access_intent, + len, ki_pos, CODA_ACCESS_TYPE_READ); + if (ret) + goto finish_read; + + ret = vfs_splice_read(in, ppos, pipe, len, flags); + +finish_read: + venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), + &cfi->cfi_access_intent, + len, ki_pos, CODA_ACCESS_TYPE_READ_FINISH); + return ret; +} + static void coda_vm_open(struct vm_area_struct *vma) { @@ -302,5 +329,5 @@ const struct file_operations coda_file_operations = { .open = coda_open, .release = coda_release, .fsync = coda_fsync, - .splice_read = generic_file_splice_read, + .splice_read = coda_file_splice_read, };