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: 96678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp40953vqo; Fri, 19 May 2023 17:03:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5QtcCWSS0ud/ySosFAQf681jpakpxDEUyLKbzWIxGW9S5zpCvEgoJqsiC5eLY8tmhj+rkh X-Received: by 2002:a17:902:dad1:b0:1ac:86b5:70eb with SMTP id q17-20020a170902dad100b001ac86b570ebmr5112637plx.39.1684541002833; Fri, 19 May 2023 17:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684541002; cv=none; d=google.com; s=arc-20160816; b=tpZ9XRAWkrxuC2QkbKsNoCoN6BvVV4wnw7DCIlrxxjRYPtVQyy7tQA92ynZy2+GeOP U12TQ3A/yIaeMI6X4HjffRVI0PO2ECQ635+Bd6qqBqUBVtNFYbrWqYZ7+VZF1Dp+u76s BW9UNA5TCvjNiNRT0xtif+3OAad/1xWPwur/k0pThYo/BD9dacIwkIBLZCQve0qshXda 868H/oGbkhDDvZDD86O3xfxYTtmDRg8tAU1miIxQRo0EW9xX1bCfqnVX7sMjwMp1M0B2 YhtvAXquJyf2CHwXqeX/hxL7wZMaBYYdtTLwDDw3G3XIvIw6R9+n4XuSVMIqoBgIz0qO 7wzw== 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=j9lKnYQLAbUm3aZ6/GDqCuwrLRq8hWqBI2gRgBsDQ1U=; b=FCeIfR9BvboAd+P2TWdPDT9Gj3s6bnazelkm3bX+JykDnxoIvCMTPUIBmATFjaH8ZV ukS1SuXO/JxsoUlxv1Vdsl3R0Pfnw5yQRkgJOgbhVIOqAyckz9gF5s7Z7JgRK5qnSW4U t9K35j1yRzzwwLARGXnR1N2My45rlF4UDaKV04O6lvLLZcPgOp1DIyUBpXTrWrGWhpmp BtPtVfva2gfgWECWA14SZJpZnRCW2uOOU3Xo86qhXKgfqtPlbYfwC0ERAyhg8sqrVIk0 tXaMq1pBvaZf5XMowi0RdFXkzYegjStkObLpaOSUfAKQ3o/bFRh7OKeKmDMHO37QurrR zRaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VaQStPJc; 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 c9-20020a170902724900b001aadd02b88fsi336136pll.233.2023.05.19.17.03.10; Fri, 19 May 2023 17:03:22 -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=VaQStPJc; 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 S229916AbjETACh (ORCPT + 99 others); Fri, 19 May 2023 20:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjETAC3 (ORCPT ); Fri, 19 May 2023 20:02:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A103E56 for ; Fri, 19 May 2023 17:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540864; 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=VaQStPJcioHeNZDpxPkJsEkuEkk7afro6ShXmifoz7fBKWKNcMTgBM+P4RfUhjsU+TKOgv 0b7exeuDPV8zhN88XO3KirZ5IwETB0eHpONGdt6Q1veHgDpgsnhULlQ+5iVh2cHxDUObkb HiKfc38HH/v4QzFJ0z7I7ICW++y+hF8= 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-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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1766369266794497190?= X-GMAIL-MSGID: =?utf-8?q?1766369266794497190?= 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);