From patchwork Fri May 19 07:40: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: 13247756 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 A45B2C77B7A for ; Fri, 19 May 2023 07:41:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 285F9900007; Fri, 19 May 2023 03:41:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 20D04900003; Fri, 19 May 2023 03:41:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0603C900007; Fri, 19 May 2023 03:41:16 -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 E737B900003 for ; Fri, 19 May 2023 03:41:15 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C05D1A09A2 for ; Fri, 19 May 2023 07:41:15 +0000 (UTC) X-FDA: 80806208910.04.6799015 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id F1DBF40013 for ; Fri, 19 May 2023 07:41:13 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Atd8wBv4; spf=pass (imf17.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=1684482074; a=rsa-sha256; cv=none; b=M3jqbIOodt+lSdLYSS+WegskZuEoqTZP3Qlz+GlkW7lMzAMfPgL2AxSwfjqUDQ+jrySEgs 0u3TGtO9Q+xc9Gl4SFQ4YbXoasHOeUhvjUZs6rn0C/Jui6wK4e4e9S6npTKn0FVp9X9zGO 0upmbNGHWwUz8ZM6AmRctkvbGLqIBCA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Atd8wBv4; spf=pass (imf17.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=1684482074; 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=BN8k90GM05xGcXUwqmiE5oyub34c+VlFBbq2fGi5jWo=; b=XT99TzcvQ6mK3c1vWGxp4F3cp3fbhUzZ5LnRTFZ2BcnIIjTU68eswM9Ag3Pxp1Kz920fDX /8hxW6qG2/UguENzzBjavUy01VRZYmcYjFVnnWFXIcDri/Tu2WTNrEFOPwQLAFSJi2DsJ0 KirUKl1Dcld6Y1wt4mJHIXxBA/34nx4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482073; 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=BN8k90GM05xGcXUwqmiE5oyub34c+VlFBbq2fGi5jWo=; b=Atd8wBv4C3HOntXIH5KpI41nfIOqi3PwRTW3eYLArD3OPPIXeX3WbDF8XiPezaBC/izVCK HQmQZqXjg5KE9v+JFaK82G5cU4sF0c7pHc19dTqzew19VnfdCCxpGOI0PH84DI0OCjhFGp HQpyvXU3FUr0uxG4dNPvkm1M2o078FE= 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-541-i2ERw50uOo69R7scCkPSwg-1; Fri, 19 May 2023 03:41:08 -0400 X-MC-Unique: i2ERw50uOo69R7scCkPSwg-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 DCDB029AB3E6; Fri, 19 May 2023 07:41:06 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6BAC1121314; Fri, 19 May 2023 07:41:04 +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, Steve French , Christoph Hellwig , John Hubbard Subject: [PATCH v20 01/32] splice: Fix filemap of a blockdev Date: Fri, 19 May 2023 08:40:16 +0100 Message-Id: <20230519074047.1739879-2-dhowells@redhat.com> In-Reply-To: <20230519074047.1739879-1-dhowells@redhat.com> References: <20230519074047.1739879-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: F1DBF40013 X-Stat-Signature: adq5dgjxuw43jid7kf895xmjisedk54f X-Rspam-User: X-HE-Tag: 1684482073-235291 X-HE-Meta: U2FsdGVkX1/wsXeZhRMpDERGsbyfOw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Niw+G9DBHIXRMLvz5Udi0pD1+y8QhJR0tzZKieDyUAOscsmBjKsvSgEq/N+iB2mf0hSSWexiWsy2OyVVsPntaEbAqdkTU3Zk8TuSQWOttNsNkGkWGa+7tBUEdkYCEHdpq6xTXgw2dLtrmMak8YrU2pufRkXi0fCWZ6iYt6H0PLFEk9thWazGOA5LBKWau3cbJRc69/UGKjGv2zbCcxFV18kyHdocezEMhXP/gpR4xMzs9/IizFPU9pU2TlhUQB5KhIt8tqXY= 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 cc: Steve French cc: Jens Axboe cc: Christoph Hellwig 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 Reviewed-by: Christoph Hellwig --- 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);