From patchwork Tue Mar 14 22:07:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13175049 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 04D5DC7618D for ; Tue, 14 Mar 2023 22:08:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 496E28E0007; Tue, 14 Mar 2023 18:08:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 448B18E0003; Tue, 14 Mar 2023 18:08:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19CA48E0007; Tue, 14 Mar 2023 18:08:31 -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 0230C8E0003 for ; Tue, 14 Mar 2023 18:08:31 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D3D3CA74E9 for ; Tue, 14 Mar 2023 22:08:30 +0000 (UTC) X-FDA: 80568893580.02.AF5C671 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 34328A0004 for ; Tue, 14 Mar 2023 22:08:29 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NGglUErH; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1678831709; 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=nHNy4nJmQ/a4IoNX2QKH+L39mDVFpf5RihnjQdBGf3dRrNxD/dijAN+muv3j6a0QSvRy3T 3tBDD5OffdVjA7ialu6X4rTvpUqAeW3PHlgw5c10oGKin7jUutc7f3qXA6FX1SoZjIvoIp 9H+mAnHpXpQsdPdyWsknYavE+70mRmM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NGglUErH; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1678831709; a=rsa-sha256; cv=none; b=lY3E+7g0dVBeOeY3ASdKlI8raY/jjzBbfEUqCike9n8xi77+ZDMWQ71fZNZIebeZyn2BGk Q4kYUxWLLt9eMj7/b5zHoMWz6AHtVwlsZmRtPmfw9VpzVOt5XVhLh2u9LA+Yq9cArjCdok zchnUoYOHhc17RdWsDd654BeEySLHlY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678831708; 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=NGglUErH5fcSEvmD9vw9W/isAS1FhkxYEGh5+SdoHN9pDUhVGvsUCHGxmg2tfVLhpOsEo6 pZYbztVsYUUjw5oHD5asoHi1NQPtprj0XEscnIt2iHSgbNRP9qeASB7GNcEamHJVAQ9Hda m+4JtBwug1Un5Y0FszBTl6Z+BBRUzQg= 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-355-ou2O4Fm_MEqdgyGyXimoSw-1; Tue, 14 Mar 2023 18:08:25 -0400 X-MC-Unique: ou2O4Fm_MEqdgyGyXimoSw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 538CA85D060; Tue, 14 Mar 2023 22:08:22 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD5082166B26; Tue, 14 Mar 2023 22:08:19 +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 v18 05/15] coda: Implement splice-read Date: Tue, 14 Mar 2023 22:07:47 +0000 Message-Id: <20230314220757.3827941-6-dhowells@redhat.com> In-Reply-To: <20230314220757.3827941-1-dhowells@redhat.com> References: <20230314220757.3827941-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: om8pm8ig7tqznqfh8774rhfifudrzygb X-Rspamd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cRauV9orayDLJOExEMn/Yj8RbctdojozDgqz9CmjlrrfKTbkT9cS2iRnIl8jxYE5Kj2tjOMi1OYyUTYBl2Q39oY5X57TrgMD9D71xY1/+B7xUeMeusE1HZM49fi9FNYOZbqp93JVNxGXOQfqs+oYTfG+RISMy08h6vRaMG0csHEiAT2VO53syz58PduODj2gPDLng//FK9oVIAtL7ACQosXEncbRtBm7CMCarx1YN9LUxm/b0cOpIqQ4BxALbk3ekobEmQd6eM7LvMwlNhFb19Pa/kcm8gKOv4c0CV8W+BDJ7CgDf1xdwLZQw4GOcYMncn3iZP7N3I1cFAqGPDsYUS0dcNmYRLZ4uwFzjnf/2tN659cy8SQSHOOiqQiqua8eeE/+uFohwUeuimmvd8JDU8yBC0KLoVmqz0iY4Oj0J7J 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, };