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/5dDwEoXQlaLMqau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OrT7eFG6lZZG+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);