From patchwork Fri May 19 07:40:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13247767 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 5399AC77B7F for ; Fri, 19 May 2023 07:41:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB972900012; Fri, 19 May 2023 03:41:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4292900003; Fri, 19 May 2023 03:41:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE25D900012; Fri, 19 May 2023 03:41:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B7826900003 for ; Fri, 19 May 2023 03:41:52 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8AC501209DD for ; Fri, 19 May 2023 07:41:52 +0000 (UTC) X-FDA: 80806210464.09.6B2DBE3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id D0274A0005 for ; Fri, 19 May 2023 07:41:50 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EYxiqhl+; spf=pass (imf15.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=1684482110; 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=zBEjCltxDmlnA0oSyuagNhPyHRx1meJicqC3uPUtKyk=; b=2I4UR+EZk80gZp1kglwMuhk9MfPh4ytQOx2MOu7bcxMcRWhHk4lpT692eiO3tB5rlMqBF8 1LblLHDCw5iCBrQnjQbYDaXiSx7nxx912HI7iGgxpfZNES3DCauGXCeq3x9pTUFnfZ0DgA eP+56rNMm/3X+UBbf4pTszZoY851ll8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684482110; a=rsa-sha256; cv=none; b=H+f4swdf/kSfmh1nfXfls00Xl+AxnDp/fsVGbIBv7RPQEiZdimeSDZ4FVkKpapvGbf7dEK xdYZcC737LC9+WdrNKTmFH4AR43TMtlahLlSX4lglR9NRUeeo635pWbsWU2Kf8tiyIkJPF yOov6JahXyjP2py3W3ngmwqewRuMIs8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EYxiqhl+; spf=pass (imf15.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=1684482110; 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=zBEjCltxDmlnA0oSyuagNhPyHRx1meJicqC3uPUtKyk=; b=EYxiqhl++3sqvm3CcX3n7fgqDodqw8MRLIzTkLYnzZrGhPxFM4EctmSnUEnL+IB/JrurKY WTj7FfnTmfqQOF1hn/GacI5n1wp1+cydMA2e/oXwAYnQTRVuPjqzrn5zlMLfrGUx33xwN7 uXlnzMRAzH2UlubYnyryLzu1PLyv6Ig= 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-500-_1BGeCTTMTyFaYpS14WWgQ-1; Fri, 19 May 2023 03:41:43 -0400 X-MC-Unique: _1BGeCTTMTyFaYpS14WWgQ-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 B00A03C02180; Fri, 19 May 2023 07:41:42 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7169740CFD45; Fri, 19 May 2023 07:41:40 +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 v20 12/32] afs: Provide a splice-read stub Date: Fri, 19 May 2023 08:40:27 +0100 Message-Id: <20230519074047.1739879-13-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: D0274A0005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qay8hb64yh1pw6x16h7aqb7cfw6oyg1f X-HE-Tag: 1684482110-423679 X-HE-Meta: U2FsdGVkX1+SNTyE5NCnympOvZ7xdJU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ifAl7tQvnUmRy82+JrHM17QBBwNCM8vGDuxa+ddpAo7qKolsx/buLoweFdJY/lyUpY9/vUQ3tr+924r0UIdLhTIzB7m3fCmWLdf4rOw+c1qWV1dRFyZnh7sSsP55wg897zBGxReoeIZr582BhWxFJWuqTB8u6HjqxmYrBkG6nthiuESYI7N1THxRt76FGGqA4ArWJMYrW7A9kxeL8krCGUlEKsEumvV1zvnchm50P1aVsJWH1WfGnDa/pP5Eun2sBLPhTM6Gx2iKidOvSD/pDH9H/as13PKgFWy7zAZxAwlfA7j8KpF15o4U5dOI0rlAmojZKlF1VXT3Ze+4EQsKGzsGO/W5F1E+5vioA== 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 i_size can be brought as up to date as possible. 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); +}