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: 96215 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1054843vqo; Fri, 19 May 2023 00:43:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67XuQk38a0KNpqHkLyF1PuM/Q+vi7HfUZHdL7RdZ56eBMv8KrL3q/k5bjrxCxgWol3vH0T X-Received: by 2002:a05:6a00:804:b0:647:d698:56d2 with SMTP id m4-20020a056a00080400b00647d69856d2mr2137481pfk.27.1684482208897; Fri, 19 May 2023 00:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684482208; cv=none; d=google.com; s=arc-20160816; b=uPti5WWBu4fgw1yEC5ijCsg8SF669RgEG2ASq77VRXuLtQ6wYRA5rLbI75LVyguGlp 27BX9McJnCxS1IabyVj5i4ebFpteYtjRhJ4prInlgttFUoIg6fTMqoE4QhCwU4e36Ts8 pl+7b/Nd+Nojt/uYrEPQD/+hrl1wSerHleYc89ElcMUqHmyUAbnJ/j6gAIu2R/Bzo7XI qSDj0t0OkHZqm1VszblzUrlvr7q28ylquaUpCtFSVx5HxCPqXsPXqF83ds8Q1rsQyb16 8nRgJFymm/zTgYca/CkwzLcYNdADIPaPyvX13NK8zrQ0XmM9uHTWh2rNNfQ8EylJDn3j I+xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BN8k90GM05xGcXUwqmiE5oyub34c+VlFBbq2fGi5jWo=; b=faiWdDLl95Hjel8wGlHEnRcF28iJuLyPSZSReZ+FHjY2iqOVVKevXnWsFPbpo4SM1n 4q1ZwEyoq8Bgl+pHvgY/ClHtKo9cz0JX7Bf4gv1pNXRgmAW6kcNQEIB6zDZ0RE41+dxt k41PmMTUZwuFV83dxYvW+Dfiy1sC29Rj55G4lHsQlvI1MZ7ehPHzPTeQRHRBFV0eacfy Q6kMMy1vHy4UygCNdteo4tBZP2sH10CnO7DL8kGsxXYB5Z1AQV8WgubdI9rcu9MZcEuq vrCWGCAQBUViJPfM6SiKNupVFkASPiAGv819TXiks6cwOD1B8VUIYAdfynugLfxI5k8s Rteg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WV4vqEtw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020aa79522000000b006478fe28452si1166161pfp.27.2023.05.19.00.43.15; Fri, 19 May 2023 00:43:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WV4vqEtw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbjESHmK (ORCPT + 99 others); Fri, 19 May 2023 03:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbjESHmD (ORCPT ); Fri, 19 May 2023 03:42:03 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAF34E6E for ; Fri, 19 May 2023 00:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482072; 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=WV4vqEtwM2u95piKVcv32VaYxD2vcjyM03G/gmvCkyvXDkeZY4EGvyG8fWkGQXSUFdv9kR +y+mcCwjPDHb/YwxqQzftKWdM3rHj/zpFsqfzdKHGPzMfKiJSDF0gEH1iRp2eXMWsxeB7O 9Sa01w6D4Ibqb+/VLZSJZX7Q1yUo3MA= 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766307616998290542?= X-GMAIL-MSGID: =?utf-8?q?1766307616998290542?= 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);