From patchwork Fri May 19 07:40:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13247763 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 5A89CC77B7F for ; Fri, 19 May 2023 07:41:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EDD290000E; Fri, 19 May 2023 03:41:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84E57900003; Fri, 19 May 2023 03:41:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A30990000E; Fri, 19 May 2023 03:41:33 -0400 (EDT) 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 59FB4900003 for ; Fri, 19 May 2023 03:41:33 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2640A1609B2 for ; Fri, 19 May 2023 07:41:33 +0000 (UTC) X-FDA: 80806209666.24.A9B2F4D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 7A0728000D for ; Fri, 19 May 2023 07:41:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="T/rNQk3U"; spf=pass (imf30.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=1684482091; 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=vPjrjhiQt/5heMfgoC9V3vUMTVvHc0mi6B7m+VDoI8vYuMhneoMntYswZn7HMD44mDQ+F9 rOHiVXJwLPWsvCy3TYAkXxT1XWShU05Ql2yIrHy93e2yBtjHzM/wdqmeoqpNEwKAzeVV+p m9vAFZon9tK9i9UBmkjthx8KiuTePbo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684482091; a=rsa-sha256; cv=none; b=eTMTS9EWIzwcTsmBveSkBv3Aty0kZU3052MQVENtE+eRVS6T9eOFujVPNP7NM0C0CC0vqM QA/ivUYmBe2vfrYwRyuUAATELYPMZnT3/3bfujYsRX6Qr/0rnA4tG3cKENb8Eo+u7fGNpi 5EdLqkxivr78O3RcwgcoTMSx8TXvV8M= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="T/rNQk3U"; spf=pass (imf30.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482090; 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=T/rNQk3UCv5M3nTihypGmgF4aLgMwedgpWDFujJj7t3gVnuW277JshR5vGBg34Ulg3+L6+ RlfQ8/bntSIfBcxj4QzDrZ/cUOrw4PtPzYed0PMrvveSHuMGfT/gNTp+ZJeEU7kg/jVaIa 16rDQZx5McKeqjvcZ7AmeFmEsutoXsc= 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-587-n4p8TgQ6OGG9Vxma9vRnxA-1; Fri, 19 May 2023 03:41:29 -0400 X-MC-Unique: n4p8TgQ6OGG9Vxma9vRnxA-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 C01A5800141; Fri, 19 May 2023 07:41:28 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10DF940CFD45; Fri, 19 May 2023 07:41:25 +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 v20 08/32] coda: Implement splice-read Date: Fri, 19 May 2023 08:40:23 +0100 Message-Id: <20230519074047.1739879-9-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.1 X-Rspamd-Queue-Id: 7A0728000D X-Rspam-User: X-Stat-Signature: ri4quoksigfmpsdi3tc3yasu6ihjuixo X-Rspamd-Server: rsp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jw+boR1O2y7yG1yoZs8ZmclPiUjr+6hdKZoMS2KLg/b5kJPC2WozegUURC34r+3JllnU0auTSjEVzrDxpHCbU18sbJf1GYgUT7JlTFx/MHXaHrGW54le9BNcsyggY/MSeVufmh9SNj+wSW1IvFviy54rS4C5U/kactikfKGHOcysDqoGkFERzGNq7QZANuQlpHJguekB5BQoFzPbDEYFbsGWvPFFwEAUd2BNqEf2fTXeCB3GXT6y+Y3HG5a2yPj8minc/wOFxeCL+DGLxeBk06Kv8fO0KqZQzSRCDYXlKrvRN5Utv69gRVBAXjSpo5whyzksqF49uOcXMHypf5UluKXkVIa+q+jivQCPn9DPwzxOTXi8ffttqLHhF4rg== 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, };