From patchwork Wed Mar 8 16:52:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13166163 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 528D3C678D5 for ; Wed, 8 Mar 2023 16:53:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 861A7280001; Wed, 8 Mar 2023 11:53:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EB176B0083; Wed, 8 Mar 2023 11:53:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6640A280001; Wed, 8 Mar 2023 11:53:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4E7E16B0082 for ; Wed, 8 Mar 2023 11:53:24 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D196BC0750 for ; Wed, 8 Mar 2023 16:53:23 +0000 (UTC) X-FDA: 80546326686.03.52098B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 05A62180019 for ; Wed, 8 Mar 2023 16:53:20 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hM0nRbrF; spf=pass (imf24.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=1678294401; 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=PhbxTzWahXdd/JlmGrRowyeASqSlq5EbDSo0Q9TZAGc=; b=nzii5cEFWmxT6b8hUfKIsbAAtLpUmGG0Mc9xyohpJLvarZTEVpoTrv1ZFknQ8m0GY0W2/9 VtB0Zd2BIcRxoxPGSezDQr5gTiz6ViSHbeHel7uQMbfO4bqZ0Clg7gOEWkQLGcSUdDgJBg IAsyLQKvsin++C+YfF1Y/sFuiXX68pg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hM0nRbrF; spf=pass (imf24.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=1678294401; a=rsa-sha256; cv=none; b=givSOfVXcbq1tQ6Vbn+cJ8BYPLpogSjgI1P6zfEodYSnK4+OCPefbi4iQpqM704vFwGo3Z yE1K29Jqspx0zWhPsB3mCpHBykKMDzoN2aWoQASHit7mMjAlnk0CNs/MbLfOXe4lYlx0BK k1yjuz8jarzSw/igmurqj3mbvJCCjSM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678294400; 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=PhbxTzWahXdd/JlmGrRowyeASqSlq5EbDSo0Q9TZAGc=; b=hM0nRbrF1MoXBP7RU9/atMQ+2yAGE/JncDHrVqEMsvniy4HISLKJqLedPdFkehZJDswxF6 z87kAhTPw4nEe5oY7VUupjLNUG+lOZ8rXiOwfsnSFAQLQcfjDq0IqMuy4tRJnXlMxIJirg x7n03L5S2ldAK0xcz54MSEVzuwymcYI= 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-18-Nut58j8COw2eSbYYTRM5UQ-1; Wed, 08 Mar 2023 11:53:14 -0500 X-MC-Unique: Nut58j8COw2eSbYYTRM5UQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1025F1C12983; Wed, 8 Mar 2023 16:53:13 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E0E9492B04; Wed, 8 Mar 2023 16:53:10 +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 , 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 v17 05/14] coda: Implement splice-read Date: Wed, 8 Mar 2023 16:52:42 +0000 Message-Id: <20230308165251.2078898-6-dhowells@redhat.com> In-Reply-To: <20230308165251.2078898-1-dhowells@redhat.com> References: <20230308165251.2078898-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Stat-Signature: of8ceb17nj71go3htx7umbi5zcg3cjup X-Rspam-User: X-Rspamd-Queue-Id: 05A62180019 X-Rspamd-Server: r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DvLIYlxgVvxZVE36MFQNopuAVkLyUPRq7Yp6csF2vPy1zWFC8UgCKjmc3QQ6Frc8fA592vtcR+r01xWz71Q34vD0LROZOHWjmOQOdLcfzhCFIQXJrgiRWc2cTme1KgRZ/Z7mJUnEJPUBwdgDTjLkpCw9R2YIhsPbMsLNPaxGrEniAWmMX1bTscPmloQA1sRMJGDcrFKTUtfQ68Le8SkUnQBOjrYwbYgUTaWUCGaJlLEBa6ik2QVSlBrH7lbaNTY6APczzAFM43hnSzX7j+c26eVcITzfTBfGdUkpCTrnaYwzXsum9euaJzJPMB+H/mZm3znUq+mwN7+lRH6y8DLHH7QYkClqUpU7elEjHe1KO1bvzdjTOUhR4jtR+y7MvIs0/yWNQa8PuTXUkjFXfNr7znJ 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 cc: 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 Acked-by: Jan Harkes --- 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, };