From patchwork Mon May 22 13:49:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250581 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 BBBF3C77B75 for ; Mon, 22 May 2023 13:50:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CE33900004; Mon, 22 May 2023 09:50:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 47CDA900002; Mon, 22 May 2023 09:50:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34500900004; Mon, 22 May 2023 09:50:41 -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 278D6900002 for ; Mon, 22 May 2023 09:50:41 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C35764031F for ; Mon, 22 May 2023 13:50:40 +0000 (UTC) X-FDA: 80818026240.04.585152F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id D24D112000C for ; Mon, 22 May 2023 13:50:37 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Dvu4pWNd; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1684763437; 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=5heG8daRS4C75Yq10maO32wWxD0HQE2hn6bd0CfPaUs=; b=QLdEt3nlPl+RSa84+bOuktUBrY6EeHmqIKh6jxPu9SKpakRIh0T7kL2CFB2CgC+ShflBi0 dyparSlQRGepqfc6eBIZtcHMsmabM5LmbC7Ds1T6cT4YF4yzwPHcxoETdvx1dZQNJNGHxW Fe8vNR6sKChNG5evDYeJHB0VOCthQnU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Dvu4pWNd; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.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=1684763437; a=rsa-sha256; cv=none; b=HWQaBDvinexm22181njx/SmO6KjUmjTogPtzy7Iu8cMp1p25YVlwmi5603Atk+BoiLQ7bk w/k1OaMTjpz5FhRKeUjWWLLsKkkAGu1tsdxUmvamGDERLd8TO9fVbESJ2u4CIWtDBVrIQR THfaWrvWnylFh9YcsoQURJ0FMxQhK8E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763437; 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=5heG8daRS4C75Yq10maO32wWxD0HQE2hn6bd0CfPaUs=; b=Dvu4pWNdLi0I+z8vrkwP2ggMrz4UxAB0k4HDSPrvJMFsIp6v8Ykz35guK4EGsi3dhdwfDl jCpFCbkmHpq/LMmENeDYAMT705sJdXocyGJg0AGKI+c2IG/M+DLFi9aDptWgTJefmuiJTT pjq+x7koAzO9doCmFwyKMnj3VBUA6ZE= 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-155-ZtRXgNxwOsysPKvv-a1tRA-1; Mon, 22 May 2023 09:50:31 -0400 X-MC-Unique: ZtRXgNxwOsysPKvv-a1tRA-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 759A9802A55; Mon, 22 May 2023 13:50:30 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id B886C40CFD46; Mon, 22 May 2023 13:50:26 +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 , Steve French , John Hubbard Subject: [PATCH v22 01/31] splice: Fix filemap_splice_read() to use the correct inode Date: Mon, 22 May 2023 14:49:48 +0100 Message-Id: <20230522135018.2742245-2-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.1 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D24D112000C X-Stat-Signature: oq71g5dpuu6nrks6bwmtdfbh8p3frg6i X-Rspam-User: X-HE-Tag: 1684763437-502783 X-HE-Meta: U2FsdGVkX18l1/AUuzDg/5dDwEoXQlaLMqauGp9704W9OL33A5Qz15VCMAlXdImI890mCN/ZZapVfXlNph466Q+z9BSYMjo4SQlHtstzQc5Wn2D0iG/yrb3XSjS7M2E8zUQrL9RzPrPuoNRA4BkxpxD/zlmL7ncW03MaQBg5T4+cpFyc5qBw7RbLzqTk1cED/rT19ddWwOog8jHVA4qkAcEit4nAH9VdcfH3p3i3ia0PHH0AsYtWVx3N3IS6eIfYcL2IrkFD8rYh6wUIWAeqERey7PwP1hfjanbRLNr7IZOt/HIGL2MmTs8gyT/E98sUMss/PQFofs2ZbGcQkMlyAjOBtYcai7f577+KvNsCpOz/p9jxsgXTmbtU3I3hTHNHEuouIUn1H+XF4pQnRxBKXMAnKcmLU9gbi2WNJ6++KQ5JTYIv9wiuLtpocezgOQY6XnNpKfZCH9MJI2n+hy2DVUfGUkEE4m2BOq+q4AMc0BB3FHSY9TMhakpygI1rlbJyPqnYOpn7rNbxaWxFCJo0b7LhQUlXReyan7SwKuV/vGP9/q0gO1nrvJqK7LTgIUo9AE22W/6XG7OM2adHP0bgiu8QIhsJ3B54Uudni3mJBjMrDY+TmLFsH+VR4PJecPKRhX2CcZiDlDfyAB4pkQWgzQLJaZ6MfeO3U/6/2/he2ZMVJJUaMH+C/esxagWOpomZd6YvTna7nMaQwHxN2wXW/u6TnE0ipCrYLD6WCNdkJXpAGe9kf8qipMKa90svIoqoNTI0TMuiunI1674yubMAn/aA715jCGk21UcltFYZb55jfT+PHgB6THDKo3/2y90mStzyHl1Bpb8W3uZ05WKSDGLb07Q0zWHACT+t+PB4o+GM4mmDSfqptGpUyuyBXMKS6SDZ1RPXe/MBJJeqS1LuwRfzv00t+laKmQ+5AjcXFWx2LC/hEayAKhuVGTv+Q2RFHDsnApqGay60jpy4YI/ DLYSRMH+ tHmVEYc8tnBjjCHlLj4Qv9RFRLwb+awFpppRMJi/ALip+U+LQWjM4VN0ebRAk3TMhbz/76ofc1dAzJJWzxTlS7RfDmev7uzMrxrGGeCwpSQ1vA0RCKhkUzFHiulcrlxpOrT7eFG6lZZG+NdKYPPVD391O42nKULtfzAJ9CBmUKvOv5i0zuEiJt6AxtWhq/hwC7u1esqbHnao8mywmW6QPVOn6D2MZq2hRUFBc9o86EaskXxHPb9kpuJzJbyrtdDVNHTXQMmPndyjb4gc2TA+dddngyS9DgcEdS302ANXVSg4AsGEsZfFy4Wg84oiIKn7tynwcbFF2k5h9vD7yrdQpOfL93BlmS+ZAm9zG86eQlFtKujhP/8y2IMUbosjr4pqxG86U0OGkZGeubft/lXl2e/cGq9DFbMHd6XMW/CUJibbVrY23UrtdSC3dbn9iTm1KnFbN 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: Fix filemap_splice_read() to use file->f_mapping->host, not file->f_inode, as the source of the file size because in the case of a block device, file->f_inode points to the block-special file (which is typically 0 length) and not the backing store. Fixes: 07073eb01c5f ("splice: Add a func to do a splice from a buffered file without ITER_PIPE") Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Steve French cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- mm/filemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index b4c9bd368b7e..a2006936a6ae 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2900,7 +2900,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, do { cond_resched(); - if (*ppos >= i_size_read(file_inode(in))) + if (*ppos >= i_size_read(in->f_mapping->host)) break; iocb.ki_pos = *ppos; @@ -2916,7 +2916,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, * part of the page is not copied back to userspace (unless * another truncate extends the file - this is desired though). */ - isize = i_size_read(file_inode(in)); + isize = i_size_read(in->f_mapping->host); if (unlikely(*ppos >= isize)) break; end_offset = min_t(loff_t, isize, *ppos + len); From patchwork Mon May 22 13:49:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250582 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 2237AC77B75 for ; Mon, 22 May 2023 13:50:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AEB4900005; Mon, 22 May 2023 09:50:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95F20900002; Mon, 22 May 2023 09:50:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 826ED900005; Mon, 22 May 2023 09:50:45 -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 65BA9900002 for ; Mon, 22 May 2023 09:50:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 364BC40298 for ; Mon, 22 May 2023 13:50:45 +0000 (UTC) X-FDA: 80818026450.27.9593C09 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 53A0280014 for ; Mon, 22 May 2023 13:50:43 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XQXYK46i; spf=pass (imf02.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=1684763443; 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=KE9n9iro3FTjdaHiFIooYMOpWcibwpM8czGND8V/VvE=; b=tnG2hlONA/qaMJw2uFWNLlTOcNr1dtq+YrNpYMcJBmqWeHirEFBH2rKog5yZwyNRXCdEj0 jG4w3F7Ew+8mp7erbVPVc1HF7rOSnp7Ce0vZZCOfdyB45UW9Mfeg9RVKItQ+1tB8kFr7YX RfifZKuxqsXB1rc7DsFCaNeK+WMoKZ4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763443; a=rsa-sha256; cv=none; b=C2JPBzfEJ5O7r8emvnsD6pHTDFYlHYpU5yvjUpXD/dEqpCavlSAh445JOwyC54EHzPz7t5 ZWr3wvaPqrc4klHoDMSm2JABI4halvhAxkBJUDn/VfTcAVeGfp5VQsC5C97gIyw/K7axXZ e50dCpgJZUWwDfHmnUTXHNPNZACnC+A= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XQXYK46i; spf=pass (imf02.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=1684763442; 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=KE9n9iro3FTjdaHiFIooYMOpWcibwpM8czGND8V/VvE=; b=XQXYK46iuTNWJyhhSTjY0nMxsdlbAOJhQpCCvPuU0xLmfFHyquBxj80n6Prhpwk/2Qypjn /Gc34AS85AXB9xDDHtlQ6aHccmV9JVdz7nDL32AUOEglr3yXHS4YopOojmJoMaNWbdj8xq tMUzB4rDEPShrdQUyJZgTA57buvNV+M= 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-451-ZA03jKiYMVa10ZeylKgdAQ-1; Mon, 22 May 2023 09:50:39 -0400 X-MC-Unique: ZA03jKiYMVa10ZeylKgdAQ-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 C83D4802A55; Mon, 22 May 2023 13:50:33 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BE2940CFD45; Mon, 22 May 2023 13:50:31 +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 , Steve French , John Hubbard Subject: [PATCH v22 02/31] splice: Make filemap_splice_read() check s_maxbytes Date: Mon, 22 May 2023 14:49:49 +0100 Message-Id: <20230522135018.2742245-3-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.1 X-Stat-Signature: zqc9hdnmbs9rpgkoshnmbkwnbzibozki X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 53A0280014 X-Rspam-User: X-HE-Tag: 1684763443-612940 X-HE-Meta: U2FsdGVkX1+s7bF4pQz5H/7sxWh3UeaSwTizETQQa+WNinRu91mTgrvVSl4dswvGPWyzC/jwQkVUFrajJe6wnb0SxspYPoHOYGRCjYuYSRvpuZvlqhmnQwdVUZyAZz8RpD06wILrSvrFjxir+G00bxGx0fLb7dHPHHZ9I2RUVhle9+j776VqWPoztYh3mmXwvR1Gn3ETnxpJ0ZBUfzL9wbMP80wcCERRrEHWomFYaZ2hafGYD4qADd0wceNnVvYCRLL2tiApRedh6xMb4/Z/7fCXbA1va08IFgJFJTTF+yxJ/z2jLVVBNafMZL5nAKq+zZowChiMzDv/ABKmwfS7+F2X+Pjd+k21BP9CaNv6MdRf4TJ9GIPoqOt5Z/YC7Q08HBZ67D7KEFSO69+Nlffz5L4IGNN2fTonjqB+RY/PaGju61cc0kUuCxaS2+5R9Fb1O5evi5Bld81p0Uk4KPV9OvTxVU9eGTe89t1IMkIrrHb3oPV+e0ikjjnqQfppPLbCPF+rgZeucrZ7d/iPfEVbheuY0Zhg2+ZKMDJEX7rCS/ztnI0TvNWGjgHGpR/Nv1UfZ3giZdWp9Z9T0LApxiJp5pMcE7NRq2yOj5YYTAOsoD4cX7r2o4vyMt+XKcbj6lB9EmFW3PyQmZn7jACxRZAhEfeTjUyjj2VzX1vuZjdcB0mtNcWPJZUU6tP9aIopH9YqtUGIvoHRkFDn18Gm+XWHOradP3QQmhzrJH4b8iobB2h+FbnWjWvMPL+oLWegUBxjdahrAQFHknyiWCIJ2Uy8VDEun9+0+uWTYqLtpRC9AMqVbyKs57iDQ2XFacCZliVdujL0BMi2GPefYGKmktJqEY2in2mT9UL/FDvTnbcY89xYVdClsYtM40ESxT6LPl0gXi5EJFrzmlChTsTC4MSRAwAGgcATjvT/4Qskb/lZrKh/yb56bzqFpVZns0bCXzPtLG9gp/4j5VakiiJ7Np+ xEJJoN7K O8e17uEeeZV0qNeJFKuoCd8WUC6lXsmNvEToGEvGubkr4uoSd9xtbVBNazhMnLBBlGiEKI/xRzGEA9GtsRgS6JCbrKXWXmMOK+J/b4rER30J90/fScl32MkWfQBgq3YpIG7iMM4lrrPZp0ZFjyIfFep07FTLfVhQsHEKBLinNyjv5xfgbvr809vI8oslz1ph/buW2qUy+pK6DrbDPTSepE9rgzw933h1TVkKGqezDxJmJIDbMAsIw5OA9AJVx0hrM8PVIu3krkM4Cj8PlRl/ooWdVZzIItbjJ3Houh2sww09vwuPulnKXJOWctVvhVwXG78XGU0K9Ts3zqaHyZpQXLmXwO5sG8AhYbXscCRi19kHW1iB0vI5WvDl8A6Xg8OLm/YVYp1IGH6CfknojsFLUZ3m4LTC3CvRXk6XwboPvHr2t/kFbca10zOSne3oEj+p92Q+0 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: Make filemap_splice_read() check s_maxbytes analogously to filemap_read(). Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Steve French cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- mm/filemap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index a2006936a6ae..0fcb0b80c2e2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2887,6 +2887,9 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, bool writably_mapped; int i, error = 0; + if (unlikely(*ppos >= in->f_mapping->host->i_sb->s_maxbytes)) + return 0; + init_sync_kiocb(&iocb, in); iocb.ki_pos = *ppos; From patchwork Mon May 22 13:49:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250583 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 A826EC77B75 for ; Mon, 22 May 2023 13:50:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 47E4F280001; Mon, 22 May 2023 09:50:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 42EA6900002; Mon, 22 May 2023 09:50:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F6FB280001; Mon, 22 May 2023 09:50:49 -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 1D123900002 for ; Mon, 22 May 2023 09:50:49 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EE9B21C6FA6 for ; Mon, 22 May 2023 13:50:48 +0000 (UTC) X-FDA: 80818026576.28.D7BA609 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 1C51840019 for ; Mon, 22 May 2023 13:50:44 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UOPa6WCG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.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=1684763446; 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=IqkXhDjcGTp5qgC2QwXKM8JLGfM3IWsybre/9cqiJ5w=; b=nA2+F0yKDE/GkNz5+9dlwAFLA6mERgqNJoLmA6VvUtOqRdqpXcPLCtrqMeNmzUYCyOMzyv e0fYR2f1Mt8H11sgHQ3a9vBOcoLbHeCfpqhyWvGlUZ1+EnTlkjLpArsftlan2+oTbqs9eg 3AWuy13ui4tiiKPQuDQ9Jaza/ct1duQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UOPa6WCG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.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=1684763446; a=rsa-sha256; cv=none; b=dj/tGjApToTf3shxxZ8Zcml+jOVos1F2MAMvfySNI2fAKgH9qEpocMuMODR78Cq7/Dl40A JlacsnhIUvWbD0w3M6OnCTiw4KFVRRaSDtY/RM4iDyJBx5XDHug5BPwV4pv4jrxaH/0bem vEB3aYwOfqJ0/e25Z8jEwl+ZcNxnwjc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763444; 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=IqkXhDjcGTp5qgC2QwXKM8JLGfM3IWsybre/9cqiJ5w=; b=UOPa6WCGKsICfK4xajaNPVhgj1XfQya/cNfqkodrf7+3fiBUMmQCiBxN8525IUpLGvsO7S Sqg+IQ7+Z9iKI0gPkkG/84O+ctWRujOXlzZ71bxTvin00oBayXfmFj1vqphgwC5nwZBc92 pgZGi+oqaVsvXNxmzUUi9peN82YzEDw= 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-383-QM4O9WzdNfyEMQKKRbb3Hw-1; Mon, 22 May 2023 09:50:40 -0400 X-MC-Unique: QM4O9WzdNfyEMQKKRbb3Hw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 695863C025AD; Mon, 22 May 2023 13:50:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88BEA2166B25; Mon, 22 May 2023 13:50:34 +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 , Steve French , linux-cifs@vger.kernel.org Subject: [PATCH v22 03/31] splice: Rename direct_splice_read() to copy_splice_read() Date: Mon, 22 May 2023 14:49:50 +0100 Message-Id: <20230522135018.2742245-4-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.6 X-Rspamd-Queue-Id: 1C51840019 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 7c4e3t4m9t8ggmtoayxwymd7n4d4p41u X-HE-Tag: 1684763444-905129 X-HE-Meta: U2FsdGVkX1//W47UYPs01rPnB0wRunAGQawcvvF/UEuJAkeEpzlodG3DKIiWXXhDjP9KsPHfmsGr4235y+5Zw8Wyjoljyq0Wef6Vt2b7pQ2STx1f5CQO84lA3puqIdr5JOILt7kBmELl1JGc15DmopsRNjJDo9QWo/nM3pFcTzb0v+DS9RsLtThnqpWxvOenn8On/DulHr6+SF8uA+Y7tFq9VviZj54tYHLd7U5GemRExcV2XC/0aoBUu+0Ym43kaQ9tRxrsbPaxeB2ikitwhg6YCep9JxdG4GFihaMripoLXZqwF6xXP3T7S03y+nzKF83q4bhDaustiWyb7PUasVlETvfdD0/aH4lpl1LqLs5OyT7B1pi2uW6YZTyyLFBNhAnXaLzgsJuRzcilgXSyCIcSV/BkWvC6GAVwFFHy5UVXJGI1CgcYBzEr5WWn67DizRAwlP7hGGSCUDZMLZRoBtVrFSE8av/6oV5D+lkoaWG1LCWN89H8d+rBjjR+L6ERhLeCSNwjt3E5LGd8u/zF+/t9rwY33WLwA1z2qH/s2YuIYOLmLQDlDhOXHmTBpBFS4Y7ONKxBohgMuwcogH5mfeA+QxI2yGOWYM1j8MQAyo5Y05STMW+r9No0vgEILj3hwdVH3kHwMM3qeccGEIxPiRZxXM0vPy7M0Nnolohk5mTNzMIC4PUiwLjJVFXfArpAEi8Acwd3qXuEl645uTK+LHZBiVNA+I6ePEEikfejIU1/2xmPlFgq5v1Kp5XhiQWmoaZyeU2fzLKdvXqpzNPm1wSLxmkoBceVqHm1EEhJg5gu9OF+I5wY5NUCVV6NSFPVZ/sKYy4puPX15prW5YaFbNR7y6hoZsQCJa90cXX10H/oyyWEORyy8djfWeVeaUPSM1AXbiYVMH7xhsoVhKY9kYu+jNl3GVzvUPtvusNdcSE7IFgCiMf9BPmEs73xaLwc5rktzVMndNiIO1l2BIX 1vCJtX0e f7hwP4b0oZT65SLQHkDNYEVnwkOJm4ZCDJCgFLFOOv39Qle0werrRbwi+MI81sLbHMNMd9PcnZJztdKEjj5u/Z93EhEzPiU5rKW6zaBYkhdblqnKADWazPwVzvvjHBjgV80GUBP/uukceL+9BQbvn13fMUPNOQn9rJMo6Y4SfXBrar0JL48yxoNYOBPcJSW5rMTm78KkkY50/NMnnMwlnlmDASl3YTc6RJ1HasFhWYvz+DV60XE7n+Uaki3XfGlFgVqlRQYUcQB19XH7adSiTP7H1pr5oYqR56NhRqIIQYzJOIcTOunjuzy9NF5WGZhXkFyBwIzU8oKTDeXi+35Gn5YHARW04FQzwAI2+9uc/ZpBOywebWzifwVPfEPWzP9AIuAIc3Bt4jRbQBsj2yX9DBFARNlN5AhN+egW4mSrNmm8mGClNnvAyvGRryeRQ9SCKgMxo11qPM41z0YA= 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: Rename direct_splice_read() to copy_splice_read() to better reflect as to what it does. Suggested-by: Christoph Hellwig Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Steve French cc: Jens Axboe cc: Al Viro cc: linux-cifs@vger.kernel.org cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- Notes: ver #21) - Rename direct_splice_read() to copy_splice_read(). fs/cifs/cifsfs.c | 4 ++-- fs/cifs/file.c | 2 +- fs/splice.c | 11 +++++------ include/linux/fs.h | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 43a4d8603db3..fa2477bbcc86 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1416,7 +1416,7 @@ const struct file_operations cifs_file_direct_ops = { .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, - .splice_read = direct_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, @@ -1470,7 +1470,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = { .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, - .splice_read = direct_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, diff --git a/fs/cifs/file.c b/fs/cifs/file.c index c5fcefdfd797..023496207c18 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -5091,6 +5091,6 @@ ssize_t cifs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!len)) return 0; if (in->f_flags & O_DIRECT) - return direct_splice_read(in, ppos, pipe, len, flags); + return copy_splice_read(in, ppos, pipe, len, flags); return filemap_splice_read(in, ppos, pipe, len, flags); } diff --git a/fs/splice.c b/fs/splice.c index 3e06611d19ae..2478e065bc53 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -300,12 +300,11 @@ void splice_shrink_spd(struct splice_pipe_desc *spd) } /* - * Splice data from an O_DIRECT file into pages and then add them to the output - * pipe. + * Copy data from a file into pages and then splice those into the output pipe. */ -ssize_t direct_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, - size_t len, unsigned int flags) +ssize_t copy_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) { struct iov_iter to; struct bio_vec *bv; @@ -390,7 +389,7 @@ ssize_t direct_splice_read(struct file *in, loff_t *ppos, kfree(bv); return ret; } -EXPORT_SYMBOL(direct_splice_read); +EXPORT_SYMBOL(copy_splice_read); /** * generic_file_splice_read - splice data from file to a pipe diff --git a/include/linux/fs.h b/include/linux/fs.h index 21a981680856..e3c22efa413e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2752,9 +2752,9 @@ ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb, ssize_t filemap_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags); -ssize_t direct_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, - size_t len, unsigned int flags); +ssize_t copy_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags); extern ssize_t generic_file_splice_read(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); extern ssize_t iter_file_splice_write(struct pipe_inode_info *, From patchwork Mon May 22 13:49:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250584 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 98597C7EE29 for ; Mon, 22 May 2023 13:50:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4809900002; Mon, 22 May 2023 09:50:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF6EF280002; Mon, 22 May 2023 09:50:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9755900006; Mon, 22 May 2023 09:50:49 -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 9BC9D900002 for ; Mon, 22 May 2023 09:50:49 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 64842C019E for ; Mon, 22 May 2023 13:50:49 +0000 (UTC) X-FDA: 80818026618.23.0CC0C6D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 8B8D840014 for ; Mon, 22 May 2023 13:50:47 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=irRwId0b; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1684763447; a=rsa-sha256; cv=none; b=oy2iyWfRBLkMRefn+BpxNQbf+pcNJqGDY/XlpavhnGWa2ZQcxP+bVBks48KdWw28C4RnRq DrZX7HLuPlcCiY8Lp2bNNsptUQnvzJTdg+87eMhsRLDv4PL9cxCuIeXhGe/VGr5HnPea+o Ier2+D6VnnbYC2AsnHm6/g7GXhU3usM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=irRwId0b; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1684763447; 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=+QycUCk1EhV64OEFYi0Ywr/xSgjmAM7Sud1UY4yTKxE=; b=1OQaYmt6tMmfg4o1IJAWfHYr9GrRoA5kOpGWgfDns2Wlf3lGZYpkaBkMbMTEyEhlUsZimc dlMxpLiHYdsFO6G7Amb3ctU0FwZlqCswbiCQ/WSaWHDx4gfy5nqpQiUIB7wq5v2WIL7hF9 8sW67a5FH+l7lrDZzF0t/BFtdAXFz3Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763446; 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=+QycUCk1EhV64OEFYi0Ywr/xSgjmAM7Sud1UY4yTKxE=; b=irRwId0b7rmrkvFKJGDi5rMomGoLAcVNHD3gfrMJbmzxHoQFvXLan8va9T53clU+p7RTp+ bCfl/B3nF1FJhEnbooXWxUflQUHFBpDETU7lrOc4icWGlZc/+mrWt9BxfoldR/H4vAsbad w1dGvn6OkRH7Ednh04r+CZOnrWbR7Hw= 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-31-5SDxrfwzNriOr4rM0S6JVg-1; Mon, 22 May 2023 09:50:41 -0400 X-MC-Unique: 5SDxrfwzNriOr4rM0S6JVg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8CC9185A78E; Mon, 22 May 2023 13:50:40 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A3B22166B25; Mon, 22 May 2023 13:50: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 , John Hubbard Subject: [PATCH v22 04/31] splice: Clean up copy_splice_read() a bit Date: Mon, 22 May 2023 14:49:51 +0100 Message-Id: <20230522135018.2742245-5-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.6 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8B8D840014 X-Stat-Signature: gefage8t446yne1doqedaztxyzqm7pi8 X-HE-Tag: 1684763447-196718 X-HE-Meta: U2FsdGVkX1+XrChWSH2oZgCqbJrp8z9ebPf32JYyjN4HSd1TrGtjUe/3fzzMFaOb3VhxkXbJnh6DCQwhMecboxjj8OJunqOP92f+P2LMp4o1O1ZDSAjDgOH8AgxORgXSBa7B3pVKceOJGTJfYdApy7q6p7ZGcq4UkYYyNUEXkCuz2uscttSyqHhmn+rAOKV/p0J144QHKedaZzDwJ9hDdLpM7IdvUJzVrx+NE7+MJANb1Ex69tsiEOYUGoccFzvjOPU26TY9QbEf7jY9zDslitYA73zrr2BYEeAJTNiRbYzKlAXv3NCMRbEbZ2MCmwhRN3JldeRoPj0WZDICaeh60zHkZOrRlGXXBdYmbjzsdf+9JRnOP/mCCP6+hbqjRsa5Ho/49hPXTWBN2wK6LQp3o6lVybFKkUstS3cMCvQ6exiX/yO2C2+oOX+W8RR+YgMHawGw6Y0PtcQcg3M3ieWF8/9Fcm6wtHcZyBvPY3fqBplMSUvml4CaIHtelInB6fq9Y0ikJOkGBdocpxgA/f0k92I+K6///HdfLhFm1lKLzDvefEFB23kyByQSM/5yC4bLtQUR/nq4f1I6P8pFwkHFiYJh1cvAnQkr9sYxTUrzomPvTSKAQmD4MtlEYlQ7uF9WQ1ZHFjU7jjX2G3bEUgRItFelcqXykd3RvmgziCW1iXsXYoTd+3ENBy/CkPfYIxFQM4XGl4jaRzjBiW+lYCwIeo1gnOWJv/DZEcSu1OVucM4u6eD0mOZhXa3vR7FPcWK6uzCl4rtLi9oUz2vJI0nXqASlCd5N2VBTNM9yCUKY+ZW8t/giASYdIIDwU36Po0uDjNnc0sL1yL1vQjRjq3R0JihEYj4GFj5mxsI1Fya/1sLysfVqk57j0qPDEmBiUnFeHY9jZDAoPKp9vGPnhWlZlRD1U9+xm9bfFUnbqXe4c8PGgv9E9tbNAcdzFSxRR2yEOBE+HMjSxsX2eVBjGWL bDzHd3hU e8TRvZHlzOitJ2dlRFtIoLQlXdjcSl5am7ozKIUJxytt7b8uw2WStvn9Lv4W3GUdHyARkh9xHY7xAZcSdUqV2fBNo3GF1p1krzdlhGXUT1tGIl7yU42edDJ2C+hhd3zFLt4VBjnZKudPap9anxlCcNqbaKwTwSNIpKH+qfeKaKSo31IDw2tORhAFPFBpOubQ7aEaaVjwou2EJ+AYZ10SOcMa5rWk1+NjRvYsu4VI5hwLiepnPokdxEB3FTAVyUHHZnq9jRX560x2DQSvrZ8HFmJFm4pZ1vNPCWkh6CkgBc+m9cN7sSXSAHrl5s6b46Y6OAa/uckcXD8mrntR5qWx5MmSjAjArYIQrbYVkspjTCuCOwlB3hqwl8ouPWMivqDUR/CJYMFQtf9lNgpUqAbx3C/CVzktm7ufnh26oDZhLbW4aHeEZbyrNxVbepBRpmdE2l10mFjiy6eLXHi1QaEpKB/7kEJEI5LlyoE40 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: Do a couple of cleanups to copy_splice_read(): (1) Cast to struct page **, not void *. (2) Simplify the calculation of the number of pages to keep/reclaim in copy_splice_read(). Suggested-by: Christoph Hellwig Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- Notes: ver #21) - direct_splice_read() got renamed to copy_splice_read(). fs/splice.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 2478e065bc53..f9a9be797b0c 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -311,7 +311,7 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, struct kiocb kiocb; struct page **pages; ssize_t ret; - size_t used, npages, chunk, remain, reclaim; + size_t used, npages, chunk, remain, keep = 0; int i; /* Work out how much data we can actually add into the pipe */ @@ -325,7 +325,7 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, if (!bv) return -ENOMEM; - pages = (void *)(bv + npages); + pages = (struct page **)(bv + npages); npages = alloc_pages_bulk_array(GFP_USER, npages, pages); if (!npages) { kfree(bv); @@ -348,11 +348,8 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, kiocb.ki_pos = *ppos; ret = call_read_iter(in, &kiocb, &to); - reclaim = npages * PAGE_SIZE; - remain = 0; if (ret > 0) { - reclaim -= ret; - remain = ret; + keep = DIV_ROUND_UP(ret, PAGE_SIZE); *ppos = kiocb.ki_pos; file_accessed(in); } else if (ret < 0) { @@ -365,14 +362,12 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, } /* Free any pages that didn't get touched at all. */ - reclaim /= PAGE_SIZE; - if (reclaim) { - npages -= reclaim; - release_pages(pages + npages, reclaim); - } + if (keep < npages) + release_pages(pages + keep, npages - keep); /* Push the remaining pages into the pipe. */ - for (i = 0; i < npages; i++) { + remain = ret; + for (i = 0; i < keep; i++) { struct pipe_buffer *buf = pipe_head_buf(pipe); chunk = min_t(size_t, remain, PAGE_SIZE); From patchwork Mon May 22 13:49:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250585 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 CD704C77B75 for ; Mon, 22 May 2023 13:50:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A190280003; Mon, 22 May 2023 09:50:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 652C8280002; Mon, 22 May 2023 09:50:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54D20280003; Mon, 22 May 2023 09:50:53 -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 44213280002 for ; Mon, 22 May 2023 09:50:53 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9A40216027F for ; Mon, 22 May 2023 13:50:52 +0000 (UTC) X-FDA: 80818026744.21.145777F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id B5DC0C0016 for ; Mon, 22 May 2023 13:50:49 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SS7NsFAS; spf=pass (imf22.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=1684763449; 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=pM2ysDzppt/NTb8ZyH27IEzbM3T0VU0XmStR2DOq6rE=; b=Q3XGVQuCx88g5dUMa0LKaLWRuu9GOlu6oBRpAShLUk9CaMRo0OMNug5zpj0q4ofGwQqIjK kNuaFlBK80BYP9AedwYDkcB1liEYVd2WYnnOKvlHbOWDsfQJ+yVn0Kw2eVymKfntMz+pcL 89TQ+tymuPyyMXGebeL0m9G4AiXwLKg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763449; a=rsa-sha256; cv=none; b=5tWqS2oV+VyUvszr3v55eVdTFnr0MnPeVLrqxlvX479bq1aTfjTM1oH2Iub2bgcAkjWHiX KFwiRhbOTs/72JaHp9Mcx4vNVzQ6k49VoH8Q41NApufZmOv8wOpQY+qucCo/l9PVmVHQgi 4mhX8p73pQ36NuCI+Gcdhb1451AuogQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SS7NsFAS; spf=pass (imf22.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=1684763449; 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=pM2ysDzppt/NTb8ZyH27IEzbM3T0VU0XmStR2DOq6rE=; b=SS7NsFASiIta7fo9ki72BUGPXIlM8RpvEJQsWk5fyELmuhKfz7tR3ipYp8FW0VGEcrGWXt F2+Ex1YwLecY/ID53kxoCuJCZ6okzfrVlbnpdJs+2hRQjZKq9MEA+afIq56TVWj3sIstMR Z/dy6IKe9SOlfiXUBSPfgpmEnvU7eEA= 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-553-qL7E6ESWO2O9-esN8xS6hw-1; Mon, 22 May 2023 09:50:45 -0400 X-MC-Unique: qL7E6ESWO2O9-esN8xS6hw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBA44101AA74; Mon, 22 May 2023 13:50:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 882EE40C6CD8; Mon, 22 May 2023 13:50:41 +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 , Miklos Szeredi , John Hubbard , linux-unionfs@vger.kernel.org Subject: [PATCH v22 05/31] splice: Make do_splice_to() generic and export it Date: Mon, 22 May 2023 14:49:52 +0100 Message-Id: <20230522135018.2742245-6-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.2 X-Rspamd-Queue-Id: B5DC0C0016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: rqkgwmsx5ajq7p71x9wrbio4tx5h4wdc X-HE-Tag: 1684763449-795473 X-HE-Meta: U2FsdGVkX1+N0RscRrA6miFkR9al8dOnc9lVN9ygJ3kC3VNwU4ntUrHc7XviKg8nNuo7NusL4T3REbz1VFxXad6N+fs3lq8jst2S1X4lDs4+y8QuNpTryLvphmnd5WVUnUIlt/n3XKKmCJJZ/SVF3yWSrPcLa2JjcPwRfRvtk0sHAfqhVQ6ljim15XfuBlHHKKSsn5we6zz/ESmz0pVr/1kvWmo7ds0zCYItJnMUG9LVAPE0dnvkmczWRPLnL7rxY4KMmdJ2WIYI/z40coRADRKuuUTykhJhTTh7Td9l5vyom4qvuwhRbUbSUghF3wfmtAHoCzSGJghVoZcm3l680luTCJtkXpO0Rk/GspL/+rN72R8os3O34PJIzmavIxsRHeSEiACnUTzz3ZwYjhuJ/wAHCfgfQKgbUw5VXnaeMdJjceAxSGee2jrAmZxdf5WdFenWYz6yxO7TnRGuJR7L6vziblI0pzSbDQSOehEp+jLrj8XhccTC2xCgKH435Wa+BPMHAcz+YxTpNsCzau+A3gZHuIXLtEPKyY8XkDlaeA3BagcYzeyDNzkE+8c7vX8UDob9wEXmimximT8Uwpbt07eGwOM6ZLd7qC+B2Gz2cuVBXlIk2Gnk57p0rI3ibKQo5JV8IdTjkgymK/I5PFQJWTl1yhyqNWw8mKFZV2hrO0HeyuWulKv4hlw78tyh9ZX0QjYuPo4GjxzTjFW5kgmCGpEP86gq6YlrzlsL29qI8eVhOUKil3LWrZlo+qu+kU76FxZB2NNug1EEOlIL90takV/ItjTtqOgDS4u2MC95LeB0Rd76e5nL2RxTXP5C0XY0W3BqKUYUNbzrWa6pwgAvLohfZ+kOn0lel6LCQ4bOy6yxcrANqtAT3wajDTDOaHNEtDQUc0kikwjKzTVTsaXeCfkcOI3QfYQXIRBPv10HsFeD7Z1ZhQq0F7YKoWALYRZBf3+yRICFaArQ/4rH5eQ 5T2JZ6Do dXb8EnyYO87vYvksWz3DUDfy2R26OnEXNsodGJhL9vGu5rPqqcFJ2WX2OOG7IpL5OKnqOkSU7yqyvMl2nb1gxRRfShPgOozU/Eb/PJmFhrf+rSUoN8lrLpF1j3VD3FGhxwDtC0aLCA/DOmWoMS/2rCEV5aQafktBotfZSeswI7oIuD58THkGdeq39+DaktKa6pllnF5Yd2HQJaZpwgVJc6cU2Myth5DALBtQwnFWcMwxkvRBu5wzF58EPYxi+gBDR4qBTAoMqsgqTwtCBxhGvFSGgIvWEaay5oSndhLh0OUsyccz/FYreS0mmT/HkdhkQQbjmXHOYKX0qNbnE98j7D2Mm0BEZfOqx5j64bKzJM7i1RN36LpucmspYomv1Z3ecVTCj09i0J4Xedu7yTLHo4lCcl/m4RCZo2rOmQTUSsms8d2iZrLfJ4ZleIN3FlwjAX+iOCUV7LvuNOL1/ZP9KVQFfIYkHmKGybpPwwvX8jkJmqASVioDDp7yDJw70kUxMq21v 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: Rename do_splice_to() to vfs_splice_read() and export it so that it can be used as a helper when calling down to a lower layer filesystem as it performs all the necessary checks[1]. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Miklos Szeredi cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: linux-unionfs@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org Link: https://lore.kernel.org/r/CAJfpeguGksS3sCigmRi9hJdUec8qtM9f+_9jC1rJhsXT+dV01w@mail.gmail.com/ [1] --- fs/splice.c | 27 ++++++++++++++++++++------- include/linux/splice.h | 3 +++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index f9a9be797b0c..d815a69f6589 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -867,12 +867,24 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, return out->f_op->splice_write(pipe, out, ppos, len, flags); } -/* - * Attempt to initiate a splice from a file to a pipe. +/** + * vfs_splice_read - Read data from a file and splice it into a pipe + * @in: File to splice from + * @ppos: Input file offset + * @pipe: Pipe to splice to + * @len: Number of bytes to splice + * @flags: Splice modifier flags (SPLICE_F_*) + * + * Splice the requested amount of data from the input file to the pipe. This + * is synchronous as the caller must hold the pipe lock across the entire + * operation. + * + * If successful, it returns the amount of data spliced, 0 if it hit the EOF or + * a hole and a negative error code otherwise. */ -static long do_splice_to(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags) +long vfs_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, size_t len, + unsigned int flags) { unsigned int p_space; int ret; @@ -895,6 +907,7 @@ static long do_splice_to(struct file *in, loff_t *ppos, return warn_unsupported(in, "read"); return in->f_op->splice_read(in, ppos, pipe, len, flags); } +EXPORT_SYMBOL_GPL(vfs_splice_read); /** * splice_direct_to_actor - splices data directly between two non-pipes @@ -964,7 +977,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, size_t read_len; loff_t pos = sd->pos, prev_pos = pos; - ret = do_splice_to(in, &pos, pipe, len, flags); + ret = vfs_splice_read(in, &pos, pipe, len, flags); if (unlikely(ret <= 0)) goto out_release; @@ -1112,7 +1125,7 @@ long splice_file_to_pipe(struct file *in, pipe_lock(opipe); ret = wait_for_space(opipe, flags); if (!ret) - ret = do_splice_to(in, offset, opipe, len, flags); + ret = vfs_splice_read(in, offset, opipe, len, flags); pipe_unlock(opipe); if (ret > 0) wakeup_pipe_readers(opipe); diff --git a/include/linux/splice.h b/include/linux/splice.h index a55179fd60fc..8f052c3dae95 100644 --- a/include/linux/splice.h +++ b/include/linux/splice.h @@ -76,6 +76,9 @@ extern ssize_t splice_to_pipe(struct pipe_inode_info *, struct splice_pipe_desc *); extern ssize_t add_to_pipe(struct pipe_inode_info *, struct pipe_buffer *); +long vfs_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, size_t len, + unsigned int flags); extern ssize_t splice_direct_to_actor(struct file *, struct splice_desc *, splice_direct_actor *); extern long do_splice(struct file *in, loff_t *off_in, From patchwork Mon May 22 13:49:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250586 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 6A3BEC77B73 for ; Mon, 22 May 2023 13:50:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2DD3280004; Mon, 22 May 2023 09:50:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB6D5280002; Mon, 22 May 2023 09:50:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7EB7280004; Mon, 22 May 2023 09:50:54 -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 BFED5280002 for ; Mon, 22 May 2023 09:50:54 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8EEC21A0327 for ; Mon, 22 May 2023 13:50:54 +0000 (UTC) X-FDA: 80818026828.05.AB1282F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id BD526100015 for ; Mon, 22 May 2023 13:50:52 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VklACMMH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.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=1684763452; 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=OAfj5fBZSZu8a/UyjUmcAHzT3o8yzjmkKwDwGprM6r0=; b=MP4VwHG5Zhby6yZx/r59y06jSmpPDv+J0cxQeBwAiM9WR5IqLqXj+8evqhsloWUFba0Om2 WRKdcME85lLjyRX9GXVLgTX2Jp9LSEkegAYi/irIadyrYdYXiwUPg0lnAqI6X0zzBnevsm QdPCJeniFZ8SNhZZjboPHyva5iLOvVY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VklACMMH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.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=1684763452; a=rsa-sha256; cv=none; b=H1a3pJYFXvguUG/KRkF9SP6nswZp5hxjWNT6Jln/SlM9qahMR0zb+AxooU7MmQ0FhFKkga ST9uiyWY/H5idLUyaj71hnw9dfApR4vfVB3zel/Ff+rf+v333cYhb9dDXA4cArThY1gGCi hPYxBfzSM7Ze/n0nRCYi4uElJ3xAue4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763452; 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=OAfj5fBZSZu8a/UyjUmcAHzT3o8yzjmkKwDwGprM6r0=; b=VklACMMH8QUbz5ndWOQFK65p+yWfpfru3ae58f9Jnf2QLrjTVwgP/SexBjxId+9pyricnA f6wo69ZNXyjCI828RcW6tPaZ0WQR15jCuFo2Sy4+JZ9fw9GlLvAqiGuJIIA5RnYxpYTGUa j6D7sonQWbG7uZ/DnXEOUDCveeacYFE= 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-315-ESFFS34sPvibgfGTGCbRAQ-1; Mon, 22 May 2023 09:50:49 -0400 X-MC-Unique: ESFFS34sPvibgfGTGCbRAQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 160012812947; Mon, 22 May 2023 13:50:48 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0BB8C1ED99; Mon, 22 May 2023 13:50:45 +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 Subject: [PATCH v22 06/31] splice: Check for zero count in vfs_splice_read() Date: Mon, 22 May 2023 14:49:53 +0100 Message-Id: <20230522135018.2742245-7-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.8 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BD526100015 X-Stat-Signature: juafubn4snoretwsc563kqqoyyia1xqg X-HE-Tag: 1684763452-767482 X-HE-Meta: U2FsdGVkX19tQ6TFQmINuetGL96v1Jd6pZUW50oQo+n/awhlmVrVnblRpN8sxNptA9T8NwdtI23f4Wv6/FwZrUhVZb5xKeCnqEYb1RTO+jExzdXXNMfVxEwNvBC7pRHzmth0/SvVVMtecc1Hl5KYDhvYFkDRJi1PjQYX6yexpLhMs8o5jMYAjVNpXD/yau2hpy1m8Lrw5Ms50t+A4+ZNiTnqzgCP5Qg+YbBbUJL5YkJQ8+HV+vSnfNelfAsqN3OvBffrxWsKdJBT1crzi1Gr8qcpCm8co1d9d6GXlWLuCCo6Lkfxi05rpUFv0ldArMpE4Nz78uaYsftXgklPdXcTf0GyaDmEj+h80FtqgU7U+hd9cRZ3kOT1dSlcxKXbmJy8wQK6c1WpBAjSirbw7uwGm9CfMiQmUuw+SqzQaMze6uVmaJCSxHeXGyxEyexGwUr1a1Z58JSbOWNRHuCSAfAQd0Ve0cXn5Ih1SC322c6cVljBD+NW3ZHyKWE9OvGcTsdVVjzc916pbLlrqsT41kSKmwuqx2evCHQCEehcES8hZgaUnmmx2Us16q8zoBu59tofMMG/7PEqB2eCm1KIHrXB+qIWRXZNerYLlDrZFg4SU9Yg6gu4afrCwwBxKr5UMIcedZFYpgQvF6sVMqn9mtI36yMBVNBOi+uA1TocDDHiarBl2OEaubfgE5Nn+Sa5fA2LV/Fqtwi3bN2wYOJW7bxxeix2hkHAqT5PXMQ98+jXyO8c/tt/ATJQMK9nrXC3B46Ko6tWI+T1iYYcI8qPYrELfxTX/VawEKO3z0yjCuTB/db+cRIsIjweTDMkJsKB1xlgxsAnGxXEm0HV7A1A/MBjBGdHqS1J8ZXuUMt+sv+vYni3myEFR5P5IoxHGzgnikPu0FgkEy8yktSTwEM/KMLCULZQal0uHXmbyyTCHvx/+0vxGKH3zLknhX209vLn7RDQSJy5K2K5/rW1Jb1A2NA oYi9DEFJ R87rDdepAKn7K/fZXhh2eQ/vcmtpiDRh8xsA4sdmZ/xT93lgCpyLY1FaaaR2YurufQ/BJ61sFdlbwU6RbzFxEjPcvaySM7rf1iQIM+nNZmN3b0rwP2roJzeJjBqiewjmSydL9aSuNxaVbhpud0X0k3JL2ik19D5IZpL6acFlFnPQl+5wyWh0Nz3/60AQUNucyLLORrTVZM5k4O4wJxm4oFc50QyQk2I05IaYl6kQ4gNHpjkCaGnsMJlGN8eDS6+QnT756mM81ijMaMeFyvpRox9fP983eR2RANxHe2F3TREVmCDSEyTZG31Kf66HxaJ8/08l6VrtUGtB5HrkORndM+ionWYbSO760CEIJR2OdLNHpPas9fot4J72FiP3hRz3BsAFEIIV80TUfwfY= 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: Make vfs_splice_read() return immediately if the length is 0. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Jens Axboe cc: Al Viro cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/splice.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index d815a69f6589..fe3309ffeb26 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -891,6 +891,8 @@ long vfs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!(in->f_mode & FMODE_READ))) return -EBADF; + if (!len) + return 0; /* Don't try to read more the pipe has space for. */ p_space = pipe->max_usage - pipe_occupancy(pipe->head, pipe->tail); From patchwork Mon May 22 13:49:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250587 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 4D18FC77B73 for ; Mon, 22 May 2023 13:51:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7F5F280005; Mon, 22 May 2023 09:51:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2F18280002; Mon, 22 May 2023 09:51:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF753280005; Mon, 22 May 2023 09:51:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B25D3280002 for ; Mon, 22 May 2023 09:51:02 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7E51840313 for ; Mon, 22 May 2023 13:51:02 +0000 (UTC) X-FDA: 80818027164.21.1B2D35C 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 A235980015 for ; Mon, 22 May 2023 13:51:00 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JFoE160n; 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=1684763460; 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=NlJ+5nt1dbN0CXPyG6Okiwr3pDsREkSTcJAeP67H8Fs=; b=GNdwE7RYIk1hkGQ3makuvxH91vuelOBrcQdpz9irItTbqKymjT3oRAbOJNidtO0JfttHy7 VGdiwcTWWR5QgcWRsvNwBgFFQndU3w1lHeSnxgZMYXlpjcUWUcHhHO0an955Oz0u12RgiI OgJ8FzFkr89iW0DK+lAdJWPA3hqlskw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763460; a=rsa-sha256; cv=none; b=JFAf5xs9LzdweUkgLu0Kt2hL+e4sr5NTEimt1xmbuOVJngWv8ylc09T5z+sVZokAlmt+vS vgHs4htYhbswEm6IVTv2WJKAD1yAt08fSgjcx/jZZplE4Jzg7P23gbXRciG+/E4NVNb/ro RPd0HSoWuyIXpRpPg/0076NnGQ/b2TQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JFoE160n; 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=1684763460; 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=NlJ+5nt1dbN0CXPyG6Okiwr3pDsREkSTcJAeP67H8Fs=; b=JFoE160nuha9gtZkkvLiBf5ASfxOHJ3aQoLexBSrvUj1kgDEizbaD3OvQK50waagVvJk0/ sVLrSLKilYWg2XazPcuCX8/6PmC+KUJycKFhr+IGtaFWkIK3RLYhyRLxhE3Htu80jtkuwl M5QJtVZhKAQHWZRhSFsdgDS+qc5tAXw= 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-443-RuncnEKyNrCpayNrIultIA-1; Mon, 22 May 2023 09:50:52 -0400 X-MC-Unique: RuncnEKyNrCpayNrIultIA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E38F1C01702; Mon, 22 May 2023 13:50:51 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7E3F40C6CD8; Mon, 22 May 2023 13:50:48 +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 Subject: [PATCH v22 07/31] splice: Make splice from an O_DIRECT fd use copy_splice_read() Date: Mon, 22 May 2023 14:49:54 +0100 Message-Id: <20230522135018.2742245-8-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.2 X-Rspamd-Queue-Id: A235980015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: pbhtrspwi1hrr5zzof3itqrmqhr4pq1m X-HE-Tag: 1684763460-583980 X-HE-Meta: U2FsdGVkX1+8B6HyXgLAFBOdU9iquKrHu6ipKwxNPt8KriqI4nttvuNltdr1EE34wpm1G08wr9/HHDfY7BAb8DGNZ8sj3uoi1JrVvK6cOsu8nDBqe/PwdqvPL4KMsgOP6CI27r5mgQQ4FEPbrsyHa2qLs8OfNvvI6S4nHliK9joczciauVSSFmCxy7DIJoGqrgYPoZnjRtvZuGiKtRgaXRA2/yR0XSWpOG7tvdBd1n4eQscDemTO0tLSRVMs1A3Tvmbe/hkKPOm6hbq5MP46HTADd9xapzFDEK8y3s/M4nbooa/hKTZIaA+ULuHhZuudcr+iGKeoc3vK/hq0ctlLzbFUgFzR1LA4T6JR2eFsCToyrBu+gljcp1ibifGoy+hlOJlO0qWFO8dMhwOBCL45NjBNBbRprtHDJVZdolkXa99k5ZhkKAmTd+WIKvzhkGvd0JOXr9qTH375xU0aBZSL/t0kGvtOiAVapLm7csqMma+v2iD/83x1uqRhBHX/v6zyui38vHcTonpuQoeSfEy24N7S69cFlGZq/CsIrix09Kr0tZUxtoi59oJrfUizi4VitdK0uoxsxqIFQcMyYDZ4+nxuYadbKFBYTwWOrcMDzTzfu3cqaAgvUO9gRxHErlJO7WDouRtDioOZwPlSVMY+RzL3RNCgSj8buViBACy3COUZByV42sGYShWyl/MSdJf0aUxn/X/RG6AKBBU5FbisHK7rh70ls4hlvSXwfiejvB9WIsSIACeGYlU4yAyTBVhOBCxckDvnJKFv7RMmRBtBgEBRxkix2LU0SHFdWYJMjE3mIqLuzi6425+EWWVGeVmtY5Sd1LEWo+cCrxY387PB/TwRC71Fib1MriclKaJN4iUJEG5SVL5zNoYQGs8O3GYx0XWYSwYudyjw5z5cUxYzqZ5xsdnKwuxBkPZbet++2YZj24AqYgx4a4Jt1S2ZIhBY1uY/cY1KPeKwyxic+UE grXc3dHk llN/2GaHFJthxUpn5Rj0emjbRd8MG59F5tVkDb0kwQEbku5jBXZ67RNu/DP15gBfEsaddpkeQ/buJv6ZjBpBTCfIW8fIZYCsJ0C5yA9hoWlQZVh9pQULIr1fBBPw+DEhLcMJdS6M5dk8h5eh4G77k/WJZsGrJY8bux48B0n1EBHWEspYcolhhCWDQ3ESmakinLGx10VWOUJngePU3+maBc6G2xa5NNeReOXDEVKRCiQuQfifVZWp8bmKFzmyzAe+VYf8Mr3UTvCZDcVZHPri5sqBSRjd+klkQZeIwkL0oeVd82eRJ9Uo3wbA+G61lODMvABSZCNTX3fnBRHN47dZOHcetTJKCNTE+3s8j64e9KsemGaifp3MEiR7+tW62k+4jTFoAUG+A6qxwUPk= 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: Make a read splice from a file descriptor that's open O_DIRECT use copy_splice_read() to do the reading as filemap_splice_read() is unlikely to find any pagecache to splice. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Al Viro cc: Jens Axboe cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #21) - Needs to be in vfs_splice_read(), not generic_file_splice_read(). fs/splice.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index fe3309ffeb26..76126b1aafcb 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -907,6 +907,12 @@ long vfs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!in->f_op->splice_read)) return warn_unsupported(in, "read"); + /* + * O_DIRECT doesn't deal with the pagecache, so we allocate a buffer, + * copy into it and splice that into the pipe. + */ + if ((in->f_flags & O_DIRECT)) + return copy_splice_read(in, ppos, pipe, len, flags); return in->f_op->splice_read(in, ppos, pipe, len, flags); } EXPORT_SYMBOL_GPL(vfs_splice_read); From patchwork Mon May 22 13:49:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250588 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 5FBDAC77B73 for ; Mon, 22 May 2023 13:51:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDFE0280006; Mon, 22 May 2023 09:51:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8EB7280002; Mon, 22 May 2023 09:51:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D07B6280006; Mon, 22 May 2023 09:51:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C1EB3280002 for ; Mon, 22 May 2023 09:51:05 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A1F3C1A01E1 for ; Mon, 22 May 2023 13:51:05 +0000 (UTC) X-FDA: 80818027290.28.151D32F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id C284B140005 for ; Mon, 22 May 2023 13:51:02 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FBduurpm; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684763462; 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=9C/VFkhLRxHq1Y6ot9RmxNuYhTHdz11f1qiRk1qH2g0=; b=L01fa1bvWQA+yzaYYYuzOmByupVDVc9fg+uj9432zzrno69OMNWpJwRoAk4GF78uKLjIY/ gP0DCIEsOCXcfe8tcBVFULfeNri95GrrS7LvINU/CKE8uBJ3JrP1Dveyd61KjL4C8MLtA9 bDfVI/Fk52yXJrXKh/tlGL/GOBtUZvg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FBduurpm; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763462; a=rsa-sha256; cv=none; b=ZLmq6oLzrP3lIcjpipibk1NpDDqXYXROkK42lNOXMzdsZiJ9M1tTnIA7GEx15TNUBsu5wq Lqj9rxO4WYxXY1cm3w6OTXfmpr+bVjahcQ5Jur+QWN42f2R4N/fxAqYMtFdNocXBzU3hSF +ElmoTHgDUnfhCxSIlh01sCBZQvDBFU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763462; 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=9C/VFkhLRxHq1Y6ot9RmxNuYhTHdz11f1qiRk1qH2g0=; b=FBduurpmvEvzjEo9cCdSOWcxsg5Zz75aTinPNK86OehzivEtmg4w5HZYJJmhEuTD5BWbSI w/AlAKZY2/2+tmXxP3LWdchEJUlgHvLv0cFqONnn0vYDT4r4cLXgJfG/ZWM0y22s6sw6gK K5epBUiWFvoRjg22V6Nfe0BQzN3+dIE= 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-628-yJ4lna96OoqIQQett0IxRw-1; Mon, 22 May 2023 09:50:58 -0400 X-MC-Unique: yJ4lna96OoqIQQett0IxRw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA9502812946; Mon, 22 May 2023 13:50:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C7CF20296C6; Mon, 22 May 2023 13:50:52 +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 , Theodore Ts'o , Gao Xiang , linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v22 08/31] splice: Make splice from a DAX file use copy_splice_read() Date: Mon, 22 May 2023 14:49:55 +0100 Message-Id: <20230522135018.2742245-9-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.4 X-Rspamd-Queue-Id: C284B140005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5ymszeoik53titmeer8crot5zjyecu5y X-HE-Tag: 1684763462-345178 X-HE-Meta: U2FsdGVkX1/0h8C3n9rTeJRDwIb9Lt6KC+T2IuDz2vqcAtU8PAcxOZGptn+F+JMZqB+53TNy+0VpUsuM8pc0mEWotrRbmQIYma5d+p6LKwl2LHx6jjMlOw2odSj4ebTfrvdJ5mvckjqCOs6FrPbuLpW3768dFMxOulsEocBGQuPsYvNKoVQW+3NnW5eyt+ou3wuvVXV1E3A2je3aGolFGtoHi4mJdWqXHfYrfLbSB+W5Sr8dUisnCJeuhIvQe++2gkYxgFtXNK9ALsEuyf0X7TlLvGUZbXy9KnaVIr9vJ01hja0bD01NGk0o4XsCPbetRWi6JYJyYY7iqIK9s/kVKe0MGoULWwEk2Gb2L2fmOXMwDGn7AjfVG9J+tbeZ8wXEJ498TMpcnXuaC+ae7DD6/Fv1TTtmLaqBClEoFBkOCdRFGbJvNdis+ScoOWUZV+DSFrSN6JyGyjnfbz5lKtCVGWb0LqZAaLXHl7puyHvq9fIIDgl0wnX6OQ/cSdsi4cfifzsj0FgYqhiJciSg6Xlh8TvN/izvzwKVui90guX/Rz0oA9/drL+WjNFvAUBd0JscFzsD5jjCi/p5Bvw2SQUzscOF2vc3+Fj7ij/XPVS3hKco7KJiu5zJmu94mUgjbFmMN2YEJ3dEMP93opgw22Yhbr6rbERiuKHthpdeJOaP357qOSu8QEZk77CIDLCsrIPaDN2kyGvzGfg9AXSFebV49LiE6oCXWUHSh20ryioU+qWB76KqD+Ydxty2YbBLTFLgsEMXXhuuBWkHGv7Jo3Y6Us0jpw4Q5hGM0t08OMcAmn4dk4pIxtTWTTg3MvYjKnmdIMm6GNOy3HyU56w3UYSkuctSOYm2qwDQKOmBpB7DYv2FQDnT+ROHoKh56yH5tmMS98A9Bc578kPHbGjcjBXBuWrnCt24+ordqeGI4XeASOlTGb/fJ2a3ANnif39CUctjF+i2qvAzg0eWQstfhtQ JO2bGUnW KnjOAXSBdVGw2UZi/oMgZgzQ3l1VKC3xVUCaelPonUS58JlRjpGAuNnSMgDWn2DO3zU44Bg2Uk2A6NVkItOre2yllHyEBYzwx44VKRgUCpakMDCg7k5TcZtA2X3EN6yRi0y6APgkznGbb+W2ju/kVoYaBpPCTRHJ2097KJCNOqtuZhOIEaO37tYnZ97skPcKXbdgn7ksBBwhjvL/hDVW4ZpxyfUwKIbbJVS6KjVL/nQvbe/qs63pHlhNEcDS8B6ylBUtUkWjPncYdealBGkStJm2JHT8j56KOYhh9KTJU2IZCAISOUECO15hYfhEGuXcyrqucShrKQxyRUzAa8alz06p+mh+TeG3SryuhtbN+NZiBx1Vlabtl37RldvrtENTGbDKlh0QJOxQVzdG1do/J5RUmknejBkPPmPQj+Z0sr8/1z6hlyoFMVgNpEKzkL06m3DMN/6dnf9HrTiy2BO+Q96oynK1CH7RMxHaQ 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: Make a read splice from a DAX file go directly to copy_splice_read() to do the reading as filemap_splice_read() is unlikely to find any pagecache to splice. I think this affects only erofs, Ext2, Ext4, fuse and XFS. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner Reviewed-by: Theodore Ts'o Reviewed-by: Gao Xiang cc: Al Viro cc: Jens Axboe cc: linux-erofs@lists.ozlabs.org cc: linux-ext4@vger.kernel.org cc: linux-xfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #21) - Don't need #ifdef CONFIG_FS_DAX as IS_DAX() is false if !CONFIG_FS_DAX. - Needs to be in vfs_splice_read(), not generic_file_splice_read(). fs/splice.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 76126b1aafcb..8268248df3a9 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -908,10 +908,10 @@ long vfs_splice_read(struct file *in, loff_t *ppos, if (unlikely(!in->f_op->splice_read)) return warn_unsupported(in, "read"); /* - * O_DIRECT doesn't deal with the pagecache, so we allocate a buffer, - * copy into it and splice that into the pipe. + * O_DIRECT and DAX don't deal with the pagecache, so we allocate a + * buffer, copy into it and splice that into the pipe. */ - if ((in->f_flags & O_DIRECT)) + if ((in->f_flags & O_DIRECT) || IS_DAX(in->f_mapping->host)) return copy_splice_read(in, ppos, pipe, len, flags); return in->f_op->splice_read(in, ppos, pipe, len, flags); } From patchwork Mon May 22 13:49:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250589 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 400E3C77B75 for ; Mon, 22 May 2023 13:51:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D30F5280007; Mon, 22 May 2023 09:51:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE12A280002; Mon, 22 May 2023 09:51:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8228280007; Mon, 22 May 2023 09:51:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A54CD280002 for ; Mon, 22 May 2023 09:51:09 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 75B23120352 for ; Mon, 22 May 2023 13:51:09 +0000 (UTC) X-FDA: 80818027458.03.E004EAB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id A90BFC0014 for ; Mon, 22 May 2023 13:51:07 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HkZxiYwJ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1684763467; 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=KUqjynheJXCaLvUnn68NO8vUOrcgRITgr951Lzay0lM=; b=55E4/h8TEmnwpwvlOVAlsaKiJxzOX4bYW85mleARAvtQ49YGxAex/fC6uunlw0T6vHnTYB LXk2qjqbZNtC6jxcMN2yl42JjpbeDOeZ4mnvapIJahai9OZW+429DAb9vr9Bymv2ONsbUj Wrp6HYXf4Nj1f1tputfyxzXehwcT7gM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HkZxiYwJ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1684763467; a=rsa-sha256; cv=none; b=riKrfWNasoQ6wlLvtcelsd0BPvRf1fy7Nc5EjdeCFKUrEpto1SWK2eoxJTRG20nTTrq0Vm 2jp+/DMf52xLqro8uJ1F4NkPuf0ou2GQkspTaTBkKe40pdTB38IZrjdevfPQdqeabUnamw pXul7QbhhrZ6TLHnITi1OI+9WKembJw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763467; 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=KUqjynheJXCaLvUnn68NO8vUOrcgRITgr951Lzay0lM=; b=HkZxiYwJHLcsyhSZIpbo6FL/ls1EuRfjyVYf0HgxZ3gCiZeVr3s/rlCkGUP3901WrbJCVJ nDIlqVE5AIzYaT2/rB5tc44kefiGVAwe4HSdLaqMxgj/mcBLokZlx+JMeUV7Cnn+TxWlSO bA1S7u51kU/8i4iMVGM65Gce0mrCZzM= 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-531-212hUAElPzmC_VRu-aa_BA-1; Mon, 22 May 2023 09:51:03 -0400 X-MC-Unique: 212hUAElPzmC_VRu-aa_BA-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 49961185A795; Mon, 22 May 2023 13:51:01 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8774C140E95D; Mon, 22 May 2023 13:50:57 +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, Daniel Golle , Guenter Roeck , Christoph Hellwig , John Hubbard , Hugh Dickins Subject: [PATCH v22 09/31] shmem: Implement splice-read Date: Mon, 22 May 2023 14:49:56 +0100 Message-Id: <20230522135018.2742245-10-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.7 X-Rspam-User: X-Stat-Signature: oo7x7oraw7xh9jn9ac5q5quj88q5b8a8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A90BFC0014 X-HE-Tag: 1684763467-943968 X-HE-Meta: U2FsdGVkX1/+3+nHi48FuLEtTBnsEbSv3nQQcu26Vrxg+J/bE+L5Ga5UxcaFt3RNn5UvLY/nprvofIdTWWX5JyuUX7xli4Hz5Foiau2YGGP7/WhIa3AgprHhmQFx0tkGuh5gfj+i45PRqgIHkvGT8wm4l6DAnqPUL96aNtZd+Tv3X+mAv1E/EEfh7/BtDd+Ynzb8q9JKyQhxlUuSMIvTA8RX2ctz8jJU3yBNCy9gg896LxKb1jgiSG2xGw8JBbfJZNSVECdOnvju+e/NEKv3kKjfT3eQCqW1pI/IyM0ZaK84nkN324PKED6SYbNbQ+Pmx1BIXD4HZBPaNMeYBNvp4APdZZYIYfbWGU4dSUPCk1wE8/wQpk7afp4rVP43qvQsJyVAplvQLorXUL3MIZWrGCVDZ+dsGyR/3zH/LA03ALMTVQG79WZhg8XkLDsqpui93PUpEDpiJ05Iqx+D0ogRg9qQFuyMuKVlZYvYO+RbhK2pTI1gV5Qo3NN1dmFU/LBRMYQNjCjjE3l45H6kSX2nfi8Ea9iupsy+b0C+H4BXCZy3VogCRaUaGBbFRigkscLpXmtTGZYSBkZrGB3VAxiMEaJdNUZj2iarlXgY1gF5KbCiLph+IEsrt7cnglgNfXlSpOW7gjwLr6qrv/XyPonov2mKqjkmAzN8ahjLgb8AE5bK/tKyPJ0iriDJCc9JetshySRMfSwXWufYb53OKXfWswu6fS30x9uuFuXTqmzZDwyd2TkgMZ5AbxSVXe2aq1LGkNAu9Xca81Anaax3f5wdS+J3mNik4Hm+i/YYqqIOAJftu7KYSGgMz2BFGZG1vXEWGmCbQZiptfKNus+a5OfvMKwF3rSnoSsdq7YVbMo8CKX6n3IJ5LIMiSivPBF9dgfZCSQVKv+lpSBbBADPiBf4SrTP/8aXO11+lzsEaCvoNCNgRtMXgyqpo6IpzreQvuEncerKKVGv/NyeF4aP3p7 7Pb+lznW aoWY8ldT42amtazwIodBL8G/kuqM4jTqaptCHJtssDJwHKnZN5r+WJ8qv49MUfb00xBGYFKFlWQTfTO+p8SvjQ230PY34hYQsz4mAd1FJeJJnacqVI/HZNBY94mdeXPfQwKIrqGPrZDRLjC108ny6k4iG6oM1aWTcYc7MHX58T5ki6nxjlQHhYj6YPQnYCUHa+4TPbUv7YtwY/DBFbOa3gxFJXmrlJAdL9hHZXYHaQh3M6PpbI6nhEIWCHSFw/MxITmkh+3doq5FlE18+qTAwB03niWzKq0Cz76VmwiRglJHRalaeU0MaKz9eN3wrd8s2Ty5m4mVu4wyGCFDNDmNr3Z9on2dWH4vt2dQs4z5xC1paDH9JvRnxNAGc29ZTWiU1rrxhQk9aW/+aS+IeNSBoBdTbMql2w0lXvnTa87XYD6sxNzjFcualKoyzmkXMydfZCeiZlY7GDkyl/zhyBYUzZaDzbQKoeo6ioZM/cbkzQKEH+WLkAt3bNoj5c4CbAPiS6UrPSMBJnGYro/Q0MdT1nCSAUGzNNngAf33R 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: The new filemap_splice_read() has an implicit expectation via filemap_get_pages() that ->read_folio() exists if ->readahead() doesn't fully populate the pagecache of the file it is reading from[1], potentially leading to a jump to NULL if this doesn't exist. shmem, however, (and by extension, tmpfs, ramfs and rootfs), doesn't have ->read_folio(), Work around this by equipping shmem with its own splice-read implementation, based on filemap_splice_read(), but able to paste in zero_page when there's a page missing. Signed-off-by: David Howells cc: Daniel Golle cc: Guenter Roeck cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: Hugh Dickins cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org Link: https://lore.kernel.org/r/Y+pdHFFTk1TTEBsO@makrotopia.org/ [1] --- Notes: ver #19) - Remove a missed get_page() on the zero page. ver #18) - Don't take/release a ref on the zero page. mm/shmem.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index e40a08c5c6d7..1f504ed982cf 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2731,6 +2731,138 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return retval ? retval : error; } +static bool zero_pipe_buf_get(struct pipe_inode_info *pipe, + struct pipe_buffer *buf) +{ + return true; +} + +static void zero_pipe_buf_release(struct pipe_inode_info *pipe, + struct pipe_buffer *buf) +{ +} + +static bool zero_pipe_buf_try_steal(struct pipe_inode_info *pipe, + struct pipe_buffer *buf) +{ + return false; +} + +static const struct pipe_buf_operations zero_pipe_buf_ops = { + .release = zero_pipe_buf_release, + .try_steal = zero_pipe_buf_try_steal, + .get = zero_pipe_buf_get, +}; + +static size_t splice_zeropage_into_pipe(struct pipe_inode_info *pipe, + loff_t fpos, size_t size) +{ + size_t offset = fpos & ~PAGE_MASK; + + size = min_t(size_t, size, PAGE_SIZE - offset); + + if (!pipe_full(pipe->head, pipe->tail, pipe->max_usage)) { + struct pipe_buffer *buf = pipe_head_buf(pipe); + + *buf = (struct pipe_buffer) { + .ops = &zero_pipe_buf_ops, + .page = ZERO_PAGE(0), + .offset = offset, + .len = size, + }; + pipe->head++; + } + + return size; +} + +static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + struct address_space *mapping = inode->i_mapping; + struct folio *folio = NULL; + size_t total_spliced = 0, used, npages, n, part; + loff_t isize; + int error = 0; + + /* Work out how much data we can actually add into the pipe */ + used = pipe_occupancy(pipe->head, pipe->tail); + npages = max_t(ssize_t, pipe->max_usage - used, 0); + len = min_t(size_t, len, npages * PAGE_SIZE); + + do { + if (*ppos >= i_size_read(inode)) + break; + + error = shmem_get_folio(inode, *ppos / PAGE_SIZE, &folio, SGP_READ); + if (error) { + if (error == -EINVAL) + error = 0; + break; + } + if (folio) { + folio_unlock(folio); + + if (folio_test_hwpoison(folio)) { + error = -EIO; + break; + } + } + + /* + * i_size must be checked after we know the pages are Uptodate. + * + * Checking i_size after the check allows us to calculate + * the correct value for "nr", which means the zero-filled + * part of the page is not copied back to userspace (unless + * another truncate extends the file - this is desired though). + */ + isize = i_size_read(inode); + if (unlikely(*ppos >= isize)) + break; + part = min_t(loff_t, isize - *ppos, len); + + if (folio) { + /* + * If users can be writing to this page using arbitrary + * virtual addresses, take care about potential aliasing + * before reading the page on the kernel side. + */ + if (mapping_writably_mapped(mapping)) + flush_dcache_folio(folio); + folio_mark_accessed(folio); + /* + * Ok, we have the page, and it's up-to-date, so we can + * now splice it into the pipe. + */ + n = splice_folio_into_pipe(pipe, folio, *ppos, part); + folio_put(folio); + folio = NULL; + } else { + n = splice_zeropage_into_pipe(pipe, *ppos, len); + } + + if (!n) + break; + len -= n; + total_spliced += n; + *ppos += n; + in->f_ra.prev_pos = *ppos; + if (pipe_full(pipe->head, pipe->tail, pipe->max_usage)) + break; + + cond_resched(); + } while (len); + + if (folio) + folio_put(folio); + + file_accessed(in); + return total_spliced ? total_spliced : error; +} + static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence) { struct address_space *mapping = file->f_mapping; @@ -3971,7 +4103,7 @@ static const struct file_operations shmem_file_operations = { .read_iter = shmem_file_read_iter, .write_iter = generic_file_write_iter, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = shmem_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = shmem_fallocate, #endif From patchwork Mon May 22 13:49:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250590 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 DAF96C77B73 for ; Mon, 22 May 2023 13:51:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 764FC280008; Mon, 22 May 2023 09:51:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 714E6280002; Mon, 22 May 2023 09:51:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B609280008; Mon, 22 May 2023 09:51:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4E5DB280002 for ; Mon, 22 May 2023 09:51:12 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E4D3E402E4 for ; Mon, 22 May 2023 13:51:11 +0000 (UTC) X-FDA: 80818027542.13.96BB5D3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 02929140017 for ; Mon, 22 May 2023 13:51:09 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZmwXM83o; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684763470; 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=qKMmGOYRCa7hSrkLF/RgczhPclegMdhS5TKhbjFywHM=; b=jANZ6/giH/H3N7ho/pR+zvX415u0cGrUPzdqUzk0jkgj5GXLxmvA7OV+/NRRGVL8A3IXKT YQWuh0GD1bsJNwXYfihhEogB237vIbRScb86PRRxXsL+5053QP2uTZPHPrqXWbWoPiWhx7 BhR/OF0dJeFhVCmhJ/q/2zv9TttDzgI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZmwXM83o; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763470; a=rsa-sha256; cv=none; b=DwNogf2iSMEwWbkcsPp+DNFwN8nHHYkj534HcB+mQ1wY7VUir0Sy7aaSEe4878N4P1wTgm 1TQECSAgUAgnwEYWSF5jbPhvAwFIGWAgUYo7SLMBb8CNeIbUz3d9untk1Nf2eAoHF2I84v vLjCErE8fnhF9rMwiJitG4UjtY70Cxo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763469; 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=qKMmGOYRCa7hSrkLF/RgczhPclegMdhS5TKhbjFywHM=; b=ZmwXM83o18fbv+Cl8bq9P44ri/bGoLoK1L8LwrilgB3tEbwgIwhtcUiAThIQBHodow+AN4 Uj6885YCYIFVJysQcR2pQWIwDXdRurbKc8pv+sfqQfOOUxeQJzY+PzB189xGrfKKuqdown kfMBeULMxyS28jQijryP/OmDU2jRCME= 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-526-8G5_LAk8MpyrjZMsu_4Waw-1; Mon, 22 May 2023 09:51:06 -0400 X-MC-Unique: 8G5_LAk8MpyrjZMsu_4Waw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 036831C0170D; Mon, 22 May 2023 13:51:05 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A30C40C1438; Mon, 22 May 2023 13:51:01 +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 , John Hubbard , Miklos Szeredi , Amir Goldstein , linux-unionfs@vger.kernel.org Subject: [PATCH v22 10/31] overlayfs: Implement splice-read Date: Mon, 22 May 2023 14:49:57 +0100 Message-Id: <20230522135018.2742245-11-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.2 X-Rspamd-Queue-Id: 02929140017 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: qhc343xhynqf66oszkrcaj97anm4hej5 X-HE-Tag: 1684763469-398281 X-HE-Meta: U2FsdGVkX18mbzkVC3DnNaDPy4xYtjfGKEOQd9BO73d0Z0/Tx37PPT+siYIvvQQAjeACtRJ6JTFfjOfR7gpJl2GBDFqk07JAqFUqcFk7jfL9sjbFAYVhU7QcRX9fnVZvAmfHNxiHfoLWsJAd4M1bThCBQEOwuXHq+jKrynLwIDOljs3et56my3A+zlrsSxPot2OPu2Eipn81NcO3wkBnXiLt/97Ce342Xk7V2PrTuEfJm8pevn0/aZbP6C2TnmVXHAo4PqFZWo5Vbh2WMuYjS73TRiXuvV7Uls6mdV/o6zZqcBCdpVHEBmKfema9rawJcqnqMuBJG/QHbhUeji/HWAsGgwzykJMyxPf/25Cjz8UMM9h7PoA2GVmywZ/DvwkTYJEy0wFS8eOg/rL7Ndhek+0s3h/47qVNMU2WKJiq3k+QjsZp17QZohq/EqLOVe9EEGYRU0Sr0hPM37XcR2Tf0dLOFbcEv6CPhSS9//wfKb2xj/EPcOsGf8tpljxOG7sISeyiyxEfnHVbymsSWhs99FZGPXuSaqIMObrgq2jD0qs/belIDUm36nAgMWhGG3wTBJAqAMLyhw5Y6HpsbJbqS4oDVR3fAm5WrRcgBCkVuq8be0wtSb2zuUvK0ubhSybr9C5doE+jXesxPePdpL6+qZ1RVdSFpU3I6AZJ/l9kVZugDU0Tt62NCz191kGsZC45ghLl4w36pILNAKs2nUHkNFK8FD4CeFpRp2lmAu0QVdg5lfBmhRdU8OVs6/F2z50mINi80vXZvsPeVRV/mneWkeASLBcMIeEO5IUEhTYVN36KVDEVTEOscePcJP/8o4196qAkU6goQrdYlEn4R+V1wr7Al+5CUdw5LAIkh7n+CMmHYlEr1iqMwW7LQZXLxXBLiUllZdb189qcwyLZZFv6usY7IzuoDr2ibFwbkyLu01OQ5GgQO5vfetiiUbi7UOiDG2WeX6F5odnDycvErgk 2GMpAZHI 3Rc1lQ/Ul4NjMrP+oQiWaEuEPBAGdicTSxvnxSzupEysydxTEE3gz6TO3OigX6ag4mDpiqUFm9KQ4SV5Wz3hoNamFFDR12S+reNQDtqxTHWQO6Dur6n7IjT2Kuvqaq4w5LgBPApVZIMKlBhREeShUIhopC8uXCRzcePTAJ0ig258pzwIC75uUz49G/zDOdlhb9Nk+nXGFMA+PM05UcPhfc72t3hdSovan1qLIsjOo39f4Q+oTY8ZYO5r1JfZMAXH8+DiVJ/sgdIa6bNo+yvJOzKZYfrlT/RsFV2f7mN39Z+Am+vF5HyUOpRnwBOmGGFQxRtnOhbDMAC3u99ZOzUSfGyw0trIP3gYllWgFO0Kv/Uq3BnBUzY+b7VcrGuyQ616br8SiYXAWC6WLr5UlH+R6cNlUPDcx9rHYBvqFVOvmshbeavWH/l4OIzYNFxzWmonkxi3gzV9CdlrqYLY= 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 overlayfs 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: Christian Brauner cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: Miklos Szeredi cc: Amir Goldstein 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. ver #15) - Remove redundant FMODE_CAN_ODIRECT check on real file. - Do rw_verify_area() on the real file, not the overlay file. - Fix a file leak. fs/overlayfs/file.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 7c04f033aadd..86197882ff35 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -419,6 +419,27 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) return ret; } +static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, size_t len, + unsigned int flags) +{ + const struct cred *old_cred; + struct fd real; + ssize_t ret; + + ret = ovl_real_fdget(in, &real); + if (ret) + return ret; + + old_cred = ovl_override_creds(file_inode(in)->i_sb); + ret = vfs_splice_read(real.file, ppos, pipe, len, flags); + revert_creds(old_cred); + ovl_file_accessed(in); + + fdput(real); + return ret; +} + /* * Calling iter_file_splice_write() directly from overlay's f_op may deadlock * due to lock order inversion between pipe->mutex in iter_file_splice_write() @@ -695,7 +716,7 @@ const struct file_operations ovl_file_operations = { .fallocate = ovl_fallocate, .fadvise = ovl_fadvise, .flush = ovl_flush, - .splice_read = generic_file_splice_read, + .splice_read = ovl_splice_read, .splice_write = ovl_splice_write, .copy_file_range = ovl_copy_file_range, From patchwork Mon May 22 13:49:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250591 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 89BBCC77B75 for ; Mon, 22 May 2023 13:51:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF3E2900006; Mon, 22 May 2023 09:51:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA442900003; Mon, 22 May 2023 09:51:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6C40900006; Mon, 22 May 2023 09:51:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B84AA900003 for ; Mon, 22 May 2023 09:51:20 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8EAE9402E4 for ; Mon, 22 May 2023 13:51:20 +0000 (UTC) X-FDA: 80818027920.26.FA28115 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id AF045140012 for ; Mon, 22 May 2023 13:51:18 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AcDOrehg; spf=pass (imf23.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=1684763478; 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=6cNXasheo1DF46I8TVOzmcRUgJUblvwT7UioRDV99LqTXmsDzc/mQ8gYYpxMW2KGQp27Rk UIcSgu4AkgpZPGXjAqbf5oDbjWdRqNcDPG8cU0EWqd/MxxepJTRw+/2B3QCxNhvc4jYiFM QxOUTB/ksmna9jeljRVPugc4Emj8LQE= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AcDOrehg; spf=pass (imf23.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=1684763478; a=rsa-sha256; cv=none; b=kXUjO2jzjIK0Z7ZALuNzxKCIiDusAmtuK3HoggisV/Y9ZCfjy6EaP0m8bfZVckixQYidXL 4+O/PG1dtk+JsXssRj5agOD5oovxY/slTBmkx6jNTHt1k0ePzsegLUA0MWMhDaoooIZXoG Pa3A2/8iH2OUdGv6aoo2DB0RjtO3pGs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763478; 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=AcDOrehgxeuY/GqGNz6QtYRIMn4UBAq5o6X7A9JPd0dvWrDAesY91UlR+rsuDbwBPfSMKv hIs3bKtqbZp3Almjzw+29Vow9F+Gxi4URbljXe2YU6YIzKkW9/ph6KFSkSrTR+ybqTzaG2 1DBBo8/JiUfuhEqTfBi4hPXp09GMk6c= 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-658-FSbafaL7MteAr1zv4BBI7w-1; Mon, 22 May 2023 09:51:10 -0400 X-MC-Unique: FSbafaL7MteAr1zv4BBI7w-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 0AA3F3C11C7C; Mon, 22 May 2023 13:51:09 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB6AF40CFD45; Mon, 22 May 2023 13:51:05 +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 v22 11/31] coda: Implement splice-read Date: Mon, 22 May 2023 14:49:58 +0100 Message-Id: <20230522135018.2742245-12-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.1 X-Rspamd-Queue-Id: AF045140012 X-Rspam-User: X-Stat-Signature: eu1rs9ncwqas99fzyz86fr9b7oppgf4g X-Rspamd-Server: rspam01 X-HE-Tag: 1684763478-362944 X-HE-Meta: U2FsdGVkX1+5smDo9s++TMuV5FtkDRKN8LJ47J6sjBuerDv4jjVHq+EAdC+wtandk11rbIWTPnGYqJHBYrn3W4SbP+0e/7r6kNGfH3ZRzv23a8jXnS+UySi+kYHQ6A/qe+NmXdVDEv7eDEr6IlhCl1Vgz7wJH3VW18vlszE9k6he/yLfnvebljBl4KbdzUnlpAQ7ehgpVXTydl0+il55pPQeRBLNsCZOnYqET57ZbRUitolnlh7Gz9rxpSrbdOnvPCxHSzsbO4TDWpmEsZZTW2N1e6EYIOx3ESZMTgf8GMVgUGXzwSvbW6n/XO6SzxKzoOEmRmMSRUGSPqEXY944NzQl1TgwayxkcQNjPZv7FE78SE02bVV0kxP6O/QL+rcuh+zkw06W5fuUI8CqsHJa+6PAH40keMZhh9SLZXO53tHZ/VnNC7abYXgUtyQmc+w+BEOZ6f3l3Yz61+2WNd2tRJUgj2bwYbAJ6Zdjw6wYV50DhIzxVmH/BfxYy8QrWRXUkLhunKeytlAlSIivoWamkHnq19mPEEfsg6w2qCzqd4hPKQCWJVDOyVxd2seNtbXnY2FKQNiGcpSiswE5xKDWRd0RG0SXXmSG+4AbDVr+aOhtWfda1dkv5D3978vRLrbK1DsrFmkIO2nPpFxUuPvQr5jOXPqSJE+wajvjY4T7ZKvl+Y65FUpp7bYx5UJMSkzSAIiXuBfZdWHw+srIx+6r6CyLBAVuFgZ8ZP1uMexOePHwSs56p83U/TP/v8faer7oWKw0wUw8Mc31nDQluznSPTnuEjHMVvys2h1WWPAmOqOvPGloxYahKsU4WJ8UMgAKR9JI6+o4k7RrZSzvMPdBN9H2tOp3iFkffiWe1m66XytUlQem2GMxI+CQWCqbibBa8TQ5iXQ0xMWklNFMBDYpMYPryhczkmNfVDQYymAiFj5e3tfaIUVfnfoGDoyaZ+UHZBFCs8EXR8/bFi+pRTd eSkeuFvA ZDm71EK5kTFkvmeNK+ScTUGSZm/TtSx6EMgUUTpiQBYMSKrkSdg5Fh3t42iVWh4R3XsE57B9UOeuQ53vCRfOVU3FkxtclmAyxqf398C/6u0y/ZSgUlQv7c6qEoZfaGpErHAapOHdds3v2WfMGzTVIRrTCGLX25bk3OZlN7AlsQKpx4Xz97WS+80xTBZ6k7M0SQpHydzFUgQOLHLGpPuvzdI+5ysYtQv/Z1dTlmyJwslYKQqbe9SDNBfH187BmPL2++P7d2rznMZu+i4VOxQLsnpzG9TP1NqBA/nDhb3TiuGPPe48gybc9NPs3E3hFYix6lA9OIYxZ7p3Z0qAeMaxsXPHMT/kbVMbWsWPKctCUgHa1bOKtTDolVCzhzVRO/jfnQ2nr0f43zZCCTwfwr5O/HAe5N78iM7oPIpEliAnORlNHy1GledurnP1OAw== 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, }; From patchwork Mon May 22 13:49:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250592 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 659F4C77B73 for ; Mon, 22 May 2023 13:51:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01364900003; Mon, 22 May 2023 09:51:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E69B0280002; Mon, 22 May 2023 09:51:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE324900007; Mon, 22 May 2023 09:51:21 -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 BF6C1900003 for ; Mon, 22 May 2023 09:51:21 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7FA52C0162 for ; Mon, 22 May 2023 13:51:21 +0000 (UTC) X-FDA: 80818027962.19.AEE490E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id A505E100012 for ; Mon, 22 May 2023 13:51:19 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BgiRCZNl; spf=pass (imf05.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=1684763479; 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=bxp9/2gLZL2I594j4SxMybgCNb+qE9Rj6mhPK/7tAtY=; b=sTWj2ttYVpw3R0a7h9And3uzDD/5+s3D4r5cho4AhrEUlNap3XLJjhQHi/E0JmTJaAsArW lAL08G3WrdxctItIdau0wf5k0oi0C7WSdd0VV/B24WpSReTYktkGsebZS7Uuiz8niTf7zF OS7bO1kZ9L5b3GPjbzxgVLKzzekMMNg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763479; a=rsa-sha256; cv=none; b=pmPWuKx6CvJA2F2rH+EzwkQ2fETOl7Ich82wNjNbsenrN7hvLlSbXrfWIUDAGBDIbgonh0 G+VZ8Gxk3KYg5J3uaLYmHa7e58sgrbAASwVGEatS7GVo5dmGQoOZoPyZ76RFywZ1Avocvq fTauy6/A5iOToHKq8gPHvvlxFitJ6TM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BgiRCZNl; spf=pass (imf05.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=1684763478; 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=bxp9/2gLZL2I594j4SxMybgCNb+qE9Rj6mhPK/7tAtY=; b=BgiRCZNla04Usgd51PGIHJay+mkRYt2aNRtCWwedVQXbo6aM5nrrBQK3cMHBG8HdTATjBF HDm0+44B4ctuZbd0lWdfStXT3cIvxwDFbMeTznnmUoXnmLHyLWarYHIoZSEQy7vnoly5sj svbXzaPf5PC+s2yrBaR9pM9nyOCfaIQ= 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-235-bixELT5tPzuTZyhz1OURlQ-1; Mon, 22 May 2023 09:51:13 -0400 X-MC-Unique: bixELT5tPzuTZyhz1OURlQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1A3B2812942; Mon, 22 May 2023 13:51:12 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5F7D200B415; Mon, 22 May 2023 13:51:09 +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, Greg Kroah-Hartman , Christoph Hellwig , John Hubbard , Miklos Szeredi , Arnd Bergmann Subject: [PATCH v22 12/31] tty, proc, kernfs, random: Use copy_splice_read() Date: Mon, 22 May 2023 14:49:59 +0100 Message-Id: <20230522135018.2742245-13-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.4 X-Rspamd-Queue-Id: A505E100012 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: uxwfn7qbtqopistpd6uxxs7by6ie1ioa X-HE-Tag: 1684763479-930214 X-HE-Meta: U2FsdGVkX1+fgcnzglwKA8LW68wQu0A4K9g6s+NJyhSL8FxPa4Km29N7QwK8Ha9x9UuaeRGDQsA2llDS6BhnFfExeqxIMwWYF1EGl+hAVH9H7I4Nt7IUzPAOj2PeAXlGopStii3hlAZDFE1e9jliDMXOziO0zohxdI2nL6RSBt+19IWYQkHParSzploCwjy/Q7s0yg39gwMgwOtcQb9fOLPXIVBxRCvHu6IeH5oxoPFSzBZlGghUhbplXZwspIkvKx1m1Ji/4wJ8Z9jN+caW+/L8FTrI/janqPTmdKPncokY/NcceYhRCQNJQTmptslB9HfeFnmh9B1ggbDUGwj6vZcHhP9IDBebOGhE/3wMzs+OYrdDSzZzEk+FENvzR44lvjYWiFCAUgvavAcpI1jpK7ioU8e1Xo3NH8mBS/hJnvd4iY4f4onurn+mTWg+yNJWkaawIVFEnVspTjEgYcmMdddPK1CVXaLjfjaQNeEZbmdgSfLv1/HNTeO3LgoXXj6uJJuGQY5GAaXOQbXT8JH4Nc5azG1xpqil8JpgDmmkD2WQgBQjfdGYHWxj0gRwiCONr5PlJGLigCSbecgJXM1J9ECschUWfSXgqoeMfqpefeiaQb8ySxvSnAezUOrhlYGpOVfjq2Jg1QslJ9xcvHMgMdVZekQfUnWU4LBg+VE7FFepYnUltDe1xWhDDeymvJkYX4O2/TlysjW1gHyi3K145b3ex/qfnWyqurFBEGqwoAfXFhDSML515SD/ZreDmEdVfJkSDFAouVZ6Y01HzbEjdV5M4OoJe7dJJVE5yEkWZ7mCgUKgW9T/nYyqCn7oPCV1qdRMTztdtSgIIIPRjv3vnipGQUHBNYQKS5ZXftR5/IXFrg2Fjaam2BwP1Ayymcduw8dAEn2Pg3rA1Im04hs71Qc2ghc19niDzeyccQfoFbP56nbDdTVMLwBBxnwTSC8E0Wmc3DI8dpRb+yADDcb YUxPYmSF /ibRR8VdwPSCp3pI3MkIY1QDzOcXJD00O6gFjYPnrrIJId/qc6bDEpUq39xyTzDmA9J0mMNUKsC1D0mdnZZ+qXpTfGI/E3m3LWD7WPL8UcFuKkm5kpUNGdAFFu+1RHr3MJoVN1K5e1eHIYDO7xHbhs1cnTWz2P7i38AauRS5n+ZkiKrf/nooafGaBZh01JX4Kawm2drxIPp3aEUbznjblQgAfK7tEhqdNJH+WRSb/R5TXbdDDwt8Brb8tE8C+XJZ46ifIRxQepxzQID05HNtjEd6GJuZep/snU1roHaKi/r8aMawFdb3GTPkg9PEQkHGolAsmJ5MYmvpskzzyp5+BI0IcGIqkvVUXhgBq6niTbxe1vuoKZosgD3vJI942HsIXLb+UM937yz2d5JFwDqWa6HGTQ9xnh2JOg7Cpmf/e8v29C16MEn6vobDe1kz/HRgo055RfzfnXJo10Ft2Yeho5OCkyOkA8LpLvj9cCiCbFg9dVKH29EtH5JVGYfhFT8r88r4qZoECXEGiRbcs4+6UuT+5HJ0iBphB/pRr 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: Use copy_splice_read() for tty, procfs, kernfs and random files rather than going through generic_file_splice_read() as they just copy the file into the output buffer and don't splice pages. This avoids the need for them to have a ->read_folio() to satisfy filemap_splice_read(). Signed-off-by: David Howells Acked-by: Greg Kroah-Hartman cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: Miklos Szeredi cc: Arnd Bergmann cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- drivers/char/random.c | 4 ++-- drivers/tty/tty_io.c | 4 ++-- fs/kernfs/file.c | 2 +- fs/proc/inode.c | 4 ++-- fs/proc/proc_sysctl.c | 2 +- fs/proc_namespace.c | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 253f2ddb8913..3cb37760dfec 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1546,7 +1546,7 @@ const struct file_operations random_fops = { .compat_ioctl = compat_ptr_ioctl, .fasync = random_fasync, .llseek = noop_llseek, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, }; @@ -1557,7 +1557,7 @@ const struct file_operations urandom_fops = { .compat_ioctl = compat_ptr_ioctl, .fasync = random_fasync, .llseek = noop_llseek, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index c84be40fb8df..4737a8f92c2e 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -466,7 +466,7 @@ static const struct file_operations tty_fops = { .llseek = no_llseek, .read_iter = tty_read, .write_iter = tty_write, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, @@ -481,7 +481,7 @@ static const struct file_operations console_fops = { .llseek = no_llseek, .read_iter = tty_read, .write_iter = redirected_tty_write, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 40c4661f15b7..180906c36f51 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -1011,7 +1011,7 @@ const struct file_operations kernfs_file_fops = { .release = kernfs_fop_release, .poll = kernfs_fop_poll, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/proc/inode.c b/fs/proc/inode.c index f495fdb39151..67b09a1d9433 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -591,7 +591,7 @@ static const struct file_operations proc_iter_file_ops = { .llseek = proc_reg_llseek, .read_iter = proc_reg_read_iter, .write = proc_reg_write, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .poll = proc_reg_poll, .unlocked_ioctl = proc_reg_unlocked_ioctl, .mmap = proc_reg_mmap, @@ -617,7 +617,7 @@ static const struct file_operations proc_reg_file_ops_compat = { static const struct file_operations proc_iter_file_ops_compat = { .llseek = proc_reg_llseek, .read_iter = proc_reg_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .write = proc_reg_write, .poll = proc_reg_poll, .unlocked_ioctl = proc_reg_unlocked_ioctl, diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8038833ff5b0..ae832e982003 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -868,7 +868,7 @@ static const struct file_operations proc_sys_file_operations = { .poll = proc_sys_poll, .read_iter = proc_sys_read, .write_iter = proc_sys_write, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .llseek = default_llseek, }; diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 846f9455ae22..250eb5bf7b52 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -324,7 +324,7 @@ static int mountstats_open(struct inode *inode, struct file *file) const struct file_operations proc_mounts_operations = { .open = mounts_open, .read_iter = seq_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .llseek = seq_lseek, .release = mounts_release, .poll = mounts_poll, @@ -333,7 +333,7 @@ const struct file_operations proc_mounts_operations = { const struct file_operations proc_mountinfo_operations = { .open = mountinfo_open, .read_iter = seq_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .llseek = seq_lseek, .release = mounts_release, .poll = mounts_poll, @@ -342,7 +342,7 @@ const struct file_operations proc_mountinfo_operations = { const struct file_operations proc_mountstats_operations = { .open = mountstats_open, .read_iter = seq_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .llseek = seq_lseek, .release = mounts_release, }; From patchwork Mon May 22 13:50:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250593 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 4ED2DC7EE2D for ; Mon, 22 May 2023 13:51:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EE70280009; Mon, 22 May 2023 09:51:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89DAF280002; Mon, 22 May 2023 09:51:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 715DC280009; Mon, 22 May 2023 09:51:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 641EC280002 for ; Mon, 22 May 2023 09:51:23 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 31DC44020D for ; Mon, 22 May 2023 13:51:23 +0000 (UTC) X-FDA: 80818028046.05.CE0C1B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 84E1F4001A for ; Mon, 22 May 2023 13:51:21 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Z9iXDITk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.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=1684763481; 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=gRzUovfXnw170GzVg3YWYDNx7Fcy6r2PjCbmCvJAFKQ=; b=xhJQuYhJjVtclquM6MQ6SrF4zMikpvkS+Hq0ft8LX1YxiJVxhxtbOXr+4wWhpMg2Hb1eYW y1/a9N4QhwMQdvtDTan8xUluvBe49iYV0ZYpwmXx8vpTVfFhrOsnsKunE2qI5sIKmf5I3y 3/Xl3n0f512WiFV8wDRPwlEZ6ZpyWxk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Z9iXDITk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.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=1684763481; a=rsa-sha256; cv=none; b=mJGIEQLa8EGj4NIIw4UHGekm47LM8m/HTHD/+5e//VDqBSXq8XoW6ZubgSjAwN87LmEPoH tKUGz0+F17F2ydfomM1OQ8+xmoT/kdFrUrtJUIhnA1y8V65yyFUxLp5naheeqx9TZiOvv1 ViIdVjiUBks2yGfJDSApoyqNma19erA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763480; 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=gRzUovfXnw170GzVg3YWYDNx7Fcy6r2PjCbmCvJAFKQ=; b=Z9iXDITkYU/C1FILxSc+4ZK8hHZQVWo3TkLMYqgVj6HF/25R9wk6kX/pkz1EHvF1YojqQF TqB544kq0tYE/GEiTPJijVJvHJMhuy9HkbJmJeJ2SSQGPe7GuEhBkZgTbD8SeIFE/TYmn8 cfJot1z0znj/YQU+Lplk5KxBuWhmcJI= 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-301-_owDkNb6PgOmvE0Khp3Vtg-1; Mon, 22 May 2023 09:51:17 -0400 X-MC-Unique: _owDkNb6PgOmvE0Khp3Vtg-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 8A99E8007D9; Mon, 22 May 2023 13:51:16 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88FCC40CFD45; Mon, 22 May 2023 13:51:13 +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, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christoph Hellwig , netdev@vger.kernel.org Subject: [PATCH v22 13/31] net: Make sock_splice_read() use copy_splice_read() by default Date: Mon, 22 May 2023 14:50:00 +0100 Message-Id: <20230522135018.2742245-14-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.1 X-Rspam-User: X-Stat-Signature: yaogbjaxoqwdeerrty34t18gk9c8dsum X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 84E1F4001A X-HE-Tag: 1684763481-789751 X-HE-Meta: U2FsdGVkX1+/J/SvifYr9+BnTFEqk/HQWE0XLmUG5qCQmDkS2hhInSf93ZTaJtxKR4exQHVsmVQqRInVorFkV4nFIk5Du/TPRXMgyOCEtG46T7qK8y49I4IKzk5g2o5DLMiUAjZ7Vb3oAvToIz4LA+5hf9CWbpXCWSqk4rwN6+rf5ufdZLS8PyPUlcD6qhMw5qHEK/oDwLwEO3nBUva8+0C6Tnf/iy2aub2efwAQPjUQC8O5shl/d7yT/DHSSxbCQzkZDfGSFXZc6FOKLSn+eiQZVpHFP3O8Zx+uhl1AGxK0fxMPKVdxBk6FVJx05FxMheQaaSEWf6A9mVvMT9D0nT8gwxVEFvEsOV44/HkfNH2ARPDdo9lj7vB7F6TDOQ7nWDH/ts7znK1GMKLuCo0KdTN+RdYhfLreDG2ixmonvT2ZgsMwS5P2NvVk8kG9UyaMCnX7PzJOsSA0+Eaot+4IaQ8j6yptOjSFb4GkLPa6Is+O/oHOr1FY9y/DYgg+4ShJqm5h1aC36neK63HFX9ghvipDRPwpGMh3aU/GEBZIKipVmRgud4Dx5Khms2nFfvVI4NjjLqBkfcggQGaMxUdC4C0gHJBYLbq/6zG/XNxDEBNAIYvXUwe1frRPsXb09NzAJQgqNk9oEV8HAlcChm94pujYWSfYRVIWsHtrdNoDpFrbikC8X/0R6xRcGelvO8UJ5wX/VC2NVPAMXCRGJAqssbKlyRfjQqZKDKf1qS/GMtX0gJHd6SI7GMMYhx/TIohc0kMUQmE8KfoB0L3c23qqSozxw+xzNdQk/FQHDtxqOTc4oqDSK7Htqups7H5npG2vtey7Mog8/MMiAZ4biTrK8BWWD1Sm7gfoEtlEMUlVurZQ550jJ2vg4vtZsA2BfIp6O5RzHixe1FCLf14Bm1Y7n2meLvEb0QyGtLk6TJp/PEZ8hzkHZ7MbsfjMBbD9Eyz28sOso14KPywJr4NaMgp nYkSxkAM WEe+hY8guBIi7pnWGT9TaQ8k6GRr7B0JxFMKk1rBBSGkDQbKGwzKEGrX8iGOscpTPXCkJ6PXvpwylgTDXP3ZrMH/ZV4VfziemKj9t54VWVlL61m5owrGHhBktAlv+1YuXepNI5CnAIPSbYCRr4y+4LeGw4xwnnm2JVd5Yo5sHGxp6A/MHqHfNGuTmFMbvx6mzMsvTiBMtZ5dazDCBqusrTq7C0Ny+QFbFXOVwHpbB/ZSeSmk+e+QZxvXkj3aahL3TLs4emarA0V0DSIOGCwXhYCUsDbfeH0B1ghKfVB67XsnkSW/EsUB5mYwfvl8BMd2X9ObRYd+Ovb8vtr9RNLiDo36RAewNF125ZJO85bs3gkV95LcdB2pNEDA50kmXTE2/E62BuNUU4E+THPpnqfBx4VVfoIbeo9uHa0X7jykmKjQ0dutM/VnBhTge/PACn/BESylW6la8TcRhTaj11WA2ggq4sa0iN+Djmprp 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: Make sock_splice_read() use copy_splice_read() by default as file_splice_read() will return immediately with 0 as a socket has no pagecache and is a zero-size file. Signed-off-by: David Howells cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: netdev@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- net/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/socket.c b/net/socket.c index b7e01d0fe082..401778380195 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1093,7 +1093,7 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, struct socket *sock = file->private_data; if (unlikely(!sock->ops->splice_read)) - return generic_file_splice_read(file, ppos, pipe, len, flags); + return copy_splice_read(file, ppos, pipe, len, flags); return sock->ops->splice_read(sock, ppos, pipe, len, flags); } From patchwork Mon May 22 13:50:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250594 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 E06D8C77B73 for ; Mon, 22 May 2023 13:51:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84EAC280004; Mon, 22 May 2023 09:51:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FF00280002; Mon, 22 May 2023 09:51:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EE23280004; Mon, 22 May 2023 09:51:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 616B0280002 for ; Mon, 22 May 2023 09:51:31 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 313751C67F3 for ; Mon, 22 May 2023 13:51:31 +0000 (UTC) X-FDA: 80818028382.09.4CC292C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 5A25AC001E for ; Mon, 22 May 2023 13:51:29 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DuNWzf55; spf=pass (imf10.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=1684763489; 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=3P+FOs1njQUxSqylXnXlO9wiVhuujp6lAryk+mz03wc=; b=0Jbvm9uEjklVu/a7FqEbo/xnW3LZR1ZJq34LXDhpWDGYdweEIIcQiKM+xhSduBO+zf1WoD cFYokOhW4ZSuxndxBMguJmaq7EATVqQcXDmVZaA/cbCqyLpjXWs2vTNTC829U56RkJVwCP ttgP2Jf0y2ZAcPnqvla+iZ7WwnrJZ9o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763489; a=rsa-sha256; cv=none; b=jfe08bpU9gNR6k3n40bYMn8XpNvRMC5fMB6X0lP//UNgeQCoHM9xglMlCcwGx3wfZxl88e LvSuJzEXJOvoUhHIyJrr0n39XN5VHTqXl/ibPMShAfVDBYFfN7Cy1Ql1UKSLaCNTVVDe2y 5WQ9u0N7q7zh3q2YApq1rsBs2bAHMeQ= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DuNWzf55; spf=pass (imf10.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=1684763488; 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=3P+FOs1njQUxSqylXnXlO9wiVhuujp6lAryk+mz03wc=; b=DuNWzf5541iqoqmcxsDnKmGDMYFTYGHvY/wcJXFjdi8wCmiytqddAnpG0eKLp3OmDL20xx d9B0IXGZiHc9lmRGdnRngzl6gw9k6yUkn2p0OmaajWhX30COiogjG0gfqVoEUaHpj9OPA0 /GQ6qiXTSRiGIuV+lNwsbbD4X2AE1kU= 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-626-t6IcFv94Ov-E8ijVu7uUwg-1; Mon, 22 May 2023 09:51:22 -0400 X-MC-Unique: t6IcFv94Ov-E8ijVu7uUwg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A23F0185A78B; Mon, 22 May 2023 13:51:20 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42CD0C1ED99; Mon, 22 May 2023 13:51:17 +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 , Dominique Martinet , Eric Van Hensbergen , Latchesar Ionkov , Christian Schoenebeck , v9fs@lists.linux.dev Subject: [PATCH v22 14/31] 9p: Add splice_read wrapper Date: Mon, 22 May 2023 14:50:01 +0100 Message-Id: <20230522135018.2742245-15-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.8 X-Rspamd-Queue-Id: 5A25AC001E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: xn1pqgrgm9tcq9hcx1sa6n3ytniuiuwk X-HE-Tag: 1684763489-825241 X-HE-Meta: U2FsdGVkX1/L5NDy3JJuG2RSU6M6O9nERCeB9mTlx/ICWlgNLo7ov56cB0P5WfaotHLlPQ2d7fUfEgjnDGtOkA9q9vQ0RNQAzwSQ3R8wNupVC7NcsMU7MpsiMGJSzQlWh8a3rhYzAqzhH1fhxIYRfa5jXT3l83kxdpDfhHEa0VwIJHCINFiL788tGHdY52VTFZqwa6wXeNKU8UVs551Ut38lnGnIE/lliWpBr+sOGTzT44uXgHuNgmhL/EBGrFk8hs6/GOAiNHvKsPxFo6rsW8IuZJo8QUbhuVdXc4jgNmfiNk2KokQH/IPLJx3Py5lEWCFH1hL/X9p6op7KQwCdTaRJbLwi//q4jQ+RVYgBGtUyUTSs0nHV/ULs3Rhn7Z+/01LaMkXNjJUMfkGQZmQ6R7P90Mn4haPPxPCN9fANiNv2QxLMMEQolc3hvgLGlsH+GZhwVmXK4RKBpwM20Zx+OtEEjuy/DkqqztrhuNceaeCaYurJnCHyvPM7Qu+InTbvbzIECaGBkEkfjrT4bfgYX06TLVrOr8G66PCmyzBh2aesJEeFjsJ89Bqa/Hztt63JCRgWCbMJST4nSnr0lBcLkVOclWN6PoG0auEOOKyc3fkNmiF7Dd05KB3ET+TWKzVfHVez94yb7ZohMOKex/2APhou87mXfLd6H1XwoT9qSvcTSKh4stBDHBPEKyzA1I0wuE+JWkBfNy1LlTxrOkE3X9nO3wxzctM1g2XIJIxSX2FTPSnfJBvZwt/e0OAuZRy7maI2nyyIfkoXQiZnqgB/2NUXghAoS2xVjd9qFHXzeLvlW1YZ997DNDDgrYji4WMXamfHZ7ACfGWFYBqLYjqSjUlI+aYnRuSOvGP4xtAaSEseonn1M+KqB0PDIBlvhJtt9P7Rx7W28p4BPDzW6YwBaPZVz/YpHSG7+SQhXBwcyirKZpsSFhxj03ANxJcmVdMYXy/3e41vqs+xBWuNyuF T658V8dg Hx+jdRxZS78Sx+MiRS8RQqkocsMCZIs5dBV34bfs24+OvCXGHpXPQDWleUq1FUEtRbKfJ/6Q146HFEGlRdhh4JwMVTfui64zy1igNpeO1d1PZDfiYKnLlJJ711wAIvOJ0Brt11tj/6KBUz/3mkI8kO3+xV3acyu1095N2TtLh0C02FBlQjIoNE3m8fIHGjA3Pv4hxXqvPVeUYXMOK6aR/x+0OudV1aL+unPNspt16xp/SuQHqqRBi7r6ifPrP/RThz1iw9MBakXTuUZP600ZJJLXKxCAwzNvS23mTX86fFjlVEtLrAZQkaIfdZ+Qqh2y2EgnGrzjrMJRYSaBsy3D6Ba+XDCXW2miwD4OkSiLji3CfjJhxcA6414jo26NOLcYAuGDcIGyP/CxwJMbaEUevq1OkSEVc4HkfpfYrRUaw+tJxINyuDvXMrokP2NR01N57bEqW2mQ5RMSw/WmU+ea6ymNzDqF6M4StR8JiEJ8G0kLsffl+PJd/lRIODynperwK0j76tEiLrd1lMXy+eAzuObhIKENXIMl5jdRQkwOUm8WDBNcLcKVwHk+3EfH92ay+ruWQUHh46z111XU= 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: Add a splice_read wrapper for 9p. We should use copy_splice_read() if 9PL_DIRECT is set and filemap_splice_read() otherwise. Note that this doesn't seem to be particularly related to O_DIRECT. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Dominique Martinet cc: Eric Van Hensbergen cc: Latchesar Ionkov cc: Christian Schoenebeck cc: v9fs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/9p/vfs_file.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 6c31b8c8112d..2996fb00387f 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -374,6 +374,28 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +/* + * v9fs_file_splice_read - splice-read from a file + * @in: The 9p file to read from + * @ppos: Where to find/update the file position + * @pipe: The pipe to splice into + * @len: The maximum amount of data to splice + * @flags: SPLICE_F_* flags + */ +static ssize_t v9fs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct p9_fid *fid = in->private_data; + + p9_debug(P9_DEBUG_VFS, "fid %d count %zu offset %lld\n", + fid->fid, len, *ppos); + + if (fid->mode & P9L_DIRECT) + return copy_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); +} + /** * v9fs_file_write_iter - write to a file * @iocb: The operation parameters @@ -569,7 +591,7 @@ const struct file_operations v9fs_file_operations = { .release = v9fs_dir_release, .lock = v9fs_file_lock, .mmap = generic_file_readonly_mmap, - .splice_read = generic_file_splice_read, + .splice_read = v9fs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync, }; @@ -583,7 +605,7 @@ const struct file_operations v9fs_file_operations_dotl = { .lock = v9fs_file_lock_dotl, .flock = v9fs_file_flock_dotl, .mmap = v9fs_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = v9fs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync_dotl, }; 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: U2FsdGVkX19mu3byXobGxDYH3zkwRkeHIA0g/rRjIXe6sh3XbXs5wm6ZLGZzIrSvJ9isRAaOHvcoLQ3jh60O+Vc/AQLEUKmp9YWP1MNKBfgA2r8TgQhRPCNmeB1sTRFPIcZkKmqxOQUGab4WKu/Wd5Whp7xr20pLJrb5sV++XETRxY91b7s6WO41SNzHS+m9k+wjtS2Q0zjejIIsV1OfJ5FIb7DgUrp79927gC+CcAazeoyqC+fBBPLCrn5AFHUFD4/mkaud/Nn/MBTngAxC214yEGmulkkpGZBCL4CCdr3++UIoemAWfXsjXEmcLKSqihFalOjpoVy6po1cR9MlcQaa4arwuGAfDmknEN296seBiWyaWHv5JFVkorHDOR+7YYrwMxmfa/ovT5VCh09lFG01aelapXS1LD0o/TnR6n4G7y7MiagRbH5uO2QKh9o+QV8C2KhLZyjgq88ZyOn7V+m38k0HCMLOKuorGYoQmZBJE329PIEbqdMHqEYS6qdcrDG+0zmM/Y5m1JoyG5OnjO719L7jKn4Mh3xWNA1xUM9fVYc9lGJXM9wOozcrHIzvZ/ZQX65VVvhDn92YSn2Fmgsnh3oMqP6gkjAZ3vFo7rmpLz9L6GYrdA33/IH+qtQdf+kHVhqw2X2NssY8klmSziRQM8IIU6gfmGQ1NBGKxcFURI64gQtQwfX9MLipA/+8tqDtrAa404pg/C9uIf5xPApPRjV99VzzPV/IfdistqRXxgWr8RkYm9CopRW0/nhOiDiXBZEdSQdw+X7qw1xfeY+LDsGiJxW2356zzl29/TXpFbTX1vHWVkoomZHYR2gQVA9Lpy2GbVmlxhQ6CkFCcL7KabolxkQjxgJFkSoYE80qlpXKeiFdQFtzHHdPTyDq95oRTxwPIQRTl88Pl/VgJ9Oq1yeyctGgFXN5x/OJlllPrphziU1sfJqhPuuUm/f2g6HRPMnd4DbCZtFQuy2 /Y0PNkE4 6b/9EQQNyH+GeSB5801HHoc3OH8e8vAebgEmy/qlCRHdkSC7TbECc64RZ9ox58Kt38LxZpySVdhaLMyQo4gT6x/RIEuwtDRHU7mav/22er8iqIXuv8+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); +} From patchwork Mon May 22 13:50:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250596 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 78096C77B73 for ; Mon, 22 May 2023 13:51:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1238428000B; Mon, 22 May 2023 09:51:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D3A3280002; Mon, 22 May 2023 09:51:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E688D28000B; Mon, 22 May 2023 09:51:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D14D6280002 for ; Mon, 22 May 2023 09:51:34 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 985EAC0332 for ; Mon, 22 May 2023 13:51:34 +0000 (UTC) X-FDA: 80818028508.13.60369AC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id BBB70140005 for ; Mon, 22 May 2023 13:51:32 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ABHAEyNh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1684763492; 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=z3sOA+Wd5tRsdYNhOEn4oLwEz6sO/UZ9O0VL/asQvAk=; b=bECRorCIZ8FViZ4zChWbuFNUlCWVNH8hl4oN7CI/nHADTgY2Z+i9vD7whBTR3M/F780b0R Xjsgv9lMDyew64kRK/YdWfu14S0sPQJcKlzQPAX5c+uXZPdHwraGkuQuP7j/Prodoj9jtA aHnk5+61whTUQv0NoN8ZdFWonIdNXdQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ABHAEyNh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1684763492; a=rsa-sha256; cv=none; b=InETmhXtoFt+k5wHYJuYe77Uda/ZWYkbr+1IsAHLLvtSkTHVDS+MDQtscdqBA/Cg1TKWgP RyWkZueyo0fEIl+irvcBWHy5CmDzHTsMYJzQrBja3HqUWn8i8CDD2N4k4hDRifLv8tFcQU stg+X+Aw1lutcuyFLRTFnt4pqwwEH04= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763492; 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=z3sOA+Wd5tRsdYNhOEn4oLwEz6sO/UZ9O0VL/asQvAk=; b=ABHAEyNhFdso4+ATXKOFSdq3z4S8Eq6m9BwaqH6xMTOJL0CvKmK2ftReT0c/napc+nJCNX Wp80JWt2fz7K7nQRQyq14N+YEpRFLIJShvty4qAi+kg1ZHpxHPAgMtyMCzVKMJkyP6Z91t XvqgnzxrJzxDsPwkc/GGcsKEQ+YaXoY= 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-589-15acLePuPo-nRv91oSUclQ-1; Mon, 22 May 2023 09:51:28 -0400 X-MC-Unique: 15acLePuPo-nRv91oSUclQ-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 CC505185A78E; Mon, 22 May 2023 13:51:27 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03D3540CFD45; Mon, 22 May 2023 13:51:24 +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, Xiubo Li , Christoph Hellwig , Ilya Dryomov , ceph-devel@vger.kernel.org Subject: [PATCH v22 16/31] ceph: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:03 +0100 Message-Id: <20230522135018.2742245-17-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.1 X-Rspamd-Queue-Id: BBB70140005 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: jypaduzqm4qnosiwbwsi5j7f9agshidk X-HE-Tag: 1684763492-363305 X-HE-Meta: U2FsdGVkX1+NFDzIxU+UiYfgkO1UbGfRnacpxIbfLDrhiVD4PPBfklnLKuQNOmtjuNgNdWr6rdiDuI93KRnOhWNXRylHIlgzarmbql3Z9stCQNWHTuIINaz0cG625BqAzR8RiMGgx5kG6yJNhLZCVNXF6jWSkpuzv5vAy4Nn0eVxN4sCRBwcux8UXGmV9u93a4EoYgOzTVBVHoE4JO6JNqVibOK3Oj2TvJWrefaONO3FkRTNeT4X2GbeEq1Twphh7tCVIVG5QqLDImBm86R0DznqwFR54HDah1E1sMODwVsWlGKYSBLbcXo9hw9hO/C+wMGQisksMOj/8fZgIPo/4ehroQY+efhTn/PK+o8PvQfzQ71uVhF0vJn7QD2rQkdZ1ZjfDerrIbeQgNuvtfasZo0+wkvyn7ZbvAARccLYRHm7QCkl/hWyyNbGlwDQbdZuIMTj/plc/z5pz04CEkbriDmVs5tXvXOxD/2jrPLawvZUSHz5CjXb5vnvcietbfdxL6qBZECbmBOa6RLBxZnmv5wFWBZm6NPD+pjpAHhpqumKgr3gzt3FVhp77OzWxPFmgOyiNodFDBhaoZRUaVv4WP2OpodsKDY7sDk02s6RONReJZ93QUj3Z1F80eLdK6rz09iHzSiCWxBTAhgPVs1rmX+9D6PZ3kDH07HjrsOxxywW6b0flKEvhyHJPoGW+5LCqrOWnWGrbqn+IY0ssKk74kEiwRvG/fq2omO4NDYedd+vfHWSVnFxDmnEjNnGRWK9bxkma+3hEa5R9w27X3axJxYJzM7MVdZLhL/9vyusGGaE9xQm5lE5cQDt+SWLYGnm12ZtMAR+gKXzcTgcIkpDAQ7j3eyHTpBDGq3kmVjAbdaIX3c5IulwYNIxUvul74HeidOuAfLPjUYG+NTLmdbKPEX5VEwG+AhEUywqLS5ojV4fhBDseAI50Qmv7Ey52kGWGhjURSh1MG5eECl6hx5 hIxBvvl5 +We+IgsbsjM2LAkuiGUx6nvTS5wves19rqnQfKvlwgFUr/ebkbD/0YYeeMWrnKWo/O7TLiQ4/ajGsdR5Wq6WzeAff1hFIUO3vdzJzkFuS0/uTh82/bojP9NIqjuhPOofm3kcuBHjvFymn8NLy6El3acZ8ADkjDfHLAvq9zP3g0ArQumD/INnqvXR3grwacTnlxOTftxfgy2RqRfY5xW7fP70iyUC1kibRCtY++/hbbxQdLAD0JAZeQ2uE1W3j6yfGVPpYrYzTddYVy10K9KA1N0rStO/a+zdROj65nY/iSSDfd2Tm16NYkd6c5v8nyIlsdt5b2AY4ss8k62hlXOXX6m3/eHo3GW6khiXXT9PHhewtJnUnANDl1zxa8w== 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 Ceph. This does the inode shutdown check before proceeding and jumps to copy_splice_read() if the file has inline data or is a synchronous file. We try and get FILE_RD and either FILE_CACHE and/or FILE_LAZYIO caps and hold them across filemap_splice_read(). If we fail to get FILE_CACHE or FILE_LAZYIO capabilities, we use copy_splice_read() instead. Signed-off-by: David Howells Reviewed-by: Xiubo Li cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Ilya Dryomov cc: Jeff Layton cc: ceph-devel@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #21) - Need to drop the caps ref. - O_DIRECT is handled by the caller. fs/ceph/file.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index f4d8bf7dec88..4285f6cb5d3b 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1745,6 +1745,69 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +/* + * Wrap filemap_splice_read with checks for cap bits on the inode. + * Atomically grab references, so that those bits are not released + * back to the MDS mid-read. + */ +static ssize_t ceph_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct ceph_file_info *fi = in->private_data; + struct inode *inode = file_inode(in); + struct ceph_inode_info *ci = ceph_inode(inode); + ssize_t ret; + int want = 0, got = 0; + CEPH_DEFINE_RW_CONTEXT(rw_ctx, 0); + + dout("splice_read %p %llx.%llx %llu~%zu trying to get caps on %p\n", + inode, ceph_vinop(inode), *ppos, len, inode); + + if (ceph_inode_is_shutdown(inode)) + return -ESTALE; + + if (ceph_has_inline_data(ci) || + (fi->flags & CEPH_F_SYNC)) + return copy_splice_read(in, ppos, pipe, len, flags); + + ceph_start_io_read(inode); + + want = CEPH_CAP_FILE_CACHE; + if (fi->fmode & CEPH_FILE_MODE_LAZY) + want |= CEPH_CAP_FILE_LAZYIO; + + ret = ceph_get_caps(in, CEPH_CAP_FILE_RD, want, -1, &got); + if (ret < 0) + goto out_end; + + if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) == 0) { + dout("splice_read/sync %p %llx.%llx %llu~%zu got cap refs on %s\n", + inode, ceph_vinop(inode), *ppos, len, + ceph_cap_string(got)); + + ceph_put_cap_refs(ci, got); + ceph_end_io_read(inode); + return copy_splice_read(in, ppos, pipe, len, flags); + } + + dout("splice_read %p %llx.%llx %llu~%zu got cap refs on %s\n", + inode, ceph_vinop(inode), *ppos, len, ceph_cap_string(got)); + + rw_ctx.caps = got; + ceph_add_rw_context(fi, &rw_ctx); + ret = filemap_splice_read(in, ppos, pipe, len, flags); + ceph_del_rw_context(fi, &rw_ctx); + + dout("splice_read %p %llx.%llx dropping cap refs on %s = %zd\n", + inode, ceph_vinop(inode), ceph_cap_string(got), ret); + + ceph_put_cap_refs(ci, got); +out_end: + ceph_end_io_read(inode); + return ret; +} + /* * Take cap references to avoid releasing caps to MDS mid-write. * @@ -2593,7 +2656,7 @@ const struct file_operations ceph_file_fops = { .lock = ceph_lock, .setlease = simple_nosetlease, .flock = ceph_flock, - .splice_read = generic_file_splice_read, + .splice_read = ceph_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = ceph_ioctl, .compat_ioctl = compat_ptr_ioctl, From patchwork Mon May 22 13:50:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250597 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 04561C77B73 for ; Mon, 22 May 2023 13:51:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 911E4280002; Mon, 22 May 2023 09:51:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C280280001; Mon, 22 May 2023 09:51:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78A32280002; Mon, 22 May 2023 09:51:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 66437280001 for ; Mon, 22 May 2023 09:51:41 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4350B1C6D45 for ; Mon, 22 May 2023 13:51:41 +0000 (UTC) X-FDA: 80818028802.26.BF93CC9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 4901C14001E for ; Mon, 22 May 2023 13:51:38 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BZKIK2rv; spf=pass (imf26.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=1684763499; 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=biWhCp40UoPe+CyS0Ztg+L+BfqL/s+IwYQGGzgJK6kA=; b=cqoj3YEqylcmv/boFkcxE64DS+2OXrxDV2vNAfQq8TXQiHE9Jjo+4RqWjI9J1aVBYwf6tt yAJIUCBOFpaWP/nkrrhxG6Xl6Pw5aD28m+6ykxBk4UrOOE4AynUbjsvGd7YORI1gsEQ1/K /xEWA2NzEOI6bc0cfPRfyFJ6uZA0AWE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BZKIK2rv; spf=pass (imf26.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763499; a=rsa-sha256; cv=none; b=ULd2XUFS3sDHuFogb3wEUf9txV1yz2p26/XjCeKfQsh+6ZF1nh/t5wBVnMs4Ojc7+XDAjB URYSk5v8qdFeCcXiQjXU3pQ2gqPB1m6/Ss13IZsUuzFyYFh/ccitxgWj0PsJn5oxCBdXnv aXGITv+Z8YYAOlmc/rHWQ3Zn/6sajJE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763498; 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=biWhCp40UoPe+CyS0Ztg+L+BfqL/s+IwYQGGzgJK6kA=; b=BZKIK2rvkymFSSGrNDWoDXlABsVpdviFM1UlquAXtu6MjlADtyUU6Y6dQtsq5cALdRov8a b8Q2aOMzIRln49jW4z+p4xxGelDZYKFR53+06kR8Z1QbbuwV+VWyOGzgccJKpLtY5qCA7K DsxqU6oGfXA23WkFQBenrnOic/OH1aA= 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-671-pS6JrZMuO7KdRfWYxzCxgw-1; Mon, 22 May 2023 09:51:33 -0400 X-MC-Unique: pS6JrZMuO7KdRfWYxzCxgw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0380C800BFF; Mon, 22 May 2023 13:51:32 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3683C1ED99; Mon, 22 May 2023 13:51:28 +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 , Tyler Hicks , ecryptfs@vger.kernel.org Subject: [PATCH v22 17/31] ecryptfs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:04 +0100 Message-Id: <20230522135018.2742245-18-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.8 X-Rspamd-Queue-Id: 4901C14001E X-Rspam-User: X-Stat-Signature: p4gokum4yi39ibynp75nxgbgkjynji61 X-Rspamd-Server: rspam01 X-HE-Tag: 1684763498-566099 X-HE-Meta: U2FsdGVkX18nTUysWq6tfXaY0yvX3sIFteMNXAtZdhTWFgKEO6P/oqmBNktjDVGy1T6IlMvFd6guKQ7E7A+XepdFu6iLzydqdSMre+mnLPaMzlZQ2AdjPqvFx2su+jl7Tc7XiVoAUl7sBabSrydbpC6xRn4lLB2KuCVUu1Ut8s7DlbGPP6Vi/CacqJ4E3BAhLgDjd3F5Bs46TrXcHP555jxv8DdE/mVezucQCNgB9OjpkTVl+1QOWYVHDcTePbsDjzV2a/hIaZpVqAdLcL5LIZ+9mDF9AXRKln8UCbR3k4lY68u3VvxFAtyL+5c5JO/f9de2TU8u9Y1ilfF5pd2XmTpcaxJeIErVBkKdkXMxA+mscnsSS2RaC1Pl/8oyJSTWHqCpNhl0HcNhhbMIC+WMpcv3Fo7xyRlsVQtfLAyFWuXeSKJ7qwkH0Sk9fSOXai7JvgEKaV1QBUHS3n/wIYrKvftvWjT2qv5HLRv1KU8lHYgomFg7Nzqap/exhSGlK+3Xe2bgVNBgURx76fzzohm+tYc3h16EqTm3ASPVKgsyBvs8EWRd23s1Gtt+32ynhTDjWT7q7QZ9Qgo38NHzkGUi1nDNejDmDpFum7eSG2XMCO/9KX4QZJsjvzgINNOFgqmamz5UcxzLzOEU1ozGpbqxwS/jQf3LS4lZngYVLcFQQ+Do4Zu7HZt7sP3k56g9vPebNT7T/rOA2en8anc5P1hbkweZ7Ip1uiUim7E/gx5KYU5UEZUOuwtAcAyl+MybTO4JGnpkBOJvepHnv7s3yyE/+sqWb5uvVbWmptqs0dsEY/TbqXH2pv7tIpzhBVOR72zaFiNKKmjU/rbdZux/cWdL8XWtwrvYaiOzpybZKUpjsgrcAhZ/pVRaAmH3+d0p6QrrIL5IucpxdrJu6MrPyxncpC3062gqXVJ7BX+jecQ2YAi4u2OIqZyLArUPNNejTYppTY9iPh/IE5/TuIex1GM hclm11ja wg8oRkTjC9dgPAiAM4Au/oqvtggOZIcfJSJLhEHdVe1S4opFFitgoelSsiQBuC6PwfF8+f8PJfW7pEwXG+xqLdm/xIA3dyJ7oxlLxpzIY2mIsaMM6vD4efZOeHuvJjkmWpJ818IyCqZPsrOBkh1IjYhcdXC1Z9HSKGTac9GiI5r/Q3xo1w/w8vR3pq2ax0+zrdk3ZGFqlVJU6VImRy2eb8Q9GeylClhpHOjodk9YVa/aYLTwGBzJmT27J/dJ8jLxOnsGke3aLxS0S/oVZg72VZ8xJYq6DCqVPruvPaBH0dLmuAylSuPF+Zu0Esb3vVIScjDy5+56Y9cZovOMEiqS0aZwTf4VK/9uUCIlJtCTzlmmfIspY8GrbQtntaKGicnrrPR0mU/f/hJTdLnY9ZE5HHvg7xoFiSgNe1ZpW 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 ecryptfs to update the access time on the lower file after the operation. Splicing from a direct I/O fd will update the access time when ->read_iter() is called. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Tyler Hicks cc: ecryptfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ecryptfs/file.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 268b74499c28..284395587be0 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c @@ -44,6 +44,31 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb, return rc; } +/* + * ecryptfs_splice_read_update_atime + * + * generic_file_splice_read updates the atime of upper layer inode. But, it + * doesn't give us a chance to update the atime of the lower layer inode. This + * function is a wrapper to generic_file_read. It updates the atime of the + * lower level inode if generic_file_read returns without any errors. This is + * to be used only for file reads. The function to be used for directory reads + * is ecryptfs_read. + */ +static ssize_t ecryptfs_splice_read_update_atime(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + ssize_t rc; + const struct path *path; + + rc = generic_file_splice_read(in, ppos, pipe, len, flags); + if (rc >= 0) { + path = ecryptfs_dentry_to_lower_path(in->f_path.dentry); + touch_atime(path); + } + return rc; +} + struct ecryptfs_getdents_callback { struct dir_context ctx; struct dir_context *caller; @@ -414,5 +439,5 @@ const struct file_operations ecryptfs_main_fops = { .release = ecryptfs_release, .fsync = ecryptfs_fsync, .fasync = ecryptfs_fasync, - .splice_read = generic_file_splice_read, + .splice_read = ecryptfs_splice_read_update_atime, }; From patchwork Mon May 22 13:50:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250598 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 53B54C7EE2D for ; Mon, 22 May 2023 13:51:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4237280004; Mon, 22 May 2023 09:51:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF2AF280001; Mon, 22 May 2023 09:51:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBB0B280004; Mon, 22 May 2023 09:51:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B26B0280001 for ; Mon, 22 May 2023 09:51:44 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 84CA71C6D45 for ; Mon, 22 May 2023 13:51:44 +0000 (UTC) X-FDA: 80818028928.01.C9369DE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id C7437140010 for ; Mon, 22 May 2023 13:51:42 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hjdXxxI1; spf=pass (imf09.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=1684763502; 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=k/c+R+8s2k3pMmNtZ3aOuXJCBbwfObn3G1z9h41bJkI=; b=sAKWjIWeuDEsqFd4ckjjSzL1f1F2HHbeFZ5VCXuFO4Jk+qTM0NkKuVJhRJh5fUEo6OO9sj y6EebWVyEurHZVesxjczvixXu7xWI/n0Lq8N5XfQBnfjQXGsP/vslJ7Ob7Goq0b12247Nb 943+mScv3biyMvr1EG10YeCBA1NWrFA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763502; a=rsa-sha256; cv=none; b=cr6S87fYDn1mzHilQ+PEUDX/ICq2kD27gWq/RLt9NL1qR65eOgej3s9AchbGxFa4wfUslJ vKTZrkL1GKaBKDAXxFcWzT9Ij01vI2q9zM8E/AjK7HNz2eL0SQxuixdI3jf2VN/zMGwXNm gftIEtX3pN0Uup1G8Q0TbiCjbVrdjuE= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hjdXxxI1; spf=pass (imf09.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=1684763501; 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=k/c+R+8s2k3pMmNtZ3aOuXJCBbwfObn3G1z9h41bJkI=; b=hjdXxxI1PAwmdF+Zl4F8OFTGN1CJlu59/tR9VY7drNh0S4c5m/MhEyH7JbVnKBsrFlaOv8 kf0v2n3T9JIDzle0ThI4qPmtBEOjNFkLhLjcNI3IgcxHGXZGD6tvnt/G2GHmQZ1wcz9X7E f0m2Oc33vPCFIDiBmJxB3WAcUx+DiZg= 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-423-NgNsZyJqPjue_3wdjfNq9A-1; Mon, 22 May 2023 09:51:37 -0400 X-MC-Unique: NgNsZyJqPjue_3wdjfNq9A-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 86DD7281294A; Mon, 22 May 2023 13:51:36 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id B290540CFD47; Mon, 22 May 2023 13:51:33 +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 , Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org Subject: [PATCH v22 18/31] ext4: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:05 +0100 Message-Id: <20230522135018.2742245-19-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.1 X-Rspamd-Queue-Id: C7437140010 X-Rspam-User: X-Stat-Signature: zu8gn45szjat14sz5bodbcg8i53arg9f X-Rspamd-Server: rspam03 X-HE-Tag: 1684763502-724142 X-HE-Meta: U2FsdGVkX18DLui4veqKbyHHF4qtUoaPzBIBK4whYeBvgaFdoSNZi3hefB3/6l5gcLL69xsFXIROdGBYjhIy14NqlDr8LYzJHXoVkEKhjpvWFQP6JmbBlwahyvKRLE8jQaBCrsbOhSoKHkfhOS0SGCpB/S0e4rEj0RQUQ0OKxZhwXY9Nr5OLiHS2A7T5Th2qVC9+CTuJAHHsnPoGDyY7BRJMq8F7iqgne5TwuFSGrNokr+WcPEsySGdsO/BCoMlCanq4FvLePH0qUZqCS5oLbkWzdt+IuE04geKzHzUghiRSa+Akb3SCxy+aABfL3/G2Jc337wSm6AUaMz0g+uIiuRrYfZ+KHTQTr5y4dArAWe7ltrlraWmxYF68Z2OtCjGYbobNizPDRw3OQ+NCzoabg8QBaTjXDsuRMCmHE27vM3zIntPnRgityOE9pKQ1WoempGFa27dYdiuqO98v3fCOZMTrMNRWYKn03MbR/OwKuvaNbW3emq1OVjy2UPUE7RO65pEXV6ZD/hAhUvGbBwPGomA7g46rygZyKwTKUE573Uwse4eP8Vlq7f8S+RRkfOwCC0cugpuksId0Jg6wu7YQpQ5tM0VZT9sh8fF0pO1G1e+Az53+xcqg3VncK6hprqRC1M4oQHc+XkGLzyx/4G3JcpHrdetocL4es88IIzIdkV+n6dG66q8IWoFR/yBWh0f1RVV4NKcSxd+fMPpAOcyrPvCYNU8H71GIPO4hHPMrpOuaumjJ7zz3TDWPJoe9+NxU/lMzTAl0PtTvBOW+tXnLaRSAn6ZV0BffL/uk3LfVLuOLn6Ro1rr9r4Kp5Xn8W164BSlW20jtOofzRY/Y1IDSEcgwVzDDhO6onXE6Ny1flBxw8DG3S7EoJWfjQsJjrEJmyxFwyQzt43ENnLUAdYqhI/HBqSsDGLCuDvQ6F6z6NTvuVHtNffDVbM4xRltRkvPwtAHT0sLEGhDGe6i3uLw 3z0p/C8W ulAO1ZCpmw+Cw6MhM0wQgHDc4DutQ99nbd0urp3eoBZBfjMHPERBKT/ZDR6WsT8cljucdxmJOM423UbnR4rska9CH88VySfzw7Qz0TBUNn34InQHsyGqkyOrNdsRM6NSDFND9/sh49Tv8LL3aOCD5dFCGCmfa/ORsz0NjeJm2PjUWFE56T8PyLFr6AF2KOTf1eCbWnbYBKMshTwiq8CEuKTUhPUFBNX7c/y0ZK8sYIiFlzGnmQyC6Uwi6g7oy7KFVeBMQL0EkPZpMtOaKmuRZFJ1NPi/0kk1unNQ9eURc/mHAFUrSNIgZvk0/Y63bqA1mNaqug3oe7vELU0kFlP9oKdmUO54gdS7KAAsq813fXw1QF7YXMuwdOCjOlr2Ar71CAgoiWYi/E/Xtf+y8QK5H8z73v9E0m5PyD3WA 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 Ext4. This does the inode shutdown check before proceeding. Splicing from DAX files and O_DIRECT fds is handled by the caller. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Acked-by: Theodore Ts'o cc: Al Viro cc: Jens Axboe cc: Andreas Dilger cc: linux-ext4@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ext4/file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index d101b3b0c7da..9f8bbd9d131c 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -147,6 +147,17 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return generic_file_read_iter(iocb, to); } +static ssize_t ext4_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + + if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) + return -EIO; + return generic_file_splice_read(in, ppos, pipe, len, flags); +} + /* * Called when an inode is released. Note that this is different * from ext4_file_open: open gets called at every open, but release @@ -957,7 +968,7 @@ const struct file_operations ext4_file_operations = { .release = ext4_release_file, .fsync = ext4_sync_file, .get_unmapped_area = thp_get_unmapped_area, - .splice_read = generic_file_splice_read, + .splice_read = ext4_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ext4_fallocate, }; From patchwork Mon May 22 13:50:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250599 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 75ED8C7EE2D for ; Mon, 22 May 2023 13:51:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14A3F28000C; Mon, 22 May 2023 09:51:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FA5D280001; Mon, 22 May 2023 09:51:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F045428000C; Mon, 22 May 2023 09:51:48 -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 E2697280001 for ; Mon, 22 May 2023 09:51:48 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B2A0B80349 for ; Mon, 22 May 2023 13:51:48 +0000 (UTC) X-FDA: 80818029096.03.0422DEC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 08FA818000D for ; Mon, 22 May 2023 13:51:45 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=G3Gb0leL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.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=1684763506; 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=8d8uJmrTh/75eqAaNN/foN1c757ttvO6v+jRBhlF56A=; b=wRS2q5Xc7/B5uPx0WJSwoAvv5Vhbr4tnr1nynEVOEzclDR1VMulDwuIGX4u+lOf1qI7ael CnTFC+jwXqg2/8aHnc3mW/xGnrj4SucW+M6VNB8FmQPacYT7cI7aiUu2Qf0GQ3pImwkzaa 1vNMN+9phR1RRVbBbr0hdvMvodM7Kac= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=G3Gb0leL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.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=1684763506; a=rsa-sha256; cv=none; b=2+Rx4hJ+uohA7WacRl3JRd5zXY4sdRy9HhGeAsvuXxs1rN0Q3rt6Tv2WtES3HNtCoHPoED GXy93Dn9NWyYxUMuNT35gbj9uHreJW+P6yzohmi3jgJtHZ0416V22mx5VYjtdRWhB8jAhk R7/0kV9/7mKZXUyPxylbgcebL1qtTr4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763505; 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=8d8uJmrTh/75eqAaNN/foN1c757ttvO6v+jRBhlF56A=; b=G3Gb0leLNGy9D39/4BB8ELVvuZanIRr/qu6JoSiAkJgHKWlaQ2WHyH+sZ0dX0plq/XsHdG Yqcj7LS2in80DaBgfLmYczQZhVzBTl9ANbjG0VG967g9KLVnCxkTrXXtMfTtYQmL+qWMxZ E45mihEXFIyX2oECa+7mtG8abPGtGDE= 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-103-ZtUfXtY9PdeS9nRV65CuKw-1; Mon, 22 May 2023 09:51:41 -0400 X-MC-Unique: ZtUfXtY9PdeS9nRV65CuKw-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 149CE185A797; Mon, 22 May 2023 13:51:40 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59064492B0A; Mon, 22 May 2023 13:51:37 +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 , Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v22 19/31] f2fs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:06 +0100 Message-Id: <20230522135018.2742245-20-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 08FA818000D X-Stat-Signature: k9dxzpyed3yd9538o4h6as8b7ykoufdm X-HE-Tag: 1684763505-764107 X-HE-Meta: U2FsdGVkX1+kUM0t8tS+zwai31jGLf6rYfPe7fx9/7rSeyQv+2+KKqq5XhSSWiSUYzf0X95b9Rz9JS/TVlKBRDyMjGyyQLOrU1K33Rkdyok46Zztl3i9A1zP+lQ7Cmiz0jw8i5l+7itEPTbeQsG6WdE49d5dcEfV/Xf2RdZrEiAwAzsLd7m7ruKp8YD0jebsWV1BdSvEMVFb1YVnqiIS8p1zeDZ2YY3EeuXAfsDbvtFL/ZDahWP4ijuNG0YRhTbTEaIbw483nJ05N4cYSha/+LgyOBXgsS3x1dCMR/1VZ3jA3rGETKHedXHBkAE27bFEckcK7akk7hQVs0cCILfTuARChztRh5lUQTO+VhcTVdHKuVvHnAKOPWWNMTegGJgp0/YfDAL1zsWVWcM4eOl7laCht3K5k3gZSrhEg/oZ/c/NVY7t8Z+uiKTRgaGZsMG/+OV4fqrM1uzn3I9+cS7D6X0+SqiESFZw546l1DGNnrP4wuO8O7Yu9M7By4wyFkEztfRQBW1IKPUDxDI2vL4vDqfxQwu5xKJDExniyCD8FmkZhfzwW+CGn39J5eTIIhUidldksKk6avHd1PGkyMEUeZai/hOXUhujRYiAlh+TKbAKZhMH+SUmfX7eY9BfHudNwwkgkU9zGPy3zTs4Wj02RQeMFyAjCux98ywx7l0zlhtj4mG+rcE6Mk8vA5sq5Tg2XXMtdu5evvxETxt3/kNAzb/PMW5uZjjlBVg28Y/BK7K/HOyz0S6ubyfjEC2ugwZw7R+7PQ7Q+5psZEe5/nWax58f1tRQjVnK66xpgVCmGErPNAXo55aduHpaQoWX0xmxUI6lQCOXCawWgkWmEmEh0VQdKHCH/cjilXMNfac7P02gbMuk9GmGlkE48tDfjfEc2QjNp3TujKO30I+Da9Vx9SO8O2cz6hud5APuRjJs4LQACJLU/2g2B6gES/TVnYKEdAFu0yv0E/5kPbHzqfc wCBIGwQi nXjYdZlKbwjDX9Vt4HQyd3itS2WaJQzSX8oICSLaQa3W4K9gDGZbZKDQSP4ePf97Wnc3f1qK6nPsU9AO0Jx+nLv9JvhW0Xj9fCJ0d4iULtCFo5W/mxv26hoEr3VyXdaYFmLXfrizH/INRxdCFjYMYTOkIkJJ8ZQ/NZaeTsHshGvjnfZzZTr5zCbXwJLESrkBT4wuet9OOUZlieygKrsePXplyIkxEddefZTwUCkGwsvG3luSJDC++YhG7GwOmkQXbR5wYKDiSCkVVSE5/iBFr5mvuxUq9Dhh0mpY1NSJ/o9nCH4PY+abR9Ymkhk+t+IR8+ihKbVhO3YppeLx4IyTWa6IOo47m3eRYLUvanoYvUT5uAa000mYPNPTwNg== 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 f2fs. This does some checks and tracing before calling filemap_splice_read() and will update the iostats afterwards. Direct I/O is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Jaegeuk Kim cc: Chao Yu cc: linux-f2fs-devel@lists.sourceforge.net cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Reviewed-by: Chao Yu --- fs/f2fs/file.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 5ac53d2627d2..3fce122997ca 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4367,22 +4367,23 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } -static void f2fs_trace_rw_file_path(struct kiocb *iocb, size_t count, int rw) +static void f2fs_trace_rw_file_path(struct file *file, loff_t pos, size_t count, + int rw) { - struct inode *inode = file_inode(iocb->ki_filp); + struct inode *inode = file_inode(file); char *buf, *path; buf = f2fs_getname(F2FS_I_SB(inode)); if (!buf) return; - path = dentry_path_raw(file_dentry(iocb->ki_filp), buf, PATH_MAX); + path = dentry_path_raw(file_dentry(file), buf, PATH_MAX); if (IS_ERR(path)) goto free_buf; if (rw == WRITE) - trace_f2fs_datawrite_start(inode, iocb->ki_pos, count, + trace_f2fs_datawrite_start(inode, pos, count, current->pid, path, current->comm); else - trace_f2fs_dataread_start(inode, iocb->ki_pos, count, + trace_f2fs_dataread_start(inode, pos, count, current->pid, path, current->comm); free_buf: f2fs_putname(buf); @@ -4398,7 +4399,8 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return -EOPNOTSUPP; if (trace_f2fs_dataread_start_enabled()) - f2fs_trace_rw_file_path(iocb, iov_iter_count(to), READ); + f2fs_trace_rw_file_path(iocb->ki_filp, iocb->ki_pos, + iov_iter_count(to), READ); if (f2fs_should_use_dio(inode, iocb, to)) { ret = f2fs_dio_read_iter(iocb, to); @@ -4413,6 +4415,30 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +static ssize_t f2fs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + const loff_t pos = *ppos; + ssize_t ret; + + if (!f2fs_is_compress_backend_ready(inode)) + return -EOPNOTSUPP; + + if (trace_f2fs_dataread_start_enabled()) + f2fs_trace_rw_file_path(in, pos, len, READ); + + ret = filemap_splice_read(in, ppos, pipe, len, flags); + if (ret > 0) + f2fs_update_iostat(F2FS_I_SB(inode), inode, + APP_BUFFERED_READ_IO, ret); + + if (trace_f2fs_dataread_end_enabled()) + trace_f2fs_dataread_end(inode, pos, ret); + return ret; +} + static ssize_t f2fs_write_checks(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; @@ -4714,7 +4740,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ret = preallocated; } else { if (trace_f2fs_datawrite_start_enabled()) - f2fs_trace_rw_file_path(iocb, orig_count, WRITE); + f2fs_trace_rw_file_path(iocb->ki_filp, iocb->ki_pos, + orig_count, WRITE); /* Do the actual write. */ ret = dio ? @@ -4919,7 +4946,7 @@ const struct file_operations f2fs_file_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = f2fs_compat_ioctl, #endif - .splice_read = generic_file_splice_read, + .splice_read = f2fs_file_splice_read, .splice_write = iter_file_splice_write, .fadvise = f2fs_file_fadvise, }; From patchwork Mon May 22 13:50:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250600 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 B018DC77B73 for ; Mon, 22 May 2023 13:51:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A572900007; Mon, 22 May 2023 09:51:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45501900006; Mon, 22 May 2023 09:51:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F645900007; Mon, 22 May 2023 09:51:53 -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 20CAD900006 for ; Mon, 22 May 2023 09:51:53 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D936740175 for ; Mon, 22 May 2023 13:51:52 +0000 (UTC) X-FDA: 80818029264.01.13367D2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 28FA0C0012 for ; Mon, 22 May 2023 13:51:49 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=asLFi8lW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1684763510; 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=QCSWlIyDBY1jtat2vRjBrfL6m1m2dv8ce4hoKBezm4c=; b=q/dpFgqtTwT3F3mqBQ0HG5i9b2Knli+mn/Io3ZsmwsHolms9pgU1YsibKFmYdpFc2Zz+95 4yKAd8mfnZfgqYJZiOSRB3BvcuEl75Ls94RiK2BTNMHMTyFLqjGaOKGCNnxAwB7iWoI+LV cLIlEk6AYSulCwmAukS2qI7W7EYko0k= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=asLFi8lW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1684763510; a=rsa-sha256; cv=none; b=I+9SiNVm1j2PxNug8VkdPKnNRQK2S7w+QY168Rr1+0aKVx7fXDd0bJxGSkOjcb1nIpW5Xy 2Lr6Z8jWV7lRoQgpIB8WH6YbNCj+HqBYHZTQUq2627e3xQFFK/gfLFf4M/nrfwaNN/Ch4Z 67qLLDTYy7SIy2IZX+dhvIP+m60KUXg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763509; 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=QCSWlIyDBY1jtat2vRjBrfL6m1m2dv8ce4hoKBezm4c=; b=asLFi8lWqKYOpWnSkDzo7MztVI6HxMniWUDZrZnLfvAfOmv3bphgRxNzjjy6A2VvPxUD7Q yce1xiplLUC8gPd8EXfn8jzm7YqYj5K/35K8R7K2YgnL5K9AsFEBTNYK8UheNQBVR2g4ZH A97fLWls6xAh4uWzTx5IzVaCqieZoYw= 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-543-ktvQdbIxMHSGBGqUdvd_JA-1; Mon, 22 May 2023 09:51:45 -0400 X-MC-Unique: ktvQdbIxMHSGBGqUdvd_JA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F0793C025AD; Mon, 22 May 2023 13:51:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7EBC2166B29; Mon, 22 May 2023 13:51: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 , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH v22 20/31] nfs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:07 +0100 Message-Id: <20230522135018.2742245-21-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.6 X-Rspam-User: X-Stat-Signature: 5yopzaq1fc7yutnq1i4zkzta8mpskuxw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 28FA0C0012 X-HE-Tag: 1684763509-292528 X-HE-Meta: U2FsdGVkX1/GvNELfjHC78TxZGwCS71Ht6p3NRYTbHe6Tda3rYutT/lX7hMhRSKgd+Yw5096yUW5tPmZ5C//U7oOCPFPXNBml/nrEgu4CpRBnnCm/L2Tda8A1znWYZicPjdM6zf0EexSQOMGYFdmzvasj3fn4X0mfUMjsRpTUv9Ng1Vi/6EDBAycC3W5Raj8ZXArGPWhlAHr6ciPZNM1uB4n9zYenVUF50TspH4ZsOv8AEXX71PFg42bjOYWoi2TdtP6c0FXm6uCwUr+fjJakE+k8rg1gw03hbQjGwuGEVn/C35rgV/4kWaLNHfAM+Ml3ork4KRUpB1/5uf3rvSedmCLMsmedR8+53xvPGvdNu4KSheBiZZlr2fmmYnk+C32bVACShGODtCkwoTGw9wyKBHg1mc0l5rvoMG4ePxHGIBSnkqPaaBkkMccYilKmk9YHf1iW3kBAzSFrIPgPgiL1nVwTI1lyS6tSRAlj0ZPEU88tuC8T/FdIYRtZZAUgUIWD4zihAM4BYPvakOcuwJGYwVb9G5/jwTvLghtIz+b7IxCoNapwOtudJOX2DFBQTiKYeL495PU/dYbKTudOkgI+SzBGzDmHD9J95i8prbPn41BejOmXc+TeXPgaIvx7VXfy/aEE0aDpUWNuKpojQk/IrE8lit7BzACYXAk/LKF8ZcRpleKyKT+b0bPoilYDLv9BO4tWHv3PVEMppdxlUGp+3ErtP7DBQO4HtXDLo6UahKvtJ0qOSo/QsFwSGoG3hsgdCfGSno+M1HTIJZyy2EyipJ8J+PI0dNT1yQQNbOPI3sfCD9ESyUmAcgy6ZKHcbORF+7+6h8MeyEF2CqdkHxV3Ghl3s9T5friyDcuoweUytW1citHWQxM4YWIsCCNT6MeBORDSkXWhhF4N+v9OVLk2dOmSG4LGveR7svXpplSrU/TjikPJ/BXdhWt2IcURaDcuUSdPKGfsnjK9om59xF UMOueWuA M7/scxk+nwtKNwP74cRNKcirKfLgr/cZeKjdZlqcwE5s0/APlb9BeJI7hql4Z0J7aT7KT7QIf6riqY2CU2OqUnXeFH5GRsU5jRZxH2r+Gaf75u2+UN0ghpmSO/o0FCRuScptpC7T9aGI48Axb1gU8BBP12z+XZDkq7s8vqw42rHAfJhh5CFSZJS+m4ov/5Fi6UFegvbjQRgUolzEg59ROKJ0yxNOF9XU3Z+k3If0doVg3Mz7SECfO6MWpyZDSLcYygTsSoK5ZTmosL7axjNqLOVZ0o251yUXq406OJL7FruQyeVYUJMXQ8rvpdXPWVNrU9oaJMzgrJGELFmm+c+CMB9yxypHvDALA+LslXSnx0LeUnIghj/yFk2DAF4RlOwXJ9pNkh8On06ptHSMW+UZKO9MmsT/Gmy9g+S4v 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 NFS. This locks the inode around filemap_splice_read() and revalidates the mapping. Splicing from direct I/O is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Trond Myklebust cc: Anna Schumaker cc: linux-nfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #22) - Fix format spec in dprintk() for *ppos. ver #21) - Fix pos -> ppos in dprintk(). fs/nfs/file.c | 23 ++++++++++++++++++++++- fs/nfs/internal.h | 2 ++ fs/nfs/nfs4file.c | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index f0edf5a36237..3855f3ce8d2d 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -178,6 +178,27 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to) } EXPORT_SYMBOL_GPL(nfs_file_read); +ssize_t +nfs_file_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + ssize_t result; + + dprintk("NFS: splice_read(%pD2, %zu@%llu)\n", in, len, *ppos); + + nfs_start_io_read(inode); + result = nfs_revalidate_mapping(inode, in->f_mapping); + if (!result) { + result = filemap_splice_read(in, ppos, pipe, len, flags); + if (result > 0) + nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, result); + } + nfs_end_io_read(inode); + return result; +} +EXPORT_SYMBOL_GPL(nfs_file_splice_read); + int nfs_file_mmap(struct file * file, struct vm_area_struct * vma) { @@ -879,7 +900,7 @@ const struct file_operations nfs_file_operations = { .fsync = nfs_file_fsync, .lock = nfs_lock, .flock = nfs_flock, - .splice_read = generic_file_splice_read, + .splice_read = nfs_file_splice_read, .splice_write = iter_file_splice_write, .check_flags = nfs_check_flags, .setlease = simple_nosetlease, diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 3cc027d3bd58..b5f21d35d30e 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -416,6 +416,8 @@ static inline __u32 nfs_access_xattr_mask(const struct nfs_server *server) int nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync); loff_t nfs_file_llseek(struct file *, loff_t, int); ssize_t nfs_file_read(struct kiocb *, struct iov_iter *); +ssize_t nfs_file_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, + size_t len, unsigned int flags); int nfs_file_mmap(struct file *, struct vm_area_struct *); ssize_t nfs_file_write(struct kiocb *, struct iov_iter *); int nfs_file_release(struct inode *, struct file *); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 2563ed8580f3..4aeadd6e1a6d 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -454,7 +454,7 @@ const struct file_operations nfs4_file_operations = { .fsync = nfs_file_fsync, .lock = nfs_lock, .flock = nfs_flock, - .splice_read = generic_file_splice_read, + .splice_read = nfs_file_splice_read, .splice_write = iter_file_splice_write, .check_flags = nfs_check_flags, .setlease = nfs4_setlease, From patchwork Mon May 22 13:50:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250601 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 227FFC77B75 for ; Mon, 22 May 2023 13:51:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8344280001; Mon, 22 May 2023 09:51:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B32E1900006; Mon, 22 May 2023 09:51:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FAC2280001; Mon, 22 May 2023 09:51:57 -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 8E85A900006 for ; Mon, 22 May 2023 09:51:57 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 668A5A0348 for ; Mon, 22 May 2023 13:51:57 +0000 (UTC) X-FDA: 80818029474.22.C58FE57 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id A8B981C0006 for ; Mon, 22 May 2023 13:51:54 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aeSp7X+o; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684763514; 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=vTrARcFdbC/vmS0maUQ9q741hTl6uEjvIQp7xTnb7lA=; b=r5RwQh1ci7uDTDIsExN8wGVguOyC+uWLkNcvBuBT5rytZDIcEETXEHYt0oCb0ixJhRKkvF mjUo7nIIZcXJjEEoTKmP7Z345eIUqjfrDFa9itsZRFaB0HE27oD4MHY5vWV2/+Es7tooHf E2HzVKVsUbCH7n3ix4hE0GAy5tIUZ1s= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aeSp7X+o; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763514; a=rsa-sha256; cv=none; b=R6vpADpPaEBtZk7KqmVUEspUK+5lZNERyMvkKG2RgrlqaD/NkS/llKKzW+F4KA3Jq0Gbyx qlgC2yxq6HToit9KljzBW8Nrq6efkUKn589YcWxfRuXMWyXgsQuLpP2UHJ/nb9d4UWwFrT fFXO5dreDG2x72enctPJfOMqesigJv4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763513; 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=vTrARcFdbC/vmS0maUQ9q741hTl6uEjvIQp7xTnb7lA=; b=aeSp7X+o+u040PQa6U55BXc/XR6VnJjtTeNJ0SUx2Qkjb1LVtYadTm+uWx6zbtiCknH+7S jbiJtjSrUMbne1wcKpTAF/bvKjTRq+0GNG5Rbk/AZ7gzICXXR9dvQED+gZx9U7FuzzbLF6 /IIzvChwIkCUg9xlD3lrdGYgG7+kBJw= 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-136-Wk6gk4jOMPyGatQd-7Opfg-1; Mon, 22 May 2023 09:51:49 -0400 X-MC-Unique: Wk6gk4jOMPyGatQd-7Opfg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38C00802E58; Mon, 22 May 2023 13:51:48 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A9E4200AE6F; Mon, 22 May 2023 13:51:44 +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 , Konstantin Komarov , ntfs3@lists.linux.dev Subject: [PATCH v22 21/31] ntfs3: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:08 +0100 Message-Id: <20230522135018.2742245-22-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.4 X-Rspamd-Queue-Id: A8B981C0006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: e5ag47hzra4tofa437tefqjmak7h86q4 X-HE-Tag: 1684763514-196344 X-HE-Meta: U2FsdGVkX1/fI27vkXCDddJpkaigZborf6FGGQ5Ekcd/5lm1Bzou2cAY4uINrptLL7TuLbf9PLmcKhlGcdkdni/H2fYJLVMfL4mcfvVOVDKdL5uLGheiqhNSiAlA5kde0BhPubFKtJkDzAnhrZZ6a942J0QPLPLbFotwUt99Iks1fiEPFjo2/BxJywEJVLO1YpM54x0BxwDxWENZDCw1j5i266KB34OMdBTef6nIm/oyGjFkqxJ0v3ajZXr+HCPEw9OFUxLiX5xUFtEV2eIp24ISTi3prS1Ovp2TmAnl9i1z3L0z0LWWXhTczJOGJ+qB2CdaFSNk2SF/A6vtaVf848Y80AWj3HzCKWlCbvfheyLXDiTnTWFO31ZsV9vYLPCgzvXVqyAe1wZdA8QAPByIq2HPEyt80MNhuov91x2ikL6tqs1ysowwQbuerpb/LfnLu6hfKoVOEOJhR4mFBGvYyzxDGRH6ifUekqLuemfUMe9Hq8XEZJ4rM9xjxZwgdUZywNRBjykXTQwKVkrYWoDwiDcZhfHvr4CykdLXDluZXphBgTleM9F4/co53w6oUx42WuNENA+x8LiLC8Pq3inDYidejXijp25+Kp2nnuR8vZ94X7AQA8GtSNvvRciq7qj2wbBmxUNGNioPye1++yBComKXXOPtBnIq6KounN5HXWcdug73ECtsRDov6AdC2NGJTUnvYJO5DQW9TKtE+iLshx9Q1DqlORIeAfByruW503cTiPnZySdGx7+c4GgRuVI9t+FArNZ10te2s8H7K/HkFsVbLr3wUADxfapjh5Mf8K+4wLsLhBe94gptZ7Z2cj1lSuOresFir5k1radoInkGca+TRPMubwGlR0gnME42WzkJJQNUi7uYS21pCyzbq5APcemBopgXEM9ASsme0OkqOARAh4GBTBEqI6/mbKPxP+EFbqzK4jN7urm4W+v5nD6azoBLEInFZZra6pENkk0 wjmDYWw0 HByQkNeJXa17mJze7EDHUfPWZ76A4muSEQwJTQKbG0wLUMrIQYhSJMuK6NVgbj9A699sTHgf48EXTGA1j5UV/6ejk0JJbxfIPbWSY4raKm+fsmx8Jq06Zj13XhW7Qf7k8N5kES7dezdR5b2GWcY1mkRoosHPwJ8cvDOEUdcpN1CJP4AXr5OVD5wSvF1HhjCwLj+7brI/YaCcMc91mutA2Sn9NohR1I7cj9UCd5xa65V5qIxa1WZUJNFPGT+Bng7lBxEjT8NHfwJNY1Wbk9hEy88ZAU7sUR5Lt13HdAGW3M9EDwygNTHZIl/d4yQmC/pUJj3B6wNEY0Kjjvsi/9eZX0U5fJB2LXYGqHcgttB1jxZlgaQxPVtmG/Ijsl2YVaJ+a7P8+F+aiI64JBaVDmy//akY8rZYmE8EssAb3 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 NTFS3 to perform various checks before allowing the operation to proceed. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Konstantin Komarov cc: ntfs3@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ntfs3/file.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 9a3d55c367d9..667c9dc68b58 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -744,6 +744,35 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) return generic_file_read_iter(iocb, iter); } +static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = in->f_mapping->host; + struct ntfs_inode *ni = ntfs_i(inode); + + if (is_encrypted(ni)) { + ntfs_inode_warn(inode, "encrypted i/o not supported"); + return -EOPNOTSUPP; + } + +#ifndef CONFIG_NTFS3_LZX_XPRESS + if (ni->ni_flags & NI_FLAG_COMPRESSED_MASK) { + ntfs_inode_warn( + inode, + "activate CONFIG_NTFS3_LZX_XPRESS to read external compressed files"); + return -EOPNOTSUPP; + } +#endif + + if (is_dedup(ni)) { + ntfs_inode_warn(inode, "read deduplicated not supported"); + return -EOPNOTSUPP; + } + + return generic_file_splice_read(in, ppos, pipe, len, flags); +} + /* * ntfs_get_frame_pages * @@ -1159,7 +1188,7 @@ const struct file_operations ntfs_file_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = ntfs_compat_ioctl, #endif - .splice_read = generic_file_splice_read, + .splice_read = ntfs_file_splice_read, .mmap = ntfs_file_mmap, .open = ntfs_file_open, .fsync = generic_file_fsync, From patchwork Mon May 22 13:50:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250603 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 DC822C7EE29 for ; Mon, 22 May 2023 13:52:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0DCF900006; Mon, 22 May 2023 09:52:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC27D28000D; Mon, 22 May 2023 09:52:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B301900006; Mon, 22 May 2023 09:52:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6728428000D for ; Mon, 22 May 2023 09:52:02 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 436A3A01E5 for ; Mon, 22 May 2023 13:52:02 +0000 (UTC) X-FDA: 80818029684.16.595D960 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 657D3A000E for ; Mon, 22 May 2023 13:51:59 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NCpiZNvf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684763519; 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=WTfdYshb2SEJ7i+Rhr+GK9rq0gZ3nIJZ8Q96oyv400s=; b=8N/6c5G5PgwZUMjvZ/8roWuPb0uXsqscN9JVnolziia6xKStPc1Sd6kjFtjYvcfJGuJHBk zu12XzLfqS9ff92Xz6j5m8EG1aKAhlATHBq6mL00Zec9g3uLI4MNZ79LkkLMaJVwQE7wxx qTgm58bVf45rJaYuboTjlvCAB4P670o= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NCpiZNvf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763519; a=rsa-sha256; cv=none; b=J4EYt9EbB1rFglyO4Sx29Smb/OzuUbU7RjsGzfvyI/Uje3Sw/hQ91Ei0rme2yRJGFw3Qab T3wATLTHiXD2XhXxNoAnGXoFhQ4TRFSlAz1dRLfZ1lvpo/7luLqiXq8C+knri8xKnXlB5J bZGAsPk6nhtQX/l1IVx1d3I2AC33uP8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763518; 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=WTfdYshb2SEJ7i+Rhr+GK9rq0gZ3nIJZ8Q96oyv400s=; b=NCpiZNvfK/g2Wp6M5Wd2td/2uTMCV5f9UR1kRF9SbqG+lL0xSDuzR3N2DY72fZU9iupiDa 7j9zXPiMbyrRVKX0nhqRvkVx3tA9wI8XnjFPOnWtU5NVRwRlEE4fU9owXscHs5k9gSMZ1P I6TeE00ytsNmNXF+zah9w4Nl+2pqong= 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-610-VqXNS97OMu6rkAXf15s6Mg-1; Mon, 22 May 2023 09:51:53 -0400 X-MC-Unique: VqXNS97OMu6rkAXf15s6Mg-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 684713C025AD; Mon, 22 May 2023 13:51:52 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43402400F17; Mon, 22 May 2023 13:51:49 +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, Joseph Qi , Christoph Hellwig , Mark Fasheh , Joel Becker , ocfs2-devel@oss.oracle.com Subject: [PATCH v22 22/31] ocfs2: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:09 +0100 Message-Id: <20230522135018.2742245-23-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.9 X-Rspamd-Queue-Id: 657D3A000E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 1ia9gyfe46i99ofcuqujoujob1bshnrs X-HE-Tag: 1684763519-723220 X-HE-Meta: U2FsdGVkX19zuSnJOoexz2Q424TVdWr0R4Me0YKNB7PN0pFk0Ad0lpHdPuAn6q6uuOjHu0k6p/gzB4+JtlvyCNiwphU0kYN2cfXcz3LZyy3UD66YiRvffjjsrtDakgU8H2AurOnk9v9Lvyo/kHQZ63WRWn+/PXG0tsLHYDCPEQkUFulkGFikWtVsh/ePOga9Fg2KjKjWe/Ajk1D+LAGVNvu3WyBpIv9j5+Sln7/GP9NnR+CLs/yv5cYUitB1MEJ6d44Z4THfFAH89fJGvzbuXHz+0nmdzWjO8eRWBd6vphoJqLO/07dDfO532HSwJjWvltQKD9yexqY+0ELqdl6gZPWtNSvMfoxfrQl+9CGrsV/VgavsVIPAiLBkGh/DR5WpH0OCHBscmxXVEsbyMAqxNyZ6uKQSj4rnhFchpH/gUUntYGtnMgiqkv+BXsu0iWaT12bcRxhrBEAum8gOyi5jx4x8REQqDzofqI+ABjr1ATqtXd9oRltuywGxA+Knx5mpaLr8jeF7aZz8/BFytW0jSb3YtwRg9Uc7vUt6RNzNM8b36+Zl8FU1puSXv3yExB3P93s4bK2jxy0/nE3J8jepRx2iaH5v2AJCsUyj93TDZgQAIJ6R37ShuxWlnzuLooCMKlCtUvMURvVQdZis9saDuRZIr9DUeHccQqbPD49G1ip6JAlEVc6zNJyGmqtE+IQWunyccyIj6iwQwKWszs5J7w0T7SILgho6px984iFvgkP+tPvWr3Ytg+K3p02PxGW0pM9n1BG9nNTnvzKmfzKJqDfmdiBE+GklDXynUdJ/8m5vjpvVdf04c9scfrV7JjcdzVt3hwzwnIE+JKOWXeXERMUvf5zkhUR3DEUtV+uOOJ5Mfu2AN/XFera+zSAMdwmsZqsVdCWusTJFjpH41/E3Bmo7sMuwe0BVMVT990DoUlmWoriktt9VsTT04IOgkjHKrfRkfQtYkhJxDpDTUjk SPgFN166 Y3AC4TZFGIPLfneY+ppI7rSMytYrxUA+v18Z2mcT2ldJBzgpk5HINwbuhpF0hy9WiyIzFODvftjP6eim+6UMu2SfzVHgkjnny4Kps7L6kMUV0GdX4k9OG8DoPQ1xT3xbsfB8//JHyEgYKxlRS9i6ZsS/f+fJ7RF4eI+2XGxTyslBr6Sgt/0rUYG5PQawwl4A86KmGG8T3PukXqgLpdejXGPO8wbTZ9l5OJG5+gLKZHyupSaey5I+1/DvRb/L3s6WqjR1uw+dxGSx+qNqaKAXO1ASdCQsS1Oc0z7vRAQxX57J1uRJeYBGrGbn7wD2+AeenlCjRjeA45tGADzkmKtBdYiodbxgD+rs01A4LHF4HurYbIppOAYRKUR37LWOZSYx6ULOyswDQn4Qqm3YHiPE71JPwNfviRtClgeFZZDV8CZqh2qD31fb3all2cst+sNZOhE7OGgK4RnrNo55RlUKiMFclzAUAuRoK3agITleh9wa4rhsy+4cp3OhztRtcg2cl1WoPLiGrqUHATdQ= 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 ocfs2. This emits trace lines and does an atime lock/update before calling filemap_splice_read(). Splicing from direct I/O is handled by the caller. A couple of new tracepoints are added for this purpose. Signed-off-by: David Howells Reviewed-by: Joseph Qi cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Mark Fasheh cc: Joel Becker cc: ocfs2-devel@oss.oracle.com cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #22: - Adjust a couple of comments mentioning generic_file_splice_read(). - Pass 1 to ocfs2_inode_lock_atomic() rather than true. - Pass the splice flags into the tracepoint. fs/ocfs2/file.c | 41 +++++++++++++++++++++++++++++++++++++++-- fs/ocfs2/ocfs2_trace.h | 3 +++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index efb09de4343d..86add13b5f23 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2552,7 +2552,7 @@ static ssize_t ocfs2_file_read_iter(struct kiocb *iocb, * * Take and drop the meta data lock to update inode fields * like i_size. This allows the checks down below - * generic_file_read_iter() a chance of actually working. + * copy_splice_read() a chance of actually working. */ ret = ocfs2_inode_lock_atime(inode, filp->f_path.mnt, &lock_level, !nowait); @@ -2581,6 +2581,43 @@ static ssize_t ocfs2_file_read_iter(struct kiocb *iocb, return ret; } +static ssize_t ocfs2_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + ssize_t ret = 0; + int lock_level = 0; + + trace_ocfs2_file_splice_read(inode, in, in->f_path.dentry, + (unsigned long long)OCFS2_I(inode)->ip_blkno, + in->f_path.dentry->d_name.len, + in->f_path.dentry->d_name.name, + flags); + + /* + * We're fine letting folks race truncates and extending writes with + * read across the cluster, just like they can locally. Hence no + * rw_lock during read. + * + * Take and drop the meta data lock to update inode fields like i_size. + * This allows the checks down below filemap_splice_read() a chance of + * actually working. + */ + ret = ocfs2_inode_lock_atime(inode, in->f_path.mnt, &lock_level, 1); + if (ret < 0) { + if (ret != -EAGAIN) + mlog_errno(ret); + goto bail; + } + ocfs2_inode_unlock(inode, lock_level); + + ret = filemap_splice_read(in, ppos, pipe, len, flags); + trace_filemap_splice_read_ret(ret); +bail: + return ret; +} + /* Refer generic_file_llseek_unlocked() */ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence) { @@ -2744,7 +2781,7 @@ const struct file_operations ocfs2_fops = { #endif .lock = ocfs2_lock, .flock = ocfs2_flock, - .splice_read = generic_file_splice_read, + .splice_read = ocfs2_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, .remap_file_range = ocfs2_remap_file_range, diff --git a/fs/ocfs2/ocfs2_trace.h b/fs/ocfs2/ocfs2_trace.h index dc4bce1649c1..b8c3d1702076 100644 --- a/fs/ocfs2/ocfs2_trace.h +++ b/fs/ocfs2/ocfs2_trace.h @@ -1319,6 +1319,8 @@ DEFINE_OCFS2_FILE_OPS(ocfs2_file_splice_write); DEFINE_OCFS2_FILE_OPS(ocfs2_file_read_iter); +DEFINE_OCFS2_FILE_OPS(ocfs2_file_splice_read); + DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_truncate_file); DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_truncate_file_error); @@ -1470,6 +1472,7 @@ TRACE_EVENT(ocfs2_prepare_inode_for_write, ); DEFINE_OCFS2_INT_EVENT(generic_file_read_iter_ret); +DEFINE_OCFS2_INT_EVENT(filemap_splice_read_ret); /* End of trace events for fs/ocfs2/file.c. */ From patchwork Mon May 22 13:50:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250602 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 E34D6C77B73 for ; Mon, 22 May 2023 13:52:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BF60900008; Mon, 22 May 2023 09:52:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7624428000E; Mon, 22 May 2023 09:52:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DC91900008; Mon, 22 May 2023 09:52:02 -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 502D9900006 for ; Mon, 22 May 2023 09:52:02 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 253AC4020D for ; Mon, 22 May 2023 13:52:02 +0000 (UTC) X-FDA: 80818029684.17.E05517E 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 58EC6C0008 for ; Mon, 22 May 2023 13:51:59 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rm+uqknd; 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=1684763519; 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=d05WbB8biEgCD4p+OO2LDaxF6v/UDORhO7ObNrAbhyo=; b=s1G15xZu+Az/ad4JJZx7T5LdtclieBVYrO/ePweb+Nz1drMgy0Lp2qKi9k/7AI1q8H0sDg 6ZpYkfAKPVOjZslvBz0+UJJYokwbi+uDhVczQuS4Uf1hBQv0NTeb+7S0tqcHVxrXH6fMSD vW5c+zWbRIHaY3S+wYi4JGJToCQaQeI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rm+uqknd; 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=1684763519; a=rsa-sha256; cv=none; b=dtZmkVpRrLQTtjkIiDehZYPDZ1YRxNfm/NNwglhradd7rwSKGgUcTk2IFkKBy4Nx/PAXUa +GATBMzMhUmdyv2Z5EIJipB9hiZXrL/PIXYVNzIiXLXqefJGxiQTjn3q7Cj1XyRjwF/0Bp ZpoxNWyUy64CoF/23zewSJzb4REP1Rk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763518; 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=d05WbB8biEgCD4p+OO2LDaxF6v/UDORhO7ObNrAbhyo=; b=Rm+uqkndABUsJMSZbwJtTWM+ieBQLrGbLdya4GmwbimO23DAxi+5yNrlmtNur1v8zvqwI5 DVXFpvkUoYvn9eDCgHkozPQFi2l0gIDnVqeQjKH4QIMrPntUZEHDlqVCxFCS2peCPLJUW9 +ubpqxO7tP7bbjcrQbI1zblmVTXrfbw= 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-449-TCrleTLlPQazmOU7dZvwBg-1; Mon, 22 May 2023 09:51:57 -0400 X-MC-Unique: TCrleTLlPQazmOU7dZvwBg-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 1AF63185A793; Mon, 22 May 2023 13:51:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3119D140E95D; Mon, 22 May 2023 13:51:53 +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 , Mike Marshall , Martin Brandenburg , devel@lists.orangefs.org Subject: [PATCH v22 23/31] orangefs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:10 +0100 Message-Id: <20230522135018.2742245-24-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.7 X-Rspamd-Queue-Id: 58EC6C0008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xbjdjy7ub3o4f9tkbie3ew45mpk796hh X-HE-Tag: 1684763519-804808 X-HE-Meta: U2FsdGVkX18Rp1TcotYu4ir0CpjaaXXxQtSqIXnTwJMae8h44VR71nYnMmdIL/7ZvjOBIJrydMczRYdwk29LX3qoHW1EaGz0VEGv6rfzMOAhutkDjYlaZGYpjqYMbAKGzJGKLQHh4FyrB8SzRILRvVr3/e144L1hur3I1vnDX3atd7XxkOY2/x970Cgsoq+1xg6lo3fKsAPfqjBtRhraC7CENSi9CutwicwCqapzPNaReQ9TCqm7vj9QPMCFrX5FABCgGqFG2KtQhAs5imGOqExpxWvzmnGZNSreCyX7kJEVF3pGyeUJEBnhMGMyUtUYEB6wLtPrt4YtwwhLxdya88kZcrpM5SJfzLhUOMUJ/krWeoXF2JBol+wNpHf8D0fz2Q6B+Iq5p3/1qVFfADmLswMSzbFJUgZnZpYxkhmsHMGVuDOXa6uDFJ2mjHY8PfM8jKbSwSbTs2ClCzOci0d2WNMMac3bq5Zsj2uT/XDdzLMUWP06rC7PZP8a3NP5ZXBuMMIlgPNuNxWsbLSRve9YlIiAjNZsXbV0/lQJB3ke5NA9ksfOB5I8jR0Fn+fYPnQEKnHJDlLcIXJRAkYv3C89iP9p80sqVtT/IBRrCUCm6431jRB/uoX9nd3fiwxRRDQvIwNrgiD47JpVfgnYvRodjMBvpA9gzDWWoQ/FAwSudiMnT6CMXDAQJ3IQksDJES3Beqt6rhoiz/QwVN5sOZy3ifQb5zPa8uu5XQRjHz6iYZP7cd7WKRNjU+abI4jbCabQWLF6wZBjNVWV/IUkNf/3jHiMgXSRQ96Ncx5+WApocRte9xjnKjlLsK0KIbgsfutbZ0UBhUMOxElc7rPdybw/6ir42Ra8zR+kPIUfjb/FOH2uJ9Dxflk4PCRnIty93rhtq5UnaWcC/zz9u5fqxDTjswWnP1IgQOYaJ9N3nHk2hGVZPXho3c9LXAHnD8VmpJyf2NdJ5upt43yi+dTeWlH mg2gLSKa b8A4QdIZyyKnP7raHZXNce4+VO0Ws468vTU2QZn4NTrXPljWSTmZqLpWdgD3BuEwJqBuD+gxBjygziBFlfPh2bcDtFiAINm00I5RXhyR5EXKWSRcngepO2E+DUPUWxTc9xa8/MlTD0tewzKM9mzLrWl0EgP9riBbrgOQZCaKCEfFPXwghh2+l/OYL0vll2KYSy/notrKSKdmdDQrY+4YuCSqR68mcHbA78ZfXQfySnC+uyaAHjOVv69L89i8pBLiIvY/pGAegRXG+tfAbVaEomU19cAVtPRLEGpKGgCnvzGgTJC3UGKzyNgEGov3tmdYzea8HzhEmc/31aFeYceen9ahQjlahDwEvIJU9h4ty7VVNjhT3X53XNWRQ1Waw5YFdJNRL9mzwuAw1Z23JzUS5peqcrYnKice6i1JYe7UGzJnzqq1Xj5l1jhkm4ZXw0VxaOtJ8CVFA7+S45naBA1PRieyuzQ== 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 ocfs2. This increments the read stats and then locks the inode across the call to filemap_splice_read() and a revalidation of the mapping. Splicing from direct I/O is done by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Mike Marshall cc: Martin Brandenburg cc: devel@lists.orangefs.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/orangefs/file.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index 1a4301a38aa7..d68372241b30 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -337,6 +337,26 @@ static ssize_t orangefs_file_read_iter(struct kiocb *iocb, return ret; } +static ssize_t orangefs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + ssize_t ret; + + orangefs_stats.reads++; + + down_read(&inode->i_rwsem); + ret = orangefs_revalidate_mapping(inode); + if (ret) + goto out; + + ret = filemap_splice_read(in, ppos, pipe, len, flags); +out: + up_read(&inode->i_rwsem); + return ret; +} + static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) { @@ -556,7 +576,7 @@ const struct file_operations orangefs_file_operations = { .lock = orangefs_lock, .mmap = orangefs_file_mmap, .open = generic_file_open, - .splice_read = generic_file_splice_read, + .splice_read = orangefs_file_splice_read, .splice_write = iter_file_splice_write, .flush = orangefs_flush, .release = orangefs_file_release, From patchwork Mon May 22 13:50:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250604 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 B70B1C77B73 for ; Mon, 22 May 2023 13:52:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 542AC280003; Mon, 22 May 2023 09:52:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CB22900009; Mon, 22 May 2023 09:52:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36B95280003; Mon, 22 May 2023 09:52:09 -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 24E28900009 for ; Mon, 22 May 2023 09:52:09 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0434F1A0316 for ; Mon, 22 May 2023 13:52:08 +0000 (UTC) X-FDA: 80818029978.30.892B8DB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 03AE420008 for ; Mon, 22 May 2023 13:52:06 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eeuf81vB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684763527; 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=bTH/u0/6vAI7mUHy6uOE6ZiziK/p6ayAtCwTfEo/gpA=; b=DiWZLMcPzkUkUUy1rb4oiEm6D0XsKC61Tm3YCsiM6Ad9FLj0PMODPt5AurveOSQtkXpKQi apWKsBaTT4fKn/B1djbQpuXQAe1gv3SBGjDtbrdePnmE931inxUlSGSVs3Dv1DEeFOqs0X c0qvomSKLUO1mrApS2xY18gVtTtwt24= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eeuf81vB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763527; a=rsa-sha256; cv=none; b=ydW6zOeUPAuaT5joCTJb0qXa63/2TMk4eCA6UqwZFkNz/u2MbaobsudqS3AAR7Q73Qvdtl U/ADt9m1ZOVGFMu60BeL4d5WnFJVADAe1M9wDyE/YC57+LAvQCTxHDSB0M2J6sTtyqBddd rBZ+sl9KCykstOlqmsZIBtruDFOsbXI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763526; 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=bTH/u0/6vAI7mUHy6uOE6ZiziK/p6ayAtCwTfEo/gpA=; b=eeuf81vBlZRK5qXahAmSqE1ndrFa1qvNsFvUmiQGTVP63zR/fwtrDhBZidcTc7dVBAhhAW H11dkuKK+idHTNpkcsEsZU6e8jaa4mXcuumWR94QXoaYkvCKq998bWyJexWdjGC3qfLXIN 7DioAHH7LSRDeuizm5Q/PF6hwbLZgOc= 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-390-LkkvV9wzPveIVTI4AlkknA-1; Mon, 22 May 2023 09:52:00 -0400 X-MC-Unique: LkkvV9wzPveIVTI4AlkknA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9EEC81C01512; Mon, 22 May 2023 13:51:59 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id E87EA20296C6; Mon, 22 May 2023 13:51:56 +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 , "Darrick J . Wong" , linux-xfs@vger.kernel.org Subject: [PATCH v22 24/31] xfs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:11 +0100 Message-Id: <20230522135018.2742245-25-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.4 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 03AE420008 X-Stat-Signature: 7aepofpomyoqc1ehsjq645oaz5o5bjdx X-HE-Tag: 1684763526-680375 X-HE-Meta: U2FsdGVkX1+RK4lTuDZP4FoUOXRACK1BCzufNb5WweBex1dC2iTs3V8SuTHwNxJBgGPEFWbD5AfbgRjjYVGW+MMKLe9WrDzvhXonKQ+BkFhW5LEDLPSUgkQTlYt7APO10q+VUVbHUduP7siOF5HtyNd/hhxcvnTlfVGE+nrY9VSzBGaoeJLNXnMw/EJrVOqC8C4VPEPaTgb6GeYxTGNhmtXeqy0q54NUGZULFCy/jFzIvj0uU8HIN4nudxx+K6oERaHZX90uhSuUhkSFn/+C6toJzilTqajoK+V1mTVWRtD/EPVKRBQ5Zn+0bQolY4FHa9la/0rQ7llu9iMjjP5KARh0NIzF4b2LY9JUCKfPhLRMSoIvm2gP74Qt6CNxoYIvIg0+rd0EOpYaucFu7U5AoDBQvGAwPsqqDYulT3pJs4JOoVdLOWRFhTeWN4L3+/aUTg4FjhFvL4iwt4JFYedsuykvk5iLNiW6mNA/qK/Nr0o6JP3woRdp49hthUb1exiv2gLSYyiUNcccRLqdPf1BAfe21Cr/CV6qed7p/B1tOikWrojjxVmGYvzZHdGj9jUR/XydYizM7PKmcYzPkKahgFIAjpJLz95e4nGu/UcvKVP+7XoHC2LskgKpIPymmirGRKuwur1HiLtae93I+ULQNNqTV0deHL9ZfcdpIqGjVoM2sPhTv2n9erUItrYFvDOmd9yFMOAB3euTt6cAiDhuPQjaR6ccDyYSKxvrtS1sbeMafpgTO2/ds2wxG0XlUwyk6bOST9aJaTotnsmQf6o9X7fJtm/rdnf5QCp14DE7emW/g+qlw52lC7PZrWHiqd71PK37cHsJpZ2Z4HUospmyKSWQ9jIuCyMLBQ9RxX5+yblV5bZzKH6dEFsByYbuykegGgQvkB0AJMQa8rV1L6Sf4ru2vz0mopITKmIKXurkznI+nraNsRkkhd/YpeXVoKB14J0VJ/h0BmNMmB1xq8l q6MLx/P8 qIeXU5K2rF7c4z9V34ZAQdNjuHG8u7AEvhkYGkCvD4zRCy3ZVwPMPoszwuQFeNpv3tYckfk0uaIH9/LgQg7g+pAXOrhMXxQFqnGcD2NkavrlVgQhBhlHqbwe41rfR4sRYf6ZZO1zRpyEHZA3xSRqDvVvLk37fsNa2jb88b3qWxXP3xzhilKe0S824hEAWmu0EBkQ3kETzrLJ0JqUxTj3RqIFes1uzzgN+kRXtOe6980ipHrsxmOSJ2qppQ8OZRhgxKGmfVbVGCABBOCfg+uLScDiCDfvDaGTghgxulYAKKV7GIkrC0EDPvDMGVVtFPhKOvYIjvDgaMFqLxrnadXbi0ZKHo8XXqwbsoa4Y 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 XFS. This does a stat count and a shutdown check before proceeding, then emits a new trace line and locks the inode across the call to filemap_splice_read() and adds to the stats afterwards. Splicing from direct I/O or DAX is handled by the caller. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Darrick J. Wong cc: linux-xfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/xfs/xfs_file.c | 30 +++++++++++++++++++++++++++++- fs/xfs/xfs_trace.h | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index aede746541f8..08d632668e94 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -306,6 +306,34 @@ xfs_file_read_iter( return ret; } +STATIC ssize_t +xfs_file_splice_read( + struct file *in, + loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, + unsigned int flags) +{ + struct inode *inode = file_inode(in); + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + ssize_t ret = 0; + + XFS_STATS_INC(mp, xs_read_calls); + + if (xfs_is_shutdown(mp)) + return -EIO; + + trace_xfs_file_splice_read(ip, *ppos, len); + + xfs_ilock(ip, XFS_IOLOCK_SHARED); + ret = filemap_splice_read(in, ppos, pipe, len, flags); + xfs_iunlock(ip, XFS_IOLOCK_SHARED); + if (ret > 0) + XFS_STATS_ADD(mp, xs_read_bytes, ret); + return ret; +} + /* * Common pre-write limit and setup checks. * @@ -1423,7 +1451,7 @@ const struct file_operations xfs_file_operations = { .llseek = xfs_file_llseek, .read_iter = xfs_file_read_iter, .write_iter = xfs_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = xfs_file_splice_read, .splice_write = iter_file_splice_write, .iopoll = iocb_bio_iopoll, .unlocked_ioctl = xfs_file_ioctl, diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index cd4ca5b1fcb0..4db669203149 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1445,7 +1445,6 @@ DEFINE_RW_EVENT(xfs_file_direct_write); DEFINE_RW_EVENT(xfs_file_dax_write); DEFINE_RW_EVENT(xfs_reflink_bounce_dio_write); - DECLARE_EVENT_CLASS(xfs_imap_class, TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count, int whichfork, struct xfs_bmbt_irec *irec), @@ -1535,6 +1534,7 @@ DEFINE_SIMPLE_IO_EVENT(xfs_zero_eof); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_unwritten); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_append); +DEFINE_SIMPLE_IO_EVENT(xfs_file_splice_read); DECLARE_EVENT_CLASS(xfs_itrunc_class, TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), From patchwork Mon May 22 13:50:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250606 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 6947FC77B73 for ; Mon, 22 May 2023 13:52:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B8AE90000A; Mon, 22 May 2023 09:52:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 567D5900009; Mon, 22 May 2023 09:52:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42EFD90000A; Mon, 22 May 2023 09:52:12 -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 32F4B900009 for ; Mon, 22 May 2023 09:52:12 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0F858160339 for ; Mon, 22 May 2023 13:52:12 +0000 (UTC) X-FDA: 80818030104.04.6A148E3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 42CEB40002 for ; Mon, 22 May 2023 13:52:10 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JnhAUDcZ; spf=pass (imf04.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=1684763530; 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=OLusLo/oJVdzYA8d4lrkdkImz1Qgxj15rb4H8i/2VAY=; b=OaclAwgnDnhF6VfFNT1wvc229iZPTVWwVudCTb01NPgboKd8I6DI/GpDq3BgXGvfCj7orp hKULJtbFaMPKaLrtvuT2gdGMS/s3lF4+iPrgDx53VNdWWLG94xlsRnW01MKW8B/DWsMnwE dIDSKf9jPmBSyMc1RrYwrGYPI2MzplA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763530; a=rsa-sha256; cv=none; b=NyYM8Si/q0OdUaK+RB0cBzpoNLaL4AqqznhFg4sWb5fnWG0QdCVR27a59uhmQNFua8rxkp CDu5n6+SZmR1oOJYZsiRRQ6VRH6cRcO/UIeDCH90GqqrzbUeM+aMvdjcSedNypohD8yZw7 slfOTQvJw+I+Y2cRMTmKKJiFW3howvQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JnhAUDcZ; spf=pass (imf04.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=1684763529; 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=OLusLo/oJVdzYA8d4lrkdkImz1Qgxj15rb4H8i/2VAY=; b=JnhAUDcZxuLinwN/Wu5OgsbgAzvh13nZCRWb4tB3oU/ClCKf3yHNz4/LQIc1vN/tFHBWOS 6GEAnSqcHm71m9etSdymI5HOtJrE9y9XkLewxdvAd0i/0pveUtgC/CmNNCnpOa6sjODLop QuTbNJFA80ykdyv+7t1Mf+1CEdAHiR4= 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-339-o_R015-QO0ynOKyBDFSucg-1; Mon, 22 May 2023 09:52:04 -0400 X-MC-Unique: o_R015-QO0ynOKyBDFSucg-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 324E22811BCA; Mon, 22 May 2023 13:52:03 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58841400F17; Mon, 22 May 2023 13:52:00 +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 , "Darrick J . Wong" , linux-xfs@vger.kernel.org Subject: [PATCH v22 25/31] zonefs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:12 +0100 Message-Id: <20230522135018.2742245-26-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.9 X-Stat-Signature: ke4nr64wehk1o3qqhk8uzsfceb76k4xd X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 42CEB40002 X-Rspam-User: X-HE-Tag: 1684763530-414350 X-HE-Meta: U2FsdGVkX1/3zt38X5Dx0npkNMRXLavozJ8Yicfas9zw0kOBFuHfaiyoljUhHz8m781D1NKLMl6YHVbUFsPPe28b3nIxDMwoClnMMptI/nuI7Um18rryEeoFehdMPD8nipsFK26GXFuBmhzBCgXHwxdT/IEAkmTqqUUEoA1YgJrsgZmzdyb/AlSmtpOOB5a+ngDLOmnp1f66rqO+4eVWT4h+d0KlAJtA5FRZ9qqvJec34Yq3j6B21Y+exUUyircoItwrHSjecOBHOf3fxKtwdHSs0zP3rsEJt8HnZmHdWP4I/VBpaRQzRaxkKdmgIBkrZxQmcIzFVAjOqNoRsJuxyalDxPG72MAeAJMzuzJAaDJRLuUexlskYs2iCF6XvWjODgQxMahMKI8PWckvSIfCOxnsZO+DNefNdUlsJlbHUItw55mp7TCzQ/piAMCrqC4pDXbg5lK1gJ1ewivhVkQKSD1M8XCEzplVEGvEqr4a7LWOROH/pwQwtBQj+WlCLvXWcfhQus4/2CeHgxa/6SQ97+XuFFb/ZOBRoUzjgzc4RkMNW16J0TTliI/7fTbGlwqc0xx5wwbyb671ZuYyjH8CbU5AProJw8WK4P6Q551wqoZx6eMvyIpiGIxY0I8MMCPSaEuOk2uW1xKxJwB0u/RHV6u2YIpXBQhBoa9Uu14nqTEDVJqJe5NkI+PXsF/hdSqjJu2fLCmtfztMZD2my/oncAEEiYdD3q2e0Ib1anY1HfVAbtrc6WnwQxAz7kiRLEOVU+StSetdpJzanro0Hz8orc+mcRmS1ApnNnQ6vlevo82n0z4gGO4+ah2X1VtdPtuZMKtSR1qwD+TA0eRP/yip3pHg603mFgexE9BVYp8VjPqb0AxOAQh/FrqOB0feoQIFYkCQ75mrHtyhv0VCIA6+I7Ahd6cMJL8k746WxDwTYWBfFPQMHGCMcZpymF2Cufl/OaEtIW9BoYGrbpxietU Nk2/7InT 4QPBagM2eiCEnnGSffyastXJXQlSojRDtm6GGfAQr1qSaTCtk3HkDOQGbcnAi6Ctutbnok2K/OYyJR/ic9XTZ2tYglwh50TECjaQ40pD9oMy0acnnrfd3t6FCK0kjp3qqsiP+EE6+2nRfA85CiyLD6lEMPJ/DGyRWXcYYcvyDxEgJMCj5sqgDQjZU8d4kT8UQMx2mNKv57umFckhurMatBQR0gxIsHZyy44ThH1XEey+GkgFQQzSwZvGLu1GtuTdrxfe0sN7Pn176spfnmpmDxJIpXwfg4yoUHxNwM06nCRC1oAY1/1EzxpmmswUb9G9iYMVNiSNVLWzz9EVqJ7cQigjjQTwipbq9YpKa 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 zonefs. This does some checks before proceeding and locks the inode across the call to filemap_splice_read() and a size check in case of truncation. Splicing from direct I/O is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Darrick J. Wong cc: linux-xfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org Acked-by: Damien Le Moal --- fs/zonefs/file.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c index 132f01d3461f..65d4c4fe6364 100644 --- a/fs/zonefs/file.c +++ b/fs/zonefs/file.c @@ -752,6 +752,44 @@ static ssize_t zonefs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +static ssize_t zonefs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = file_inode(in); + struct zonefs_inode_info *zi = ZONEFS_I(inode); + struct zonefs_zone *z = zonefs_inode_zone(inode); + loff_t isize; + ssize_t ret = 0; + + /* Offline zones cannot be read */ + if (unlikely(IS_IMMUTABLE(inode) && !(inode->i_mode & 0777))) + return -EPERM; + + if (*ppos >= z->z_capacity) + return 0; + + inode_lock_shared(inode); + + /* Limit read operations to written data */ + mutex_lock(&zi->i_truncate_mutex); + isize = i_size_read(inode); + if (*ppos >= isize) + len = 0; + else + len = min_t(loff_t, len, isize - *ppos); + mutex_unlock(&zi->i_truncate_mutex); + + if (len > 0) { + ret = filemap_splice_read(in, ppos, pipe, len, flags); + if (ret == -EIO) + zonefs_io_error(inode, false); + } + + inode_unlock_shared(inode); + return ret; +} + /* * Write open accounting is done only for sequential files. */ @@ -896,7 +934,7 @@ const struct file_operations zonefs_file_operations = { .llseek = zonefs_file_llseek, .read_iter = zonefs_file_read_iter, .write_iter = zonefs_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = zonefs_file_splice_read, .splice_write = iter_file_splice_write, .iopoll = iocb_bio_iopoll, }; From patchwork Mon May 22 13:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250605 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 591FCC7EE2E for ; Mon, 22 May 2023 13:52:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9203280004; Mon, 22 May 2023 09:52:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E195C900009; Mon, 22 May 2023 09:52:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE15C90000A; Mon, 22 May 2023 09:52:11 -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 BE135900009 for ; Mon, 22 May 2023 09:52:11 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8BF184026D for ; Mon, 22 May 2023 13:52:11 +0000 (UTC) X-FDA: 80818030062.14.BD63084 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id D54DC160019 for ; Mon, 22 May 2023 13:52:09 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LRyYCHUy; spf=pass (imf08.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=1684763529; 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=HfMcLqK7SdZvPGZvy5b2RGzipVUrB/qFQK+4kiqdRos=; b=pkboapna9dkv4pwq6MPO1dCpC5CGqt4k1RmbuwdmD9tcj9gyIFoyq3tfHY4gyQ/1Hiuddc 7GONCngD/yZUou3xDCJo64ukSyQi9r7ESWXGMBZRVVEZgrFoidzo7MyNQRb0qmw9DunBMd fHo+pxAVNn2XQFbca14v24ldbC3Qfh0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763529; a=rsa-sha256; cv=none; b=qq8YePEZWL4aAZDeBK5Z5W1Tb9tVY7IavmBsXiaMmJNirmGuLAUQtRijdcOutlPFv+k89B TayFvv3N3ON36zsmXHSAjDnNiaUjQ6Tck9wbMzLIRr7ofURI5ds/gYo0fEa2zX9szW4dAa URvndP6q2ztsFUnLfpU8Qz239krh3Xs= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LRyYCHUy; spf=pass (imf08.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=1684763529; 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=HfMcLqK7SdZvPGZvy5b2RGzipVUrB/qFQK+4kiqdRos=; b=LRyYCHUyCquNmb69NdXW+xC4OC4Hhwf2Oa0J9O+9SR28Y4mPhunlTwVWBkTsCUYuwZXnvy YJ47Yz7rIJgGTwIGisHP0U7qYIIyTgTcUvn7+0e6i42+fJQaEwCIu73o/kxnJYmz0TL2jX VRsGIAmEY3G6z/u2j8aZxQsAQlY5H+s= 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-652-P98tTMU2PTmMkmG9xXy80A-1; Mon, 22 May 2023 09:52:08 -0400 X-MC-Unique: P98tTMU2PTmMkmG9xXy80A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E8E383C0BE2D; Mon, 22 May 2023 13:52:06 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13CC640C6CD6; Mon, 22 May 2023 13:52:03 +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 , Steven Rostedt , Masami Hiramatsu , linux-trace-kernel@vger.kernel.org Subject: [PATCH v22 26/31] trace: Convert trace/seq to use copy_splice_read() Date: Mon, 22 May 2023 14:50:13 +0100 Message-Id: <20230522135018.2742245-27-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.2 X-Rspamd-Queue-Id: D54DC160019 X-Rspam-User: X-Stat-Signature: xjr1835uxohp731pxr9mze8ha9pet5fn X-Rspamd-Server: rspam03 X-HE-Tag: 1684763529-983496 X-HE-Meta: U2FsdGVkX19+KxFN4mQ8zP40A20eijXjD3EFmmc+kHN/dabRN/y61TnsCFnsRoUU2OZJZ2BNJu/lSmnnkYSohnz79ckNnPR4bNZvwwcE6UAiVKglTX7vkSn8pYt6CVgshWI7Ssv91e+BrJqiCWCp7zMuV04Ew73vKFcXtTOZU5cYMyJV88AQ5FW1S7Wq90TBf+qJZkbgQpqtwuzZUPLfqmfHPP2x73MDXtsLdPy5Ub83d+Ik4lhPRlADyaoDymy3oCfUr2vAN3kma4//AYw5RWLiKUWivUvz7wWFtDuGQ/3yDAVDvctqGM/LTX+bSzQ4AE+vU0BD+ufZcb4nqHcU2OmzanNePjvbUgnecQq/Jg3z01mc+zaYDXMVB9KZS7qqwQNF2BjWxvn0jJxhb0BcyQxxwBk3cZlJ9Csbc+x25sIX7QvR+tzZwoWD1sP7khCt5/8CIE2P3GKolwBI0Y3h7gCGBJ2uBPa6i18bKFW8/r7f+aouAMLk3nkouWkNJX3+JLpF/Cu2mK1LrXz6RW+oG/gIOePVHyLt28blLFlZwJGMeZA7h4FiIzGJeregmQUmRjy8u3d6a6rqTemIcQ6C7Y3x0FdyiEqRfzQVobnO0STVyBR9kZMrgJlMfja19JkxDilUUqQIV0ZQxDKYS6Qj2GS8k1PNSkmYtT6CxbYUtIWjYrdV0kFmC50oHEjQ0eaJuObq64Fq1u3/PgcTaLlRVhRu3P15Eok486b3JJpqJBxycBmqQltpRUt5KcePlmMAfhjzhNR/IvQCDvTxJPGVSAF1cW/rdA/d6IzfSnlL5gu6TTs6QdCJiC2PNKdipLMCDlRLzwoksTuRK1TkZJpkmuqt6GjTksShL6dgEIrD78LtoW8gouSJiDmRFBYe8Z0zype4UeLuomC1iehpEAYltC9fPaPGyknTsaZsep80NatGhvo+HUrXQtst1HWtL84Pl3C9QdnUg/oAZUR3wli Ab4893as 1JXfXRkisHoOdE9p5i7cCaSUzun0gSki++QUg6IbBq/MiPhiwsCbhN/Q1so2zMLmJAtvU1UjLW8qc0OebQY/A0l2+D21IeT86Ml4CICLbLRTh6fkRdWRvTZiUlyzG/MGi4f8vL0AUQW2ecfTwTTyWlVTpPo2XH5aMFTPQfQvZBqLtVvrdH97NlLklmbIpDBrNAdm4AexkmI/pkw6o62EbS+NKz3kopi6ct2RfQ3TE7/+0fmn23TftX61b40lkiHRhLalqHRZ6TN5XnK2Ob5OMN1ALGCPUkooz2OmSAMS/2rH3HDYE8D0zCLceMyWipO2b3yQBt5P4sCDUoN4dOFCwoxOKuNy8alAKOowkBLJBf49ydLMXhUMweDgGUDMi+CDvh02ybUQ5sOvTNx1KkM3Uhx9jMcvCTIeeAiCgJ4mWK04hBn2cQTnKLblBmamkKZbMVqD+yqGEWXpixEo= 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: For the splice from the trace seq buffer, just use copy_splice_read(). In the future, something better can probably be done by gifting pages from seq->buf into the pipe, but that would require changing seq->buf into a vmap over an array of pages. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Steven Rostedt cc: Masami Hiramatsu cc: linux-kernel@vger.kernel.org cc: linux-trace-kernel@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index ebc59781456a..c210d02fac97 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -5171,7 +5171,7 @@ static const struct file_operations tracing_fops = { .open = tracing_open, .read = seq_read, .read_iter = seq_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = copy_splice_read, .write = tracing_write_stub, .llseek = tracing_lseek, .release = tracing_release, From patchwork Mon May 22 13:50:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250607 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 19201C7EE29 for ; Mon, 22 May 2023 13:52:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0DCA90000B; Mon, 22 May 2023 09:52:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABEF9900009; Mon, 22 May 2023 09:52:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 985FE90000B; Mon, 22 May 2023 09:52:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8A218900009 for ; Mon, 22 May 2023 09:52:19 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 61E5F120359 for ; Mon, 22 May 2023 13:52:19 +0000 (UTC) X-FDA: 80818030398.13.2D08019 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id A055314000F for ; Mon, 22 May 2023 13:52:17 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="NOXe/SSe"; spf=pass (imf09.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=1684763537; 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=KS9sZ9kcl+UmAh/rrU1AUBhdO0vlEMJjBaa07cCJK5s=; b=qLv0EMtUjCvYkqDkkgGk2qcko9kk1V0msDTfsVciSZs7hurmDmeSfPnH0Fty11UMF470/U S3+seIyOoAiHMiTAsaTXJAQNYspNIITvnfY8YXaT6y9vDCoOi8OT2noiGDdaihHljtEGQl /q7mhJSPUGgNlXF3n/9Zf5Hg4zNAbAI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763537; a=rsa-sha256; cv=none; b=fITNnlfOQAm9m+N7UtTkqDTsEj3nAPJaYpy75Y+VLe/sjtrTPX5inLupNVyOMzT7EA5U/o dCxDhOupE7FTCqLNCzk5Y49ebuJci7EKClxP+23cBKIK6rbhfY/Ri8SMxNXhXHaLw6viqU ezOQ9dUbUo6/G1yPwXHjzcV5FZ0RfAU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="NOXe/SSe"; spf=pass (imf09.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=1684763536; 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=KS9sZ9kcl+UmAh/rrU1AUBhdO0vlEMJjBaa07cCJK5s=; b=NOXe/SSemjqsmz/1WL2t3LiEyodK60S7rEjKKH+nFTwHcEg6EraqNagGiFwJxHcoq0fKKi Q9ToO/iGvQcCnWkhDlh4OS8MGZAdnHqO4elXk6nsebiPfmI6iNBFdftxNXNvu3rvdrsMvf ea9c2UtVm/k0PRsevGhMSOp2TYWTICA= 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-33-yOayTwe9NkiCRekSvPPumw-1; Mon, 22 May 2023 09:52:11 -0400 X-MC-Unique: yOayTwe9NkiCRekSvPPumw-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 BCAA9802355; Mon, 22 May 2023 13:52:10 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8C11482060; Mon, 22 May 2023 13:52:07 +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 , Paulo Alcantara , Steve French , John Hubbard , linux-cifs@vger.kernel.org Subject: [PATCH v22 27/31] cifs: Use filemap_splice_read() Date: Mon, 22 May 2023 14:50:14 +0100 Message-Id: <20230522135018.2742245-28-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.9 X-Rspamd-Queue-Id: A055314000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: iuqd59dtb5b6dzuicdcnhkmkkq1hjnmg X-HE-Tag: 1684763537-986542 X-HE-Meta: U2FsdGVkX18WWSVZt5p7h0rZpbW89pCf8ceZwzxk+2xwL2f7QmvyPyO5hZhfpMFAjxrts7gs2XGKzErlIae0J/CvlGI0F0OaQZcMqZuyVW1d6b0S5IjqUJJ/cb9/35aAwHJ4/HFX9MX0xAb2VJHWcgrc7y86qEdXoBXUg2VdVQ/pXebLwWC2EZW+iD5TTRHLysyQayHrHoH4Jw4tRChgPV3D9IxEKyYvx9nDBQqYkHb0rCTqWlh0P5PC6Xf/KBE0ssHV63pVi/GmeMCglWFU6g0AQpDlnVFQd7/r4j2iADLYdzco8bdM8MzX6V2JZBgP48aGMtHGatSjS9xtos/xN3Vgf0ZztmNy00XUdmgK8dl22NuKM6lQTybqX4Lyr/xP2p/hZuBxR1Lqnuo1ZoTFmnTaWZQ7fz1p/H8PVJIUqqP+t+jzXasVq2glP6M+lMx2DClSA4xklnlI54A+6lh9fVmKNLPDqVtxtqKKwXmqT7Jb2MoIUsoBdiRAi1ivBzxrz09+C0ncS2TqWW8WKauihqw2EtjWyXxS0sJINL010xdZgYlL+qdTQfIfRHbeIr6nxhYBXc+Fn24YW+27WhtZfQIP9cyM0cKaxWIX5ClHqZKf+AL0fkY1zzU2+1wFmDNhXxbFoKgTnwHGwEWo0vELa/InDSfWSbK9Cxcwt99NClEKdSd7h9rGgAI6l4XLpYvexyWB53jGidcgSfxGzcA1x71Nsi8jb/u/aH8AFp2MUs4ocyr0nA863/s1diByExxKqkcbzxRzHBNWvEH5ht3cSJp+fK6X/v0jJ92WK3SSTnP+X+uXlu2QkrpNUahmp9RLBQz877P7992Qjem7Go53okzMXWYgJLSzwI92oBPrxmfSHXZh3xxZqAcQPHTUxgqhOzebx7/7uOQ+PG3aEkL+jkdCrhk2dH7L4p+e6rRyvY/iaEaDy8iASaT31W/BU9WCoPG6TnLF8NMiOxBAfrZ C2qwWjdS Rx9JLJ57ALq8K5qSXtjklSs/6oTlzIw+QARDXDnzi91sgTc0gx+LcYlr5KCK98MjmAU3iuKZwazUGMYTb4iDJB6tp0e+Ad+YnylKemJjIeMozs3AHa9Cc/8wO5263nmpUxcdWdF8cz4n6ixIQ9JtRpb+gtb3iA5sTwPr5qfhjU8RjzfJUjncas0e+54eIvaDT+z5VKrIgaeGZ7nHHiNtyUnaJfji4Wpd/9+Yn255xgAgUSoRL/FhUJntP1P7d/ctuz8wPqjZPRGMC2d3RpM9/LxDM6EjZz1w2r3dEKEjQM2tvd+D4R4keyNfkRolyBihQrrKKqxAjgUdzmFe9rqnNgcwFnUm/L4gV6qDnvZZGQhzmLl/O/KDeR+9gMOtM443uqJKvsR+oFCUujRIQ08+h8XUu6FuNo2dExEXS9w+UNT0duqVKxMFKbdv/FSc8d8ZzffND14hkvXXeAG0wEgzJKIS0lyldo+VY0gPIZztvm+EXIEStGQxWy+PotT8KI7ai9KGU 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: Make cifs use filemap_splice_read() rather than doing its own version of generic_file_splice_read(). Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Paulo Alcantara (SUSE) cc: Jens Axboe cc: Steve French cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- Notes: ver #21) - Switch to filemap_splice_read() rather than generic_file_splice_read(). ver #20) - Don't remove the export of filemap_splice_read(). ver #18) - Split out from change to generic_file_splice_read(). fs/cifs/cifsfs.c | 8 ++++---- fs/cifs/cifsfs.h | 3 --- fs/cifs/file.c | 16 ---------------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index fa2477bbcc86..4f4492eb975f 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1376,7 +1376,7 @@ const struct file_operations cifs_file_ops = { .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, - .splice_read = cifs_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, @@ -1396,7 +1396,7 @@ const struct file_operations cifs_file_strict_ops = { .fsync = cifs_strict_fsync, .flush = cifs_flush, .mmap = cifs_file_strict_mmap, - .splice_read = cifs_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, @@ -1434,7 +1434,7 @@ const struct file_operations cifs_file_nobrl_ops = { .fsync = cifs_fsync, .flush = cifs_flush, .mmap = cifs_file_mmap, - .splice_read = cifs_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, @@ -1452,7 +1452,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = { .fsync = cifs_strict_fsync, .flush = cifs_flush, .mmap = cifs_file_strict_mmap, - .splice_read = cifs_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 74cd6fafb33e..d7274eefc666 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -100,9 +100,6 @@ extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to); extern ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from); extern ssize_t cifs_direct_writev(struct kiocb *iocb, struct iov_iter *from); extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from); -extern ssize_t cifs_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags); extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock); extern int cifs_lock(struct file *, int, struct file_lock *); extern int cifs_fsync(struct file *, loff_t, loff_t, int); diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 023496207c18..375a8037a3f3 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -5078,19 +5078,3 @@ const struct address_space_operations cifs_addr_ops_smallbuf = { .launder_folio = cifs_launder_folio, .migrate_folio = filemap_migrate_folio, }; - -/* - * Splice data from a file into a pipe. - */ -ssize_t cifs_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags) -{ - if (unlikely(*ppos >= file_inode(in)->i_sb->s_maxbytes)) - return 0; - if (unlikely(!len)) - return 0; - if (in->f_flags & O_DIRECT) - return copy_splice_read(in, ppos, pipe, len, flags); - return filemap_splice_read(in, ppos, pipe, len, flags); -} From patchwork Mon May 22 13:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250608 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 9E29DC7EE2D for ; Mon, 22 May 2023 13:52:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F7D790000C; Mon, 22 May 2023 09:52:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 281D3900009; Mon, 22 May 2023 09:52:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1215590000C; Mon, 22 May 2023 09:52:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 02A79900009 for ; Mon, 22 May 2023 09:52:21 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C7E891402A1 for ; Mon, 22 May 2023 13:52:20 +0000 (UTC) X-FDA: 80818030440.02.EED6EF7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id ECB7A180016 for ; Mon, 22 May 2023 13:52:18 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=evayyPYZ; spf=pass (imf16.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=1684763539; 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=UjNSdKZrHlxBh3wA/Y9ZbKC56elC+Zea+akHU7SRJyo=; b=ksfZDbfqULKxxmZTMPLLHlTcs1EFI2bR92Bk8Mmj1VfiIT07NySCxaVwKbnDRvLOdWAkwr DjVurTr9SaePST3d6OC8g92oZsUDxr6H5Sg8sHO0nc8VFHL9q6yudek+oM9JfJM+ynwNVE rYOLdxDjdZ3njitOHcgepOuuRjGWu+g= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=evayyPYZ; spf=pass (imf16.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763539; a=rsa-sha256; cv=none; b=JXu/6Klym/QDMhBdNnsBh0tFKKOG0TagDkkjVaPN33u1DfZUplbxSq95qd1hGmLMbPnajO K153A0btpQ/EcMlf+pFuOmZsjtujPHiP4M9qWXU5VvjBXptmN8I5pHsd5H73ThXgIsSkAq eLciOgaKf2FlKF0zi6C9FqGowLE7wQQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763538; 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=UjNSdKZrHlxBh3wA/Y9ZbKC56elC+Zea+akHU7SRJyo=; b=evayyPYZISh9CKk5vfV/aTkYNnXFTx4tEQtxurcV+CObZY9GOoC9N8mMIaPYkJFnzj6Oj0 ZzdbTMThG5tPG7JStj/t7c/9DhdZAW9iKZSrQmWZUFzfsolf7/+T2ZsIdj0BjMOXfs2fEO rJulBEPnA2cnFtXv9jW/5D1FaPvsOys= 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-615-F0Xhti4EOvm6lSyMZ6HFgg-1; Mon, 22 May 2023 09:52:15 -0400 X-MC-Unique: F0Xhti4EOvm6lSyMZ6HFgg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4EC1E185A78B; Mon, 22 May 2023 13:52:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92ECD2166B25; Mon, 22 May 2023 13:52:11 +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 , John Hubbard Subject: [PATCH v22 28/31] splice: Use filemap_splice_read() instead of generic_file_splice_read() Date: Mon, 22 May 2023 14:50:15 +0100 Message-Id: <20230522135018.2742245-29-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.6 X-Rspamd-Queue-Id: ECB7A180016 X-Rspam-User: X-Stat-Signature: uuaeqkywnfherwp3zk3cokreic9w98ew X-Rspamd-Server: rspam01 X-HE-Tag: 1684763538-882929 X-HE-Meta: U2FsdGVkX191JpsoSo2qnKANjRFu0c6rYUG3gtvL+T+mjEqEqlFe4xPQMdSl1eZHsmUaXrkI/5ySbsYi51Fz+LQ4tAMqnmPqOGEdxdvjWrsRLUtVF0tONDljZSfy7l+XYwM0+JlfWik2mBotIAMI57tk2ger7RFc9MuNacuRyUPgQ1nQLOz1cw18/KDBwup5uSpXVtbnURSj3mV4gLBfkJG6poMqcP3DS13vQ8hFm/EFlAraeACl/64S/xWY1ltHG90Ax78Wo6fp7+4OWUlLDRzdQ/2VBmJpk/rNvHz3O7D9KB5xmoCiPq6sCdkd9dYtYtFkPSpoQj2sqPyBpta5dNyUO3qje8K90lFWR5BDcSsyMsImopIu3EyRhasf/o/TvG+hRdaikBrjtzprp3GPlJB24A5HZmOR8HGFjz31celFOek/JWnB2dt2vRMt8i8Exy0PwBn2aWsmbPhuaHMCZbv4vdr8saKmSFaD2kDDKEpE3c736tLeEv3ciOy8SsMaYByq6NmoPWzX9qPc1S4H4QncWbAssFTR9XI0OcBn3Vx+DMKroP9k7iANQgTw5tfHWTsX1pHQBKp7n0D3cH3V1JLT9eJ4bpD43eebTk69TkoX+M5DkFz/eD/BqCnT1dDdV6sI60lKHQf5ILXF7bPWSBbdgA3zhy0VdUEX7ylf2QmTzWsNsnHQhbjpMcMRNaRZHxke7E++Wmef2Ld+hocyGLaEjw7G/w7ppxoaBJQ4Cx83muJgl2YWuilZi6t5ePhFE+66+77VkU74RHMbnnkoMi0E+YEZgEldz/pyMifHVar1cIFL3tuJfalEchgKOtuQ+4cLQIR7h5ENXo4rU9NZgUQUu3fuKXqmX2V8c9WB4dWYQ+DWHoIWJCvI7N3bJ5pN2PTKJMznXfnZHxfucv7pYno6XhpwLFTqo3ZszraIDoTplvMW1UcHuVvUOkxKu0kffud6Yw3f160nuzSaAZb I6sko0Lt uQdJ7TfUf2zb9FEasepRtlQvpO2mxqEkj1WZjdqV3e0aIyIXdz5RBFNQv9N3tiIel9u43RDozZ6a6UowFJFOSv+MXCBABg/bBMVLNeU40AUuIjuarx9wvWUNmqHA4AnDsEuJq0kydxMMtKGPR68mBG+11+lRx241XZ9oLrR2eFgAyJ214p74y0WXYcGywqnrZIXAZPc/kWU4VPlZTc8cfgs4LkkbA+RG9c5lUcXcK6fvEHk7gRNxEEPxw7O43QVxK95/UznuOkSLziCmJ71o4W52umw4lykk3vd8bHC4KAexN/Rmh54MVDseMzsoj6fyG+r3j9cVFnTF8YbHVN1rfJMOhJOb25ohcbB8SZCEzVYLIv+kbVGOAfM/n9tqaJyE+uxEqwGpfi4GoKp0HhzSwT2V5dGuh5Q+BJy+Opyko6hbhnIk= 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: Replace pointers to generic_file_splice_read() with calls to filemap_splice_read(). Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- block/fops.c | 2 +- fs/adfs/file.c | 2 +- fs/affs/file.c | 2 +- fs/afs/file.c | 2 +- fs/bfs/file.c | 2 +- fs/btrfs/file.c | 2 +- fs/cramfs/inode.c | 2 +- fs/ecryptfs/file.c | 4 ++-- fs/erofs/data.c | 2 +- fs/exfat/file.c | 2 +- fs/ext2/file.c | 2 +- fs/ext4/file.c | 2 +- fs/fat/file.c | 2 +- fs/fuse/file.c | 2 +- fs/gfs2/file.c | 4 ++-- fs/hfs/inode.c | 2 +- fs/hfsplus/inode.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/file.c | 2 +- fs/jffs2/file.c | 2 +- fs/jfs/file.c | 2 +- fs/minix/file.c | 2 +- fs/nilfs2/file.c | 2 +- fs/ntfs/file.c | 2 +- fs/ntfs3/file.c | 2 +- fs/ocfs2/file.c | 2 +- fs/omfs/file.c | 2 +- fs/ramfs/file-mmu.c | 2 +- fs/ramfs/file-nommu.c | 2 +- fs/read_write.c | 2 +- fs/reiserfs/file.c | 2 +- fs/romfs/mmap-nommu.c | 2 +- fs/sysv/file.c | 2 +- fs/ubifs/file.c | 2 +- fs/udf/file.c | 2 +- fs/ufs/file.c | 2 +- fs/vboxsf/file.c | 2 +- 37 files changed, 39 insertions(+), 39 deletions(-) diff --git a/block/fops.c b/block/fops.c index d2e6be4e3d1c..6c9aa028af6e 100644 --- a/block/fops.c +++ b/block/fops.c @@ -691,7 +691,7 @@ const struct file_operations def_blk_fops = { #ifdef CONFIG_COMPAT .compat_ioctl = compat_blkdev_ioctl, #endif - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fallocate = blkdev_fallocate, }; diff --git a/fs/adfs/file.c b/fs/adfs/file.c index 754afb14a6ff..ee80718aaeec 100644 --- a/fs/adfs/file.c +++ b/fs/adfs/file.c @@ -28,7 +28,7 @@ const struct file_operations adfs_file_operations = { .mmap = generic_file_mmap, .fsync = generic_file_fsync, .write_iter = generic_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; const struct inode_operations adfs_file_inode_operations = { diff --git a/fs/affs/file.c b/fs/affs/file.c index 8daeed31e1af..e43f2f007ac1 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -1001,7 +1001,7 @@ const struct file_operations affs_file_operations = { .open = affs_file_open, .release = affs_file_release, .fsync = affs_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; const struct inode_operations affs_file_inode_operations = { diff --git a/fs/afs/file.c b/fs/afs/file.c index d8a6b09dadf7..d37dd201752b 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -603,5 +603,5 @@ static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos, if (ret < 0) return ret; - return generic_file_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); } diff --git a/fs/bfs/file.c b/fs/bfs/file.c index 57ae5ee6deec..adc2230079c6 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c @@ -27,7 +27,7 @@ const struct file_operations bfs_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; static int bfs_move_block(unsigned long from, unsigned long to, diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index f649647392e0..71426c6408fa 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3825,7 +3825,7 @@ static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) const struct file_operations btrfs_file_operations = { .llseek = btrfs_file_llseek, .read_iter = btrfs_file_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .write_iter = btrfs_file_write_iter, .splice_write = iter_file_splice_write, .mmap = btrfs_file_mmap, diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 006ef68d7ff6..27c6597aa1be 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -473,7 +473,7 @@ static unsigned int cramfs_physmem_mmap_capabilities(struct file *file) static const struct file_operations cramfs_physmem_fops = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .mmap = cramfs_physmem_mmap, #ifndef CONFIG_MMU .get_unmapped_area = cramfs_physmem_get_unmapped_area, diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 284395587be0..ce0a3c5ed0ca 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c @@ -47,7 +47,7 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb, /* * ecryptfs_splice_read_update_atime * - * generic_file_splice_read updates the atime of upper layer inode. But, it + * filemap_splice_read updates the atime of upper layer inode. But, it * doesn't give us a chance to update the atime of the lower layer inode. This * function is a wrapper to generic_file_read. It updates the atime of the * lower level inode if generic_file_read returns without any errors. This is @@ -61,7 +61,7 @@ static ssize_t ecryptfs_splice_read_update_atime(struct file *in, loff_t *ppos, ssize_t rc; const struct path *path; - rc = generic_file_splice_read(in, ppos, pipe, len, flags); + rc = filemap_splice_read(in, ppos, pipe, len, flags); if (rc >= 0) { path = ecryptfs_dentry_to_lower_path(in->f_path.dentry); touch_atime(path); diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 6fe9a779fa91..db5e4b7636ec 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -448,5 +448,5 @@ const struct file_operations erofs_file_fops = { .llseek = generic_file_llseek, .read_iter = erofs_file_read_iter, .mmap = erofs_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; diff --git a/fs/exfat/file.c b/fs/exfat/file.c index e99183a74611..3cbd270e0cba 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -389,7 +389,7 @@ const struct file_operations exfat_file_operations = { #endif .mmap = generic_file_mmap, .fsync = exfat_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 6b4bebe982ca..d1ae0f0a3726 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -192,7 +192,7 @@ const struct file_operations ext2_file_operations = { .release = ext2_release_file, .fsync = ext2_fsync, .get_unmapped_area = thp_get_unmapped_area, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 9f8bbd9d131c..e8261900f4f3 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -155,7 +155,7 @@ static ssize_t ext4_file_splice_read(struct file *in, loff_t *ppos, if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; - return generic_file_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); } /* diff --git a/fs/fat/file.c b/fs/fat/file.c index 795a4fad5c40..456477946dd9 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -209,7 +209,7 @@ const struct file_operations fat_file_operations = { .unlocked_ioctl = fat_generic_ioctl, .compat_ioctl = compat_ptr_ioctl, .fsync = fat_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fallocate = fat_fallocate, }; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 89d97f6188e0..4553124f5406 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3252,7 +3252,7 @@ static const struct file_operations fuse_file_operations = { .lock = fuse_file_lock, .get_unmapped_area = thp_get_unmapped_area, .flock = fuse_file_flock, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = fuse_file_ioctl, .compat_ioctl = fuse_file_compat_ioctl, diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 300844f50dcd..0f5ad5165361 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -1568,7 +1568,7 @@ const struct file_operations gfs2_file_fops = { .fsync = gfs2_fsync, .lock = gfs2_lock, .flock = gfs2_flock, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = gfs2_file_splice_write, .setlease = simple_nosetlease, .fallocate = gfs2_fallocate, @@ -1599,7 +1599,7 @@ const struct file_operations gfs2_file_fops_nolock = { .open = gfs2_open, .release = gfs2_release, .fsync = gfs2_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = gfs2_file_splice_write, .setlease = generic_setlease, .fallocate = gfs2_fallocate, diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index 1f7bd068acf0..441d7fc952e3 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c @@ -694,7 +694,7 @@ static const struct file_operations hfs_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .fsync = hfs_file_fsync, .open = hfs_file_open, .release = hfs_file_release, diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index b21660475ac1..7d1a675e037d 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c @@ -372,7 +372,7 @@ static const struct file_operations hfsplus_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .fsync = hfsplus_file_fsync, .open = hfsplus_file_open, .release = hfsplus_file_release, diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 28b4f15c19eb..87998df499f4 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -381,7 +381,7 @@ static int hostfs_fsync(struct file *file, loff_t start, loff_t end, static const struct file_operations hostfs_file_fops = { .llseek = generic_file_llseek, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c index 88952d4a631e..1bb8d97cd9ae 100644 --- a/fs/hpfs/file.c +++ b/fs/hpfs/file.c @@ -259,7 +259,7 @@ const struct file_operations hpfs_file_ops = .mmap = generic_file_mmap, .release = hpfs_file_release, .fsync = hpfs_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .unlocked_ioctl = hpfs_ioctl, .compat_ioctl = compat_ptr_ioctl, }; diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 96b0275ce957..2345ca3f09ee 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c @@ -56,7 +56,7 @@ const struct file_operations jffs2_file_operations = .unlocked_ioctl=jffs2_ioctl, .mmap = generic_file_readonly_mmap, .fsync = jffs2_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 2ee35be49de1..01b6912e60f8 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c @@ -144,7 +144,7 @@ const struct file_operations jfs_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fsync = jfs_fsync, .release = jfs_release, diff --git a/fs/minix/file.c b/fs/minix/file.c index 0dd05d47724a..906d192ab7f3 100644 --- a/fs/minix/file.c +++ b/fs/minix/file.c @@ -19,7 +19,7 @@ const struct file_operations minix_file_operations = { .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; static int minix_setattr(struct mnt_idmap *idmap, diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index a265d391ffe9..a9eb3487efb2 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -140,7 +140,7 @@ const struct file_operations nilfs_file_operations = { .open = generic_file_open, /* .release = nilfs_release_file, */ .fsync = nilfs_sync_file, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index c481b14e4fd9..e5e0ed58670b 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c @@ -1992,7 +1992,7 @@ const struct file_operations ntfs_file_ops = { #endif /* NTFS_RW */ .mmap = generic_file_mmap, .open = ntfs_file_open, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; const struct inode_operations ntfs_file_inode_ops = { diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 667c9dc68b58..036efd85f60c 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -770,7 +770,7 @@ static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos, return -EOPNOTSUPP; } - return generic_file_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); } /* diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 86add13b5f23..42549fc81468 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2827,7 +2827,7 @@ const struct file_operations ocfs2_fops_no_plocks = { .compat_ioctl = ocfs2_compat_ioctl, #endif .flock = ocfs2_flock, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, .remap_file_range = ocfs2_remap_file_range, diff --git a/fs/omfs/file.c b/fs/omfs/file.c index 0101f1f87b56..de8f57ee39ec 100644 --- a/fs/omfs/file.c +++ b/fs/omfs/file.c @@ -334,7 +334,7 @@ const struct file_operations omfs_file_operations = { .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; static int omfs_setattr(struct mnt_idmap *idmap, diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c index 12af0490322f..c7a1aa3c882b 100644 --- a/fs/ramfs/file-mmu.c +++ b/fs/ramfs/file-mmu.c @@ -43,7 +43,7 @@ const struct file_operations ramfs_file_operations = { .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, .get_unmapped_area = ramfs_mmu_get_unmapped_area, diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 9fbb9b5256f7..efb1b4c1a0a4 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c @@ -43,7 +43,7 @@ const struct file_operations ramfs_file_operations = { .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, }; diff --git a/fs/read_write.c b/fs/read_write.c index a21ba3be7dbe..b07de77ef126 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -29,7 +29,7 @@ const struct file_operations generic_ro_fops = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, .mmap = generic_file_readonly_mmap, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; EXPORT_SYMBOL(generic_ro_fops); diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index b54cc7048f02..8eb3ad3e8ae9 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c @@ -247,7 +247,7 @@ const struct file_operations reiserfs_file_operations = { .fsync = reiserfs_sync_file, .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, }; diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c index 4578dc45e50a..4520ca413867 100644 --- a/fs/romfs/mmap-nommu.c +++ b/fs/romfs/mmap-nommu.c @@ -78,7 +78,7 @@ static unsigned romfs_mmap_capabilities(struct file *file) const struct file_operations romfs_ro_fops = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .mmap = romfs_mmap, .get_unmapped_area = romfs_get_unmapped_area, .mmap_capabilities = romfs_mmap_capabilities, diff --git a/fs/sysv/file.c b/fs/sysv/file.c index 50eb92557a0f..c645f60bdb7f 100644 --- a/fs/sysv/file.c +++ b/fs/sysv/file.c @@ -26,7 +26,7 @@ const struct file_operations sysv_file_operations = { .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; static int sysv_setattr(struct mnt_idmap *idmap, diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 979ab1d9d0c3..6738fe43040b 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -1669,7 +1669,7 @@ const struct file_operations ubifs_file_operations = { .mmap = ubifs_file_mmap, .fsync = ubifs_fsync, .unlocked_ioctl = ubifs_ioctl, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .open = fscrypt_file_open, #ifdef CONFIG_COMPAT diff --git a/fs/udf/file.c b/fs/udf/file.c index 8238f742377b..29daf5d5cb67 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -209,7 +209,7 @@ const struct file_operations udf_file_operations = { .write_iter = udf_file_write_iter, .release = udf_release_file, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, }; diff --git a/fs/ufs/file.c b/fs/ufs/file.c index 7e087581be7e..6558882a89ef 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c @@ -41,5 +41,5 @@ const struct file_operations ufs_file_operations = { .mmap = generic_file_mmap, .open = generic_file_open, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; diff --git a/fs/vboxsf/file.c b/fs/vboxsf/file.c index 572aa1c43b37..2307f8037efc 100644 --- a/fs/vboxsf/file.c +++ b/fs/vboxsf/file.c @@ -217,7 +217,7 @@ const struct file_operations vboxsf_reg_fops = { .open = vboxsf_file_open, .release = vboxsf_file_release, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, + .splice_read = filemap_splice_read, }; const struct inode_operations vboxsf_reg_iops = { From patchwork Mon May 22 13:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250609 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 2A405C7EE29 for ; Mon, 22 May 2023 13:52:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1F0890000D; Mon, 22 May 2023 09:52:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCF83900009; Mon, 22 May 2023 09:52:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A973190000D; Mon, 22 May 2023 09:52:27 -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 993D7900009 for ; Mon, 22 May 2023 09:52:27 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 23A07402E4 for ; Mon, 22 May 2023 13:52:27 +0000 (UTC) X-FDA: 80818030734.14.C9645BF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 5C247A0018 for ; Mon, 22 May 2023 13:52:25 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SUcVZbm3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1684763545; 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=sPgb6iT0KyhUHD55wBvrfISNeJ76P+kmnyDDc2IZvro=; b=bu4Tc1xm4NeR9DyRrSyXcWnlH0ebsXMc9ZlY8ZS7/FWDNxj1S25PDEfd0SwZdvNk/Pvunn bNKrBg5O4VymaXfAg2Guf5Fa+Wbo8LJUYwhAJ7Y5itAyzalbJ9PDIQPFuYiuUxaag3BiAV LX8WKfDDbots3ZNtGC+gKpC2Pc22e9w= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SUcVZbm3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1684763545; a=rsa-sha256; cv=none; b=XUyfpG7P9eZOyNX+z47EQyus1uC3xsKuvFuXbiwf5yZEoVfT5h31ZRWXoz205V3ssMDvg9 JHpAWO2kCO5AHkRIKenJ+H6Bjbc/MK0HYW5lMuZKFaPfZFZF1geFHsJuxNKVOt9D3KTxqx tw9+rWv71Gxvrz33yTQVzh7OAksqnR0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763544; 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=sPgb6iT0KyhUHD55wBvrfISNeJ76P+kmnyDDc2IZvro=; b=SUcVZbm3csF7nglSD9jDqJIUoW5qxRRJBE+L7YWGEVPx9l5Zrd6n0QxQAZJf+/RbJJ+1q3 Kc3fGfgn5vrDZECiP2WaIU5JWcKZM7d42P+pD0Xehi4ndOOPlaB4YMRxar2I36pOB3Dq5N OTUtIzv6XNFV11WG9lX/Kc4XetkTDRw= 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-195-wzCHOXg9PImMcHZvn4QAHg-1; Mon, 22 May 2023 09:52:19 -0400 X-MC-Unique: wzCHOXg9PImMcHZvn4QAHg-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 CB97D8032F5; Mon, 22 May 2023 13:52:17 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A30C40CFD45; Mon, 22 May 2023 13:52:14 +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 , Steve French , John Hubbard , linux-cifs@vger.kernel.org Subject: [PATCH v22 29/31] splice: Remove generic_file_splice_read() Date: Mon, 22 May 2023 14:50:16 +0100 Message-Id: <20230522135018.2742245-30-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.1 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5C247A0018 X-Stat-Signature: tpjea945dikmof6cfgwte9y7j159uygk X-Rspam-User: X-HE-Tag: 1684763545-192815 X-HE-Meta: U2FsdGVkX1/8A9A2M69SMP6MqHt0r28J/k+W6rq/mzPx3OGeFYJEqVZqWHHditBk7xaNnHHdm6qeRYyjBXKKt/tAXQROAsAHTC7YzOv45R8GyT9mI3EaiziRrZ7bx10NI3SbyCa3Gl974rQVn/YVrGYOuKRxvsnm6fdv9yBodUvNSFfP/YjUehHP3a+2lKn+9MLO1TkKOl3AKXIWPCOTrI+UurkPLhKjVJ5ClvbJbbCaw4Wdi5KAqVyiDvFpaMmFZKDv+4RtDTSYGbahZxiHLaTIYuAvYMXY+xLFw7vCyoLdRrfvxNw7BOe7lKx1vIMu1NXfxV+4GHBlxVJyf1vdupSZRkwO8Rr0uLFENe3dGaI8sjZvx+SBjXHxvCHSzLUBW9ISC0Yy9+pbqrHA8KWm8Wn/hvZFYeQXTWGKA1Cv8tErmz3kcLe7jyrzqOr5BLn8O7l1LVojRRf8vQlhm11/yyoKZ0uNQckyI49LgfA9XF5fzsat4DxG4tRGIyQEBtXL0UHqfeiaSLP29l/PieDwMFBVe/bSUpsoR2XPEzrAyZWpMdUzDMsqM0AC2CZQlprr0wtTwmZ8Ti17/7XubMB+Kkg/pW040K+4pz1dOX4D9/0B+WbHQcId6sc7rXkxzXo8sEQCPiNm5OFJbxkCQ0kUwSnwKUAquFzwsWFK4pYljWO3Vwq0wbaZtAQRGaYt/h/DOyKIkb2DvrgslM1C8NUhJATHe19ixCH1klwts/YvMBUqT+yoQtIqRPQ0+e6ANJdg/o0NxVhyHkHSjwwPOkimVGSywL2lcM9sg4XQIDsU3HngoRG/65i2+iI1P0lfEvkaSOrayLBMYN62fzvbOAR5TAUVlOWSIA2NPwPePmb1p2YxrO0gHXXbZk7Ui7bjz+Ynj2YCg2DTN4exN9yjl9hTeF+inR4Q40O9lnLZvLhEsSSGh4EtWsIAYwsUUqqk23FEUWi5TmHl6W/8g1J9TTa 7kYpLTwh kGC+CjtQh5D3p6hZnz76yduC+rPrSssmsqkjDRldV3zjd4ybdCRXxnF+fzRAxY72nzsxJSEprZPW7hzEye+Txbx8ZvpN8pGeq3VCoZyndbhGhODxfDrbnQJUEZ+eaJ9WNTWrsKRLnmmWAbIAnEvmSEKOKX2LRo70pAF/1K/RUxybTfW19Ao/X9LK7ZYiytdhwf89w6TabjLGOUUUr7h0BnbhWv8IH/8Mhw6cduysPZV+vT7ss2JcJmo56HliXMY02+H5xQZG3b3dmz30jmicv+ws+zy47D6vOTKidkPQNFOAcDPaPy04Ac1yVyPQkGXDsRiiQR3wdFq0B0ApD2aKKUJsbhYAwhcJ6ycMF1QIBXvY9FNtBTVMg7Ji9tkee7mFZnpSHWex6e//lworsnlWjtGtOmNgCpxMlv+ezS5He7bHSMK0BqfVEVQC3DYz/aojursdS 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: Remove generic_file_splice_read() as it has been replaced with calls to filemap_splice_read() and copy_splice_read(). With this, ITER_PIPE is no longer used. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Jens Axboe cc: Steve French cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- Notes: ver #21) - Move zero-len check to vfs_splice_read(). - Move s_maxbytes check to filemap_splice_read(). - DIO (and DAX) are handled by vfs_splice_read(). ver #20) - Use s_maxbytes from the backing store (in->f_mapping), not the front inode (especially for a blockdev). ver #18) - Split out the change to cifs to make it use generic_file_splice_read(). - Split out the unexport of filemap_splice_read() (still needed by cifs). fs/splice.c | 43 ------------------------------------------- include/linux/fs.h | 2 -- 2 files changed, 45 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 8268248df3a9..9be4cb3b9879 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -386,49 +386,6 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, } EXPORT_SYMBOL(copy_splice_read); -/** - * generic_file_splice_read - splice data from file to a pipe - * @in: file to splice from - * @ppos: position in @in - * @pipe: pipe to splice to - * @len: number of bytes to splice - * @flags: splice modifier flags - * - * Description: - * Will read pages from given file and fill them into a pipe. Can be - * used as long as it has more or less sane ->read_iter(). - * - */ -ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags) -{ - struct iov_iter to; - struct kiocb kiocb; - int ret; - - iov_iter_pipe(&to, ITER_DEST, pipe, len); - init_sync_kiocb(&kiocb, in); - kiocb.ki_pos = *ppos; - ret = call_read_iter(in, &kiocb, &to); - if (ret > 0) { - *ppos = kiocb.ki_pos; - file_accessed(in); - } else if (ret < 0) { - /* free what was emitted */ - pipe_discard_from(pipe, to.start_head); - /* - * callers of ->splice_read() expect -EAGAIN on - * "can't put anything in there", rather than -EFAULT. - */ - if (ret == -EFAULT) - ret = -EAGAIN; - } - - return ret; -} -EXPORT_SYMBOL(generic_file_splice_read); - const struct pipe_buf_operations default_pipe_buf_ops = { .release = generic_pipe_buf_release, .try_steal = generic_pipe_buf_try_steal, diff --git a/include/linux/fs.h b/include/linux/fs.h index e3c22efa413e..08ba2ae1d3ce 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2755,8 +2755,6 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, ssize_t copy_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags); -extern ssize_t generic_file_splice_read(struct file *, loff_t *, - struct pipe_inode_info *, size_t, unsigned int); extern ssize_t iter_file_splice_write(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, From patchwork Mon May 22 13:50:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250610 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 91D40C77B75 for ; Mon, 22 May 2023 13:52:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D23190000E; Mon, 22 May 2023 09:52:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23288900009; Mon, 22 May 2023 09:52:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 036D890000E; Mon, 22 May 2023 09:52:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E66B7900009 for ; Mon, 22 May 2023 09:52:28 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BAF121C6E34 for ; Mon, 22 May 2023 13:52:28 +0000 (UTC) X-FDA: 80818030776.03.7CCB530 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id EFE58C0011 for ; Mon, 22 May 2023 13:52:26 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZcX5p+q6; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684763547; 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=hZn4TB0yfpjQNsS1z32giuBj7tfAM3v9UJAdYyfw13g=; b=6g4mkn0WfvS1TAu8/0oQ6eZQeve+F0EqqtCU40paDGG2ZUnS1+cxf9SN7kUMJX3zXkevR7 gpREADJPqFbAYuSl1gZ3PjIqbIpbBVMZVzu/V4+UCoGGSAjbe0xr1sv6UyvxjAMWY3dXGG Ub24D+XbUEgddb095Buydezt+m74syM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZcX5p+q6; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763547; a=rsa-sha256; cv=none; b=ku9yBbavOhYGCFeh0pSW1m/T7DpwNLWwPCyhZFedQr/stWBWabGZO0v5B6MhB8c3o9hGP2 KVygLRP851lyXYyJLlDIf11pc4qFHM4R4440eTWmONV3ehT4i4o1Vq2fqlqscYT7X6+2nK 9Um0tjEXNkmG4qmPsvM8jzV6kvO81v8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763546; 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=hZn4TB0yfpjQNsS1z32giuBj7tfAM3v9UJAdYyfw13g=; b=ZcX5p+q6wBp0dvYuCK9ero2Iz33rw2a62w+1dYmc908ff6ivtrnX/ednuU1eE2R3IaicPM uLLfs5rQR3HWmmeeiFdRzWwP+NlxXNJH8t7nMmMUjgEtAuxKmmEhGXtkL8avrnJgLKV+eK o/8d9kqZdQaXJy09jwoLHBeUgduoPjE= 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-490-p_7H8DyNOE22Eg_rTyenng-1; Mon, 22 May 2023 09:52:22 -0400 X-MC-Unique: p_7H8DyNOE22Eg_rTyenng-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B4898039A9; Mon, 22 May 2023 13:52:21 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id AACE01121314; Mon, 22 May 2023 13:52:18 +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 , John Hubbard Subject: [PATCH v22 30/31] iov_iter: Kill ITER_PIPE Date: Mon, 22 May 2023 14:50:17 +0100 Message-Id: <20230522135018.2742245-31-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.3 X-Rspamd-Queue-Id: EFE58C0011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bjrnf31xwmjpwf3mxww3ybekrfxa3dmz X-HE-Tag: 1684763546-411993 X-HE-Meta: U2FsdGVkX1+5wrGj0iCoDkir8saBdJ9Kz4cszEoZ3M+arRcEDWeo23dhsx3oU98vkw7LJPQgEyp00U1NGJldn1CYB4w34xLX7MSpAPpMTOlUXhxWOS6ib5G6BFXuIyl4KbR9iaPdvz3EI8U6Rvk1FYKQMIo7DmwgcCaSU7m62kPXQkrcyVC5WMpF3BZTed86ElFD2J675ig2UcIXtzgZUvKYm44mm8BQg/DT9w2cl1avyUDGYljZfenUO+I5L9L6vFV0VUrv1k+eK190vCLTgsY0xfMOTIgnrT5l3ncEyWCmhFcfGQ429gnlrhNPzdL3jo5RkAdR++qb6we5vXNYUlDW7droIQN2knWsHfjp2Z450OrQrD5BrLWDBYSqSqmJpIoAcYxMAtxjEj/qS18Z721hVReN6r6SKJlJuUTpU5C2Ivuk9TzMERCA9YGILBiBkpuRhM3cJeWLcOLMtR3J4JS/Y1M9j4xJ4zP1mnd64eeji7g+NigfG/QrHyRzeyvAobCeRRz9ttizsmM3nuLYnfmsSs+Tt+93sicGXJnGOBStGYxMkYHDio3FyRHus4GP5nbC+Fb3xx/QQ4QhpezxiniX/nB4c7JcU8R+FKG21jcYFuPc1M8uaI00oCZ2Hzi5Zlhnqtmzv3evOPVz8HBZ8Ih4F4SQ/nIw1czisxqPUBVfhlHcT7tO5hrNJFDRFL73Mc6sELnaOpb4dEW3y45qVHwhLO06i5viX0f2yzDN0xMHWGVrFVvsbo6rJof8oJ427C26gNMUpni3qW2rob9nVmbTZjbFA5Icfuk6ci+ooWWfcJsCGb3KSSyxv0GVDToKou9r0S1rWxYcDpk89/GTfWJ4QJCe4ltwX0E0ypXzTo4c2KrkTwboMdmDU40JvbnTfEmNvEoQYSp1zgzdfcRuLrt1/qdiLzC0CufbLUh3txuLL9bUDQuhD6A/mBqtf1MKYit3RrUeDT0GIwCJM9v 7f4RASF/ bHcw+1Vbe7+zBXou8MktPtW23XBNy9tPr3V4ii/GulDl+D5S0MulQ60dVQa0L2xGStYWMbFXKPZjPf9VPwSsefbU8uC0HQchjAAnOZMaX8xgbSsZMVbLSCiUnIqKBRp4cFext3j8Q1FVJH3d6tJxWMhJtt2BEujk5qXFQTuVPtSSUJefsyq8mGPSdTQReOmDYtqo2srU/dJ/nBCvjs5rp0uGCnIlFMrgS4Gb+eSzWoLtLNvxzI7f3PalRYbemBLE6DoOrOC/ebnnVzswAvrO2J6J/McoPsXyOOQmqs9R19s2Hks9ilMTD4wUg2oU4nTxhXgvKtiXX5vmBpw62HiuRy0VqNtJpehwj9G+gbV7HYia7dlQxSsD5m09cX6KaQjj5OY1lk/xLLL4O8Ef1bt4+VyQtbDjiG1wS5xIngmG1TxBA3jo= 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: The ITER_PIPE-type iterator was only used by generic_file_splice_read() and that has been replaced and removed. This leaves ITER_PIPE unused - so remove it too. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- Notes: ver #20) - Rebase and remove additional pipe reference. include/linux/uio.h | 14 -- lib/iov_iter.c | 431 +------------------------------------------- mm/filemap.c | 3 +- 3 files changed, 4 insertions(+), 444 deletions(-) diff --git a/include/linux/uio.h b/include/linux/uio.h index 044c1d8c230c..60c342bb7ab8 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -11,7 +11,6 @@ #include struct page; -struct pipe_inode_info; typedef unsigned int __bitwise iov_iter_extraction_t; @@ -25,7 +24,6 @@ enum iter_type { ITER_IOVEC, ITER_KVEC, ITER_BVEC, - ITER_PIPE, ITER_XARRAY, ITER_DISCARD, ITER_UBUF, @@ -74,7 +72,6 @@ struct iov_iter { const struct kvec *kvec; const struct bio_vec *bvec; struct xarray *xarray; - struct pipe_inode_info *pipe; void __user *ubuf; }; size_t count; @@ -82,10 +79,6 @@ struct iov_iter { }; union { unsigned long nr_segs; - struct { - unsigned int head; - unsigned int start_head; - }; loff_t xarray_start; }; }; @@ -133,11 +126,6 @@ static inline bool iov_iter_is_bvec(const struct iov_iter *i) return iov_iter_type(i) == ITER_BVEC; } -static inline bool iov_iter_is_pipe(const struct iov_iter *i) -{ - return iov_iter_type(i) == ITER_PIPE; -} - static inline bool iov_iter_is_discard(const struct iov_iter *i) { return iov_iter_type(i) == ITER_DISCARD; @@ -286,8 +274,6 @@ void iov_iter_kvec(struct iov_iter *i, unsigned int direction, const struct kvec unsigned long nr_segs, size_t count); void iov_iter_bvec(struct iov_iter *i, unsigned int direction, const struct bio_vec *bvec, unsigned long nr_segs, size_t count); -void iov_iter_pipe(struct iov_iter *i, unsigned int direction, struct pipe_inode_info *pipe, - size_t count); void iov_iter_discard(struct iov_iter *i, unsigned int direction, size_t count); void iov_iter_xarray(struct iov_iter *i, unsigned int direction, struct xarray *xarray, loff_t start, size_t count); diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 960223ed9199..f18138e0292a 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -14,8 +14,6 @@ #include #include -#define PIPE_PARANOIA /* for now */ - /* covers ubuf and kbuf alike */ #define iterate_buf(i, n, base, len, off, __p, STEP) { \ size_t __maybe_unused off = 0; \ @@ -198,150 +196,6 @@ static int copyin(void *to, const void __user *from, size_t n) return res; } -#ifdef PIPE_PARANOIA -static bool sanity(const struct iov_iter *i) -{ - struct pipe_inode_info *pipe = i->pipe; - unsigned int p_head = pipe->head; - unsigned int p_tail = pipe->tail; - unsigned int p_occupancy = pipe_occupancy(p_head, p_tail); - unsigned int i_head = i->head; - unsigned int idx; - - if (i->last_offset) { - struct pipe_buffer *p; - if (unlikely(p_occupancy == 0)) - goto Bad; // pipe must be non-empty - if (unlikely(i_head != p_head - 1)) - goto Bad; // must be at the last buffer... - - p = pipe_buf(pipe, i_head); - if (unlikely(p->offset + p->len != abs(i->last_offset))) - goto Bad; // ... at the end of segment - } else { - if (i_head != p_head) - goto Bad; // must be right after the last buffer - } - return true; -Bad: - printk(KERN_ERR "idx = %d, offset = %d\n", i_head, i->last_offset); - printk(KERN_ERR "head = %d, tail = %d, buffers = %d\n", - p_head, p_tail, pipe->ring_size); - for (idx = 0; idx < pipe->ring_size; idx++) - printk(KERN_ERR "[%p %p %d %d]\n", - pipe->bufs[idx].ops, - pipe->bufs[idx].page, - pipe->bufs[idx].offset, - pipe->bufs[idx].len); - WARN_ON(1); - return false; -} -#else -#define sanity(i) true -#endif - -static struct page *push_anon(struct pipe_inode_info *pipe, unsigned size) -{ - struct page *page = alloc_page(GFP_USER); - if (page) { - struct pipe_buffer *buf = pipe_buf(pipe, pipe->head++); - *buf = (struct pipe_buffer) { - .ops = &default_pipe_buf_ops, - .page = page, - .offset = 0, - .len = size - }; - } - return page; -} - -static void push_page(struct pipe_inode_info *pipe, struct page *page, - unsigned int offset, unsigned int size) -{ - struct pipe_buffer *buf = pipe_buf(pipe, pipe->head++); - *buf = (struct pipe_buffer) { - .ops = &page_cache_pipe_buf_ops, - .page = page, - .offset = offset, - .len = size - }; - get_page(page); -} - -static inline int last_offset(const struct pipe_buffer *buf) -{ - if (buf->ops == &default_pipe_buf_ops) - return buf->len; // buf->offset is 0 for those - else - return -(buf->offset + buf->len); -} - -static struct page *append_pipe(struct iov_iter *i, size_t size, - unsigned int *off) -{ - struct pipe_inode_info *pipe = i->pipe; - int offset = i->last_offset; - struct pipe_buffer *buf; - struct page *page; - - if (offset > 0 && offset < PAGE_SIZE) { - // some space in the last buffer; add to it - buf = pipe_buf(pipe, pipe->head - 1); - size = min_t(size_t, size, PAGE_SIZE - offset); - buf->len += size; - i->last_offset += size; - i->count -= size; - *off = offset; - return buf->page; - } - // OK, we need a new buffer - *off = 0; - size = min_t(size_t, size, PAGE_SIZE); - if (pipe_full(pipe->head, pipe->tail, pipe->max_usage)) - return NULL; - page = push_anon(pipe, size); - if (!page) - return NULL; - i->head = pipe->head - 1; - i->last_offset = size; - i->count -= size; - return page; -} - -static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t bytes, - struct iov_iter *i) -{ - struct pipe_inode_info *pipe = i->pipe; - unsigned int head = pipe->head; - - if (unlikely(bytes > i->count)) - bytes = i->count; - - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - if (offset && i->last_offset == -offset) { // could we merge it? - struct pipe_buffer *buf = pipe_buf(pipe, head - 1); - if (buf->page == page) { - buf->len += bytes; - i->last_offset -= bytes; - i->count -= bytes; - return bytes; - } - } - if (pipe_full(pipe->head, pipe->tail, pipe->max_usage)) - return 0; - - push_page(pipe, page, offset, bytes); - i->last_offset = -(offset + bytes); - i->head = head; - i->count -= bytes; - return bytes; -} - /* * fault_in_iov_iter_readable - fault in iov iterator for reading * @i: iterator @@ -446,46 +300,6 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction, } EXPORT_SYMBOL(iov_iter_init); -// returns the offset in partial buffer (if any) -static inline unsigned int pipe_npages(const struct iov_iter *i, int *npages) -{ - struct pipe_inode_info *pipe = i->pipe; - int used = pipe->head - pipe->tail; - int off = i->last_offset; - - *npages = max((int)pipe->max_usage - used, 0); - - if (off > 0 && off < PAGE_SIZE) { // anon and not full - (*npages)++; - return off; - } - return 0; -} - -static size_t copy_pipe_to_iter(const void *addr, size_t bytes, - struct iov_iter *i) -{ - unsigned int off, chunk; - - if (unlikely(bytes > i->count)) - bytes = i->count; - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - for (size_t n = bytes; n; n -= chunk) { - struct page *page = append_pipe(i, n, &off); - chunk = min_t(size_t, n, PAGE_SIZE - off); - if (!page) - return bytes - n; - memcpy_to_page(page, off, addr, chunk); - addr += chunk; - } - return bytes; -} - static __wsum csum_and_memcpy(void *to, const void *from, size_t len, __wsum sum, size_t off) { @@ -493,44 +307,10 @@ static __wsum csum_and_memcpy(void *to, const void *from, size_t len, return csum_block_add(sum, next, off); } -static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes, - struct iov_iter *i, __wsum *sump) -{ - __wsum sum = *sump; - size_t off = 0; - unsigned int chunk, r; - - if (unlikely(bytes > i->count)) - bytes = i->count; - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - while (bytes) { - struct page *page = append_pipe(i, bytes, &r); - char *p; - - if (!page) - break; - chunk = min_t(size_t, bytes, PAGE_SIZE - r); - p = kmap_local_page(page); - sum = csum_and_memcpy(p + r, addr + off, chunk, sum, off); - kunmap_local(p); - off += chunk; - bytes -= chunk; - } - *sump = sum; - return off; -} - size_t _copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i) { if (WARN_ON_ONCE(i->data_source)) return 0; - if (unlikely(iov_iter_is_pipe(i))) - return copy_pipe_to_iter(addr, bytes, i); if (user_backed_iter(i)) might_fault(); iterate_and_advance(i, bytes, base, len, off, @@ -552,42 +332,6 @@ static int copyout_mc(void __user *to, const void *from, size_t n) return n; } -static size_t copy_mc_pipe_to_iter(const void *addr, size_t bytes, - struct iov_iter *i) -{ - size_t xfer = 0; - unsigned int off, chunk; - - if (unlikely(bytes > i->count)) - bytes = i->count; - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - while (bytes) { - struct page *page = append_pipe(i, bytes, &off); - unsigned long rem; - char *p; - - if (!page) - break; - chunk = min_t(size_t, bytes, PAGE_SIZE - off); - p = kmap_local_page(page); - rem = copy_mc_to_kernel(p + off, addr + xfer, chunk); - chunk -= rem; - kunmap_local(p); - xfer += chunk; - bytes -= chunk; - if (rem) { - iov_iter_revert(i, rem); - break; - } - } - return xfer; -} - /** * _copy_mc_to_iter - copy to iter with source memory error exception handling * @addr: source kernel address @@ -607,9 +351,8 @@ static size_t copy_mc_pipe_to_iter(const void *addr, size_t bytes, * alignment and poison alignment assumptions to avoid re-triggering * hardware exceptions. * - * * ITER_KVEC, ITER_PIPE, and ITER_BVEC can return short copies. - * Compare to copy_to_iter() where only ITER_IOVEC attempts might return - * a short copy. + * * ITER_KVEC and ITER_BVEC can return short copies. Compare to + * copy_to_iter() where only ITER_IOVEC attempts might return a short copy. * * Return: number of bytes copied (may be %0) */ @@ -617,8 +360,6 @@ size_t _copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i) { if (WARN_ON_ONCE(i->data_source)) return 0; - if (unlikely(iov_iter_is_pipe(i))) - return copy_mc_pipe_to_iter(addr, bytes, i); if (user_backed_iter(i)) might_fault(); __iterate_and_advance(i, bytes, base, len, off, @@ -732,8 +473,6 @@ size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes, return 0; if (WARN_ON_ONCE(i->data_source)) return 0; - if (unlikely(iov_iter_is_pipe(i))) - return copy_page_to_iter_pipe(page, offset, bytes, i); page += offset / PAGE_SIZE; // first subpage offset %= PAGE_SIZE; while (1) { @@ -764,8 +503,6 @@ size_t copy_page_to_iter_nofault(struct page *page, unsigned offset, size_t byte return 0; if (WARN_ON_ONCE(i->data_source)) return 0; - if (unlikely(iov_iter_is_pipe(i))) - return copy_page_to_iter_pipe(page, offset, bytes, i); page += offset / PAGE_SIZE; // first subpage offset %= PAGE_SIZE; while (1) { @@ -818,36 +555,8 @@ size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes, } EXPORT_SYMBOL(copy_page_from_iter); -static size_t pipe_zero(size_t bytes, struct iov_iter *i) -{ - unsigned int chunk, off; - - if (unlikely(bytes > i->count)) - bytes = i->count; - if (unlikely(!bytes)) - return 0; - - if (!sanity(i)) - return 0; - - for (size_t n = bytes; n; n -= chunk) { - struct page *page = append_pipe(i, n, &off); - char *p; - - if (!page) - return bytes - n; - chunk = min_t(size_t, n, PAGE_SIZE - off); - p = kmap_local_page(page); - memset(p + off, 0, chunk); - kunmap_local(p); - } - return bytes; -} - size_t iov_iter_zero(size_t bytes, struct iov_iter *i) { - if (unlikely(iov_iter_is_pipe(i))) - return pipe_zero(bytes, i); iterate_and_advance(i, bytes, base, len, count, clear_user(base, len), memset(base, 0, len) @@ -878,32 +587,6 @@ size_t copy_page_from_iter_atomic(struct page *page, unsigned offset, size_t byt } EXPORT_SYMBOL(copy_page_from_iter_atomic); -static void pipe_advance(struct iov_iter *i, size_t size) -{ - struct pipe_inode_info *pipe = i->pipe; - int off = i->last_offset; - - if (!off && !size) { - pipe_discard_from(pipe, i->start_head); // discard everything - return; - } - i->count -= size; - while (1) { - struct pipe_buffer *buf = pipe_buf(pipe, i->head); - if (off) /* make it relative to the beginning of buffer */ - size += abs(off) - buf->offset; - if (size <= buf->len) { - buf->len = size; - i->last_offset = last_offset(buf); - break; - } - size -= buf->len; - i->head++; - off = 0; - } - pipe_discard_from(pipe, i->head + 1); // discard everything past this one -} - static void iov_iter_bvec_advance(struct iov_iter *i, size_t size) { const struct bio_vec *bvec, *end; @@ -955,8 +638,6 @@ void iov_iter_advance(struct iov_iter *i, size_t size) iov_iter_iovec_advance(i, size); } else if (iov_iter_is_bvec(i)) { iov_iter_bvec_advance(i, size); - } else if (iov_iter_is_pipe(i)) { - pipe_advance(i, size); } else if (iov_iter_is_discard(i)) { i->count -= size; } @@ -970,26 +651,6 @@ void iov_iter_revert(struct iov_iter *i, size_t unroll) if (WARN_ON(unroll > MAX_RW_COUNT)) return; i->count += unroll; - if (unlikely(iov_iter_is_pipe(i))) { - struct pipe_inode_info *pipe = i->pipe; - unsigned int head = pipe->head; - - while (head > i->start_head) { - struct pipe_buffer *b = pipe_buf(pipe, --head); - if (unroll < b->len) { - b->len -= unroll; - i->last_offset = last_offset(b); - i->head = head; - return; - } - unroll -= b->len; - pipe_buf_release(pipe, b); - pipe->head--; - } - i->last_offset = 0; - i->head = head; - return; - } if (unlikely(iov_iter_is_discard(i))) return; if (unroll <= i->iov_offset) { @@ -1079,24 +740,6 @@ void iov_iter_bvec(struct iov_iter *i, unsigned int direction, } EXPORT_SYMBOL(iov_iter_bvec); -void iov_iter_pipe(struct iov_iter *i, unsigned int direction, - struct pipe_inode_info *pipe, - size_t count) -{ - BUG_ON(direction != READ); - WARN_ON(pipe_full(pipe->head, pipe->tail, pipe->ring_size)); - *i = (struct iov_iter){ - .iter_type = ITER_PIPE, - .data_source = false, - .pipe = pipe, - .head = pipe->head, - .start_head = pipe->head, - .last_offset = 0, - .count = count - }; -} -EXPORT_SYMBOL(iov_iter_pipe); - /** * iov_iter_xarray - Initialise an I/O iterator to use the pages in an xarray * @i: The iterator to initialise. @@ -1224,19 +867,6 @@ bool iov_iter_is_aligned(const struct iov_iter *i, unsigned addr_mask, if (iov_iter_is_bvec(i)) return iov_iter_aligned_bvec(i, addr_mask, len_mask); - if (iov_iter_is_pipe(i)) { - size_t size = i->count; - - if (size & len_mask) - return false; - if (size && i->last_offset > 0) { - if (i->last_offset & addr_mask) - return false; - } - - return true; - } - if (iov_iter_is_xarray(i)) { if (i->count & len_mask) return false; @@ -1307,14 +937,6 @@ unsigned long iov_iter_alignment(const struct iov_iter *i) if (iov_iter_is_bvec(i)) return iov_iter_alignment_bvec(i); - if (iov_iter_is_pipe(i)) { - size_t size = i->count; - - if (size && i->last_offset > 0) - return size | i->last_offset; - return size; - } - if (iov_iter_is_xarray(i)) return (i->xarray_start + i->iov_offset) | i->count; @@ -1367,36 +989,6 @@ static int want_pages_array(struct page ***res, size_t size, return count; } -static ssize_t pipe_get_pages(struct iov_iter *i, - struct page ***pages, size_t maxsize, unsigned maxpages, - size_t *start) -{ - unsigned int npages, count, off, chunk; - struct page **p; - size_t left; - - if (!sanity(i)) - return -EFAULT; - - *start = off = pipe_npages(i, &npages); - if (!npages) - return -EFAULT; - count = want_pages_array(pages, maxsize, off, min(npages, maxpages)); - if (!count) - return -ENOMEM; - p = *pages; - for (npages = 0, left = maxsize ; npages < count; npages++, left -= chunk) { - struct page *page = append_pipe(i, left, &off); - if (!page) - break; - chunk = min_t(size_t, left, PAGE_SIZE - off); - get_page(*p++ = page); - } - if (!npages) - return -EFAULT; - return maxsize - left; -} - static ssize_t iter_xarray_populate_pages(struct page **pages, struct xarray *xa, pgoff_t index, unsigned int nr_pages) { @@ -1547,8 +1139,6 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i, } return maxsize; } - if (iov_iter_is_pipe(i)) - return pipe_get_pages(i, pages, maxsize, maxpages, start); if (iov_iter_is_xarray(i)) return iter_xarray_get_pages(i, pages, maxsize, maxpages, start); return -EFAULT; @@ -1638,9 +1228,7 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate, } sum = csum_shift(csstate->csum, csstate->off); - if (unlikely(iov_iter_is_pipe(i))) - bytes = csum_and_copy_to_pipe_iter(addr, bytes, i, &sum); - else iterate_and_advance(i, bytes, base, len, off, ({ + iterate_and_advance(i, bytes, base, len, off, ({ next = csum_and_copy_to_user(addr + off, base, len); sum = csum_block_add(sum, next, off); next ? 0 : len; @@ -1725,15 +1313,6 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages) return iov_npages(i, maxpages); if (iov_iter_is_bvec(i)) return bvec_npages(i, maxpages); - if (iov_iter_is_pipe(i)) { - int npages; - - if (!sanity(i)) - return 0; - - pipe_npages(i, &npages); - return min(npages, maxpages); - } if (iov_iter_is_xarray(i)) { unsigned offset = (i->xarray_start + i->iov_offset) % PAGE_SIZE; int npages = DIV_ROUND_UP(offset + i->count, PAGE_SIZE); @@ -1746,10 +1325,6 @@ EXPORT_SYMBOL(iov_iter_npages); const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags) { *new = *old; - if (unlikely(iov_iter_is_pipe(new))) { - WARN_ON(1); - return NULL; - } if (iov_iter_is_bvec(new)) return new->bvec = kmemdup(new->bvec, new->nr_segs * sizeof(struct bio_vec), diff --git a/mm/filemap.c b/mm/filemap.c index 0fcb0b80c2e2..603b562d69b1 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2687,8 +2687,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, if (unlikely(iocb->ki_pos >= i_size_read(inode))) break; - error = filemap_get_pages(iocb, iter->count, &fbatch, - iov_iter_is_pipe(iter)); + error = filemap_get_pages(iocb, iter->count, &fbatch, false); if (error < 0) break; From patchwork Mon May 22 13:50:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250611 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 E56FAC7EE29 for ; Mon, 22 May 2023 13:52:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89C4B90000B; Mon, 22 May 2023 09:52:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84CC5900009; Mon, 22 May 2023 09:52:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EE3290000B; Mon, 22 May 2023 09:52: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 61991900009 for ; Mon, 22 May 2023 09:52:33 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0D930ADADC for ; Mon, 22 May 2023 13:52:33 +0000 (UTC) X-FDA: 80818030986.03.CE7AC8B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 2B8C2A000C for ; Mon, 22 May 2023 13:52:30 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IjfrVPTw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1684763551; 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=1dW3gfal+wiqS1BsUQ7v1POUMzsncK8bE2BxQUdT+Fw=; b=JUbD+ky+4h6WEe1KJgRrEiU6x7slRuRbt3nATM1Ycj6qVhmX5Bdb8cFO4fn+yMI4M4p+lg rjxPdDp2HLL5Gs8Lz3+awWVHE96X3SP1sVPgwesWFt3wPK/nj4uoHeEp040szt3Mk6yphC cQ5wpoFWUigIf9MCHILupP3K0kEgNCo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IjfrVPTw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.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=1684763551; a=rsa-sha256; cv=none; b=BMraiHWtA/87ohvtm5x2DFldFmAp/HP+Tqe7Vy061Ws70lckIsTbot2uvaRKPqqWGAxp4T 0EwxXwjlR4Au8KokkC6maoBXQlaI+OZAGrFm/6Z7Nbn4jrMcJKixPTv5oeUwlqtHmmNEDr 8YRDA4YaSRD1rHBm5Ddn+HaNduyd0s8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763550; 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=1dW3gfal+wiqS1BsUQ7v1POUMzsncK8bE2BxQUdT+Fw=; b=IjfrVPTwWf9h0pgVUifVFOusgyffmgP/cWgV5TQb2Dnc6KfG/uVV+8wXWpgYcwHfvWV4pD pJK3A7XP+38LijFZM5n10wj4H/MviMMona2ot7meW9pbXf3OMF3oIVaFY/H9UBkXs6Kmki CE8glafi5mZ16O8Nm0vBADOwrgBkNmY= 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-401-O78IS1gQNUW2bLyo8CEsOA-1; Mon, 22 May 2023 09:52:26 -0400 X-MC-Unique: O78IS1gQNUW2bLyo8CEsOA-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 213773C025AD; Mon, 22 May 2023 13:52:25 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AEE4140E95D; Mon, 22 May 2023 13:52:22 +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 , Steve French , linux-cifs@vger.kernel.org Subject: [PATCH v22 31/31] splice: kdoc for filemap_splice_read() and copy_splice_read() Date: Mon, 22 May 2023 14:50:18 +0100 Message-Id: <20230522135018.2742245-32-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.7 X-Rspamd-Queue-Id: 2B8C2A000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 7ftpauux6bqktwbjwewtpixymr5h3dth X-HE-Tag: 1684763550-80074 X-HE-Meta: U2FsdGVkX1/J0/UXA/QIGjEkte1jpTgkcktjehTtPDNryBEppJ0GE9k8T5j856qj7/8qie8aQw7uPTruNna5UeF0yPtNblXSP4jgtqKy+wRBM4n939QwtmfsEZduP/hxyaFEqUyKKkeIGwyuLIfbd5m2tz1xK6dbk0T/5bXHzlinqwledrlWGFizz1ix1v1D4GqsVMJGJI6lgDXCXz1wrU9zBZBxbHR1HOw9Hc875A+RBoFowOImU+6XdBpKP7BH2db4GrB7iJQugubVNUBChAiyHDnSeZXQuwy9K6cDcQrP0m00Vsma+cslNbzuthj3DFB+aFirIdGJ/6Ftfjjg13JjNP+J4949bUlL8duYpf8e2hqb4M/5M3xQ+rFewMpwn2p56piTpYpiA9VF009jAVor0VfECTA7BH7plKVnSEm064IJnUqcIfWjEhNTQNLvICXLpzy88B9GNzMBRxjbPdOROlGrUaaSI/BUAz5O73WFg3HdLTG6jNti843cRPXaYwRt00dViYCzVXl0xG+y4ZeuNa8XFs1YJEpoJBsHM5cgjmGaJbUQYycIOfTiileUuvVnOj1nxCA/fb7TeUPGOJxegKU4i9JLkSE/6xCGfpIqkKPNZU8yNOddh7Qhq09TQziZ3LCv8vOu1vjqSib0Ht+ReHkrdtWAT8fXobYP2WPK0RzbcbWyW7D5bDf3fZqVUjPRbmEIEHu7z9I2yjBeJ/68YGEHNtQFIdLBe5yV/3xxCGdKHupSRXDPvmJ2RYHgN2VF/36nl68odHNQq51+cq0rMIR/4w+HKMBPdyN0u/0YWDBzkGu9VTs/CvAJQU4ws//uiAw9u+Q9SAoGJFcDpusU3UU28F90fOuTc5tXPnd37vgSl877WkNqmyaJ4l7/5qi3ZtQgkaRNOsTy7PEp9POop62AxWGiGme6y5CBtjVZbjpRXqI0y39SiHMpVCk5KKgOolNeMRVLI6VTzX+ cgKfejii sHjfLqYCF1/rtYymSVKlt5nguoj9PHbg43wIJp3HbWYU/ctophxLldjyKtezHUFmv6yTWNtnMIIBsPPi0IjEkgZLfYcWxKychL9HWFzKZVf6hTFrSEdaM/n0e/bPoGcNZ9TqYIjOeA9UbKvQfHHSlq6sN11K1pJUXwb/j/K4GZa/fuz2sdYSpD1aIi+9GBiGTGCGemBIrLWAkJhgM4FfiqqbuaUwFxiDStzT5w/OO0T0ViOQAdVUHfgl+/57/AgOR296SQdklDOT4OwAdL/HxME0rI3DVB8ix2/FzP/tFe1MAm5I5ZN0e7gBZ0hhDHb6XV6K3Uc24vWLzSOJF/pJ865/TX8RfKYvyonuoMg1CzdeAtmsl0hs5fvb9+xSx+klgJzxJAPorJJ2L0y+kjfeBpmgnqIBAx/I78sldTLqOvlp/tZM= 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 kerneldoc comments for filemap_splice_read() and copy_splice_read(). Signed-off-by: David Howells cc: Christian Brauner cc: Christoph Hellwig cc: Jens Axboe cc: Steve French cc: Al Viro cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- fs/splice.c | 21 +++++++++++++++++++-- mm/filemap.c | 21 ++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 9be4cb3b9879..2420ead610a7 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -299,8 +299,25 @@ void splice_shrink_spd(struct splice_pipe_desc *spd) kfree(spd->partial); } -/* - * Copy data from a file into pages and then splice those into the output pipe. +/** + * copy_splice_read - Copy data from a file and splice the copy into a pipe + * @in: The file to read from + * @ppos: Pointer to the file position to read from + * @pipe: The pipe to splice into + * @len: The amount to splice + * @flags: The SPLICE_F_* flags + * + * This function allocates a bunch of pages sufficient to hold the requested + * amount of data (but limited by the remaining pipe capacity), passes it to + * the file's ->read_iter() to read into and then splices the used pages into + * the pipe. + * + * Return: On success, the number of bytes read will be returned and *@ppos + * will be updated if appropriate; 0 will be returned if there is no more data + * to be read; -EAGAIN will be returned if the pipe had no space, and some + * other negative error code will be returned on error. A short read may occur + * if the pipe has insufficient space, we reach the end of the data or we hit a + * hole. */ ssize_t copy_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, diff --git a/mm/filemap.c b/mm/filemap.c index 603b562d69b1..f87e2ad8cff1 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2871,9 +2871,24 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe, return spliced; } -/* - * Splice folios from the pagecache of a buffered (ie. non-O_DIRECT) file into - * a pipe. +/** + * filemap_splice_read - Splice data from a file's pagecache into a pipe + * @in: The file to read from + * @ppos: Pointer to the file position to read from + * @pipe: The pipe to splice into + * @len: The amount to splice + * @flags: The SPLICE_F_* flags + * + * This function gets folios from a file's pagecache and splices them into the + * pipe. Readahead will be called as necessary to fill more folios. This may + * be used for blockdevs also. + * + * Return: On success, the number of bytes read will be returned and *@ppos + * will be updated if appropriate; 0 will be returned if there is no more data + * to be read; -EAGAIN will be returned if the pipe had no space, and some + * other negative error code will be returned on error. A short read may occur + * if the pipe has insufficient space, we reach the end of the data or we hit a + * hole. */ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe,