From patchwork Sat May 20 00:00:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248996 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 0AC5BC77B7F for ; Sat, 20 May 2023 00:01:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92AAE28000C; Fri, 19 May 2023 20:01:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88DD8280001; Fri, 19 May 2023 20:01:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 668C028000C; Fri, 19 May 2023 20:01:48 -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 4D673280001 for ; Fri, 19 May 2023 20:01:48 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1D0901A0B78 for ; Sat, 20 May 2023 00:01:48 +0000 (UTC) X-FDA: 80808679896.12.1691A41 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 4FD2CC0008 for ; Sat, 20 May 2023 00:01:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i6gC5FIG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684540906; 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=up+z0f8N3Zv7uMXFjNiQsDQ9kDW1Zh9kN/9jDbkWuHc=; b=PN+f6tJqkss6SY5WYqj6HyNe3g79oEoo9PdlYUCJuG9cBSdPzLAo+sTS1FvHa9sUEmNcha Z3gzVX7qSZW8YNeUdWXcWYLJVr9LckHUrFcBsFIsslOZwjb0ImSb32SSMzcUq/YVZEM8Ef l1rkxkQm8vzGNhXQQsbawfaRI7GddLg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i6gC5FIG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540906; a=rsa-sha256; cv=none; b=DmZyTHybWrbVgRQh85a7OPjR+wTILPGhCqm+c3wh+O1aw6FU+M0rcHGkvBFg47nG1J3qQf b4xXqlhYS4ShXKD771DRWLYvdY+au6qCURf/kK+7/TBDHsHtqVanJVCkLZD/hklXbOBAPX txPw3slaUdYjzglxpafDMCfXp6PNsOc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540905; 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=up+z0f8N3Zv7uMXFjNiQsDQ9kDW1Zh9kN/9jDbkWuHc=; b=i6gC5FIGhDEJy/ZjxhZT7L1fsrM/3wtPfiM9UvUt1cSFYmRrp8kqEuoh03iRtbXR6CBHW6 qgwUGKlXBOmILfTSgPh0UhBTtj25Qp90Q0uaPcmuAxJm+22s1EntHukiMIK0cjhldJvZKz HHvldDsXNiR2o44I5K18MOhk7YFBHAU= 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-539-gS634MneOxaFqMs-dNTBgA-1; Fri, 19 May 2023 20:01:42 -0400 X-MC-Unique: gS634MneOxaFqMs-dNTBgA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32340296A604; Sat, 20 May 2023 00:01:41 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66C3F140E954; Sat, 20 May 2023 00:01:38 +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 , Marc Dionne , linux-afs@lists.infradead.org Subject: [PATCH v21 15/30] afs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:34 +0100 Message-Id: <20230520000049.2226926-16-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.7 X-Rspamd-Queue-Id: 4FD2CC0008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: c7f5mo63qb7auf3fe64cd38aimp7pmug X-HE-Tag: 1684540906-358013 X-HE-Meta: U2FsdGVkX1+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D+/+516yg7ViqHkdZAhl1ZAMwMVNyLLrJFMPjqFJVlVioesKqOZeEWtQ9F9s3PUrs1NIrhmfGQ6hRm86GIABJXijce2UpsKixSRwAZAE8gSFiZDpJKmXW8nj6xwB38Cv37a0JOkavc/4o/tmiYmf3UlllZjPI01sNWfsxe55gx8invRj71lRKE6XeG2cJmhh/ZOKSk8EF927fXAGdiz4ljd9g3V3Xp6Ok0bC3VEYEEOPB7/yNonStcw8lyvuD9po9aP78gQsajoCtNHEfYw1HyIjePuaPl9CPmDZfFAwi81+Pwb9r033WXW749OO2zJRDYJvj842g4XiPJ+mirwC0IdXwGOWw1O+y2Xq7FUCuxnGsJDzdmnpiUlNNK3uw== 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: Provide a splice_read stub for AFS to call afs_validate() before going into generic_file_splice_read() so that we're likely to have a callback promise from the server. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Marc Dionne cc: linux-afs@lists.infradead.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/afs/file.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/fs/afs/file.c b/fs/afs/file.c index 719b31374879..d8a6b09dadf7 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -25,6 +25,9 @@ static void afs_invalidate_folio(struct folio *folio, size_t offset, static bool afs_release_folio(struct folio *folio, gfp_t gfp_flags); static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter); +static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags); static void afs_vm_open(struct vm_area_struct *area); static void afs_vm_close(struct vm_area_struct *area); static vm_fault_t afs_vm_map_pages(struct vm_fault *vmf, pgoff_t start_pgoff, pgoff_t end_pgoff); @@ -36,7 +39,7 @@ const struct file_operations afs_file_operations = { .read_iter = afs_file_read_iter, .write_iter = afs_file_write, .mmap = afs_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = afs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = afs_fsync, .lock = afs_lock, @@ -587,3 +590,18 @@ static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) return generic_file_read_iter(iocb, iter); } + +static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct afs_vnode *vnode = AFS_FS_I(file_inode(in)); + struct afs_file *af = in->private_data; + int ret; + + ret = afs_validate(vnode, af->key); + if (ret < 0) + return ret; + + return generic_file_splice_read(in, ppos, pipe, len, flags); +}