From patchwork Mon May 22 13:50:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250595 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 ACA6CC77B75 for ; Mon, 22 May 2023 13:51:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4822628000A; Mon, 22 May 2023 09:51:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 42F51280002; Mon, 22 May 2023 09:51:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F6FD28000A; Mon, 22 May 2023 09:51:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 21706280002 for ; Mon, 22 May 2023 09:51:33 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F0140C0320 for ; Mon, 22 May 2023 13:51:32 +0000 (UTC) X-FDA: 80818028424.30.4875977 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 0B55140008 for ; Mon, 22 May 2023 13:51:30 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H6GIexMI; spf=pass (imf04.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=1684763491; 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=PEAwo5lhibqbQfXFUjxcLaBP2Klj7e0s52wWHDT+nWc=; b=f0g3x1BiyGSY87Jq9j8aBJehVGj1bobcYSZh3JLdyKgEqPKHaAcf574W4g2aFAo7U1EKdG tQacMzQs8AH+OgIHSzT40H0gv4MAZd5O2lDFGesPfPge53mGJbqMNqsaKGwT4xYmds7n5i 3d88EuEXQjHvojSbEk9AxhtfPRdNw2A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763491; a=rsa-sha256; cv=none; b=uvQUJNqfBNnJrjSwATfEJfq/emnoma9B7SUFI1urQAypm7LoJ0fqN7P0mrJDNIYm+WKgHK OyFUoaDvZSfHulZ4n1tMIS8Iyk1Hg+XIXjZLBWWoUjGB4uko22xcrN7crYbSRONtXU0p5r ZMERNNGr4pSEZ0eSsqAED1z080fZB4s= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H6GIexMI; spf=pass (imf04.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763490; 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=PEAwo5lhibqbQfXFUjxcLaBP2Klj7e0s52wWHDT+nWc=; b=H6GIexMIJb5nZ7rh3eCUjHPPWaJ7mdTdBsicG3R7k58o1aVVzAkSDEV0CiVDEgTtWoxEaP nMYtrAfFpKDPwwrc2NwFMv9uuCQN0uKqQYbz4SmQOsY1Qy6qVhSJ6c+Xw2Sym44oG057yH hwlQDtN0lG5+V9kZoP8x6elmX+ctLgc= 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-86--zVkVRXFMQ6pt9ZQdRmXYQ-1; Mon, 22 May 2023 09:51:25 -0400 X-MC-Unique: -zVkVRXFMQ6pt9ZQdRmXYQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 42835811E86; Mon, 22 May 2023 13:51:24 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81FC1492B0B; Mon, 22 May 2023 13:51:21 +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 v22 15/31] afs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:02 +0100 Message-Id: <20230522135018.2742245-16-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.10 X-Rspamd-Queue-Id: 0B55140008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ibxho38c9ui81xo9chxkhr6tjaga9sbc X-HE-Tag: 1684763490-430344 X-HE-Meta: U2FsdGVkX19mu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qIXuv8+k7H5hWxYCdoFkPo/KzedzSxqdHVLL0DnIiEiizk/CWj4gC7musYLX4symr3uZH+YjGkTzDgtXuMGp1YYQjo6y7oC2yffhMoXcOQEqTI7sOG/+feI3ptFvrTpGoQi/bBJRKmA/GHK6wGL+w5BelNhFlM86NPbgFwTmZpY5gwr0TAcXFklrXahBz1Xuu0HpAA5sIYY2Tsk1AnfWsjB2mR6z8IVfkU6lLgHG7G/8SI/35aPUPlUxf437+1YsIgYrJ7meJGvHx72c/0yy/gUJvYuXlpmeiNK1XhQJJiSb5LvZU7WK6wL7ES9eHP1SZ+AC76wSyqLfgbgHglbpSm9K7zr9Vc05kSczRP87zaezxCw== 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 wrapper 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); +}