From patchwork Wed Apr 19 08:54: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: 13216534 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 DCF5EC77B73 for ; Wed, 19 Apr 2023 08:54:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25A998E0002; Wed, 19 Apr 2023 04:54:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23E108E0001; Wed, 19 Apr 2023 04:54:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F9388E0002; Wed, 19 Apr 2023 04:54:20 -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 017188E0001 for ; Wed, 19 Apr 2023 04:54:19 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C7E3B402AE for ; Wed, 19 Apr 2023 08:54:19 +0000 (UTC) X-FDA: 80697529038.25.B748B81 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 033B41C0019 for ; Wed, 19 Apr 2023 08:54:17 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="E1NxjYf/"; 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=1681894458; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=J099iEeGas8X+c0Ugwu2YYwSR8o/a4NF1OsG1hAhZcc=; b=7FnptSZQiE2VaxD6BLtdprQYQCtUfyP0a0tZAR7bNEuTzd094m+CqPpwgeASTg9kUTNElq LxQGa0BVRhAYxyK5Bej5pMay7m26nd2B6s/yS16cDVh94Vz6pvpvtd9NUflt3iSD3rSai2 yvHBqTuUI6a57ho1O25PgrLHjtLi2Hg= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="E1NxjYf/"; 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=1681894458; a=rsa-sha256; cv=none; b=UmQJVewngajzgJ+NrhCKITDs/+LagYlC2iQUKnDaIUaiFn3T0rqmc68F5x6Ov1MQnYoAmo 7sYkBXg6oiyq1P+B7THlc9YQiTPP9bKA6dml6rV6nOsAIw4rNtubzWvHLs9ZXd6i89MjLy 6XYCZJC2PNt1I9kcrijO9Bbw/jnrkz8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681894457; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=J099iEeGas8X+c0Ugwu2YYwSR8o/a4NF1OsG1hAhZcc=; b=E1NxjYf//Dyhe34vdpIDycJkEsXgLmnhsduRP5H+RdrVxE35yRS1qs6AlV5n9FlMQpTEhQ vf4ZyM/SIcMEsz74DD0fUXW9r4ri46WH+9eLUY/Vn6FD5gtk8wTV4gKJ8xUd0/PswStvoe p4YypG+37HREIjMuh8uA6eMEwUpgpb8= 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-538-1ikd473jN-q5I59GX08wYA-1; Wed, 19 Apr 2023 04:54:14 -0400 X-MC-Unique: 1ikd473jN-q5I59GX08wYA-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 532FE101A557; Wed, 19 Apr 2023 08:54:13 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id A32BA1121314; Wed, 19 Apr 2023 08:54:11 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: Jens Axboe cc: dhowells@redhat.com, Ayush Jain , Christoph Hellwig , Al Viro , David Hildenbrand , John Hubbard , Steve French , linux-mm@kvack.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] splice: Fix filemap of a blockdev MIME-Version: 1.0 Content-ID: <1770754.1681894451.1@warthog.procyon.org.uk> Date: Wed, 19 Apr 2023 09:54:11 +0100 Message-ID: <1770755.1681894451@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: 033B41C0019 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 6q4gi8yf5zf4wzfs7ysurfjjnp36upwi X-HE-Tag: 1681894457-140517 X-HE-Meta: U2FsdGVkX18RjHlLrJh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wbWtWNj6bBSlTKAuAB3oN9xJU4mUezglhyQU/NDM+WPnqUR9OzaPybm8r8TVnjccdfGHQ7urJ2QF8XOS/T4tsq/O0glsZmx7150oRU5mTrHPXN8OVC5gTGsl8DgKKb6idRE6XANlQams1GSLSEssPtyc/Snwk+mEsA+vsUJe9Y0WkCWLtRJaILmX0N/6Qi/z3EM0XCHgFQxvUEFtwhKf0DFQn8k6nNuvFrn6tMT5GDZiIdTEjdm3ezN3wM206echfOT8u/yGuwBG4h7+Z5BJ5E79W3RQRSaOweSGA41z/oMZc4DV3fqqQvhxlNgJfrBk0oMqsYRt4pacPptmPcbqy1dVGC/7K/aX 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 the new filemap_splice_read() function to get i_size from in->f_mapping->host, not in->f_inode so that it works with block devices too (in->f_inode points to the device file, which is typically zero size). Fixes: 07073eb01c5f ("splice: Add a func to do a splice from a buffered file without ITER_PIPE") Link: https://lore.kernel.org/r/0c6b661c-f7ff-cf12-b7f0-00b6b2f1317b@amd.com/ Reported-by: Ayush Jain cc: Jens Axboe cc: Christoph Hellwig cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: Steve French cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Tested-by: Ayush Jain --- mm/filemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 470be06b6096..f86cc8acf33a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2902,7 +2902,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; @@ -2918,7 +2918,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);