From patchwork Sat May 20 00:00:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248982 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 0DEEFC77B7A for ; Sat, 20 May 2023 00:01:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C4FB900005; Fri, 19 May 2023 20:01:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94E10900003; Fri, 19 May 2023 20:01:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EEB0900005; Fri, 19 May 2023 20:01:05 -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 6A1D3900003 for ; Fri, 19 May 2023 20:01:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3B497C0B00 for ; Sat, 20 May 2023 00:01:05 +0000 (UTC) X-FDA: 80808678090.26.A28C3D7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 02B901C000B for ; Sat, 20 May 2023 00:01:01 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Msprf/CS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.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=1684540862; a=rsa-sha256; cv=none; b=WQR33ZCedF5pNYNtdyGLX5ZBYMsvN7S6AkVIFEqwamyvcXe9h7YY6VK3iZMMdY/pRH6DkZ pTXkGiPMyPLV5Q1AXrOm2zHn+WT9EH4WZb8ZR64KWGNsUfD4XJH0zIbpVxW0H2VKs7+gZY YU65pkMb+n/hLNvRX6LFK/KJC+8U6Rc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Msprf/CS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.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=1684540862; 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=j9lKnYQLAbUm3aZ6/GDqCuwrLRq8hWqBI2gRgBsDQ1U=; b=vJxgKQo6LZHN4SVGOcGYwI4filN9I4mWNuWi4XQPFc4UtjgVirYG8w8L/OO6CweIHRxtvR fkwKsa1iCMJJqfVvjmeW42rLTpvdfKKfl/yb+33+T7JLfNdEO0xTlJaxxrwIW18Bcej0Gh hPhOutc+Hxj5O6ZDmQZhfdt0ng4Cc74= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540861; 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=j9lKnYQLAbUm3aZ6/GDqCuwrLRq8hWqBI2gRgBsDQ1U=; b=Msprf/CSyhnY/NPUpdL63MrIinhyhh7jv6t7P2Ctw8yi2/691apfRQRQ8LikHNRs5bFtvl +zqgi5k0qBLI9PWOz79W8Xss/gIyC5Evd/Dw0wXJFh8a+Nvi4G2mxJfOa+InzlxsOX89LJ 5qQbhgv3fTuh4Fdvz+VjRjW9HeclVqc= 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-596-HCwIrqq4N0uEJGXPHYI5kg-1; Fri, 19 May 2023 20:00:57 -0400 X-MC-Unique: HCwIrqq4N0uEJGXPHYI5kg-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 EA588800969; Sat, 20 May 2023 00:00:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE04C2166B25; Sat, 20 May 2023 00:00:54 +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 v21 01/30] splice: Fix filemap of a blockdev Date: Sat, 20 May 2023 01:00:20 +0100 Message-Id: <20230520000049.2226926-2-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-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: 02B901C000B X-Stat-Signature: bes6jtmhi8aqytcfcxwzsuhmf8eqfo17 X-HE-Tag: 1684540861-379528 X-H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jc+uUwtTqGu4KnJdqWUDXZeMlMMzPjT5uEO/8ubSOaM4SELcDiURgewcNA53Slqun756DrZ0Y4Gj1O+/6+7ig01EaMFv71dF+WmxzmH0+kWSte/e3urylz2jKQy2Q4bAZ/G3Jwxo8qzGQww01p1NwxFn06wKCD/O41c49O8r6e1MJ3iJs5oAyqlI9ihtzsKfiM1MXLK7t6K4hPXa20MRmANV0Y2UJ2bf2Cm2WeLs9PwpDSKwJSirk25esYuqBKFU05imUkEmQQJfCbp6ROc1DGw+nVTRT5kZdH9QgQwLu4/IvV5NVM4OgRJMTUAM= 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 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 Reviewed-by: Christian Brauner --- 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);