From patchwork Tue Feb 14 17:13:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13140600 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 37A1FC05027 for ; Tue, 14 Feb 2023 17:13:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 194A26B0078; Tue, 14 Feb 2023 12:13:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 144106B007B; Tue, 14 Feb 2023 12:13:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00C436B007D; Tue, 14 Feb 2023 12:13:47 -0500 (EST) 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 E2A316B007B for ; Tue, 14 Feb 2023 12:13:47 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B18ED16085F for ; Tue, 14 Feb 2023 17:13:47 +0000 (UTC) X-FDA: 80466544494.04.BD19F79 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id E71FCC000E for ; Tue, 14 Feb 2023 17:13:45 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ab+l4l18; spf=pass (imf28.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=1676394826; 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=zSLOPyPBTyGpP+6+bR7yKU/VhAXOTSaAngOTYdMp3ic=; b=7r89XYxTiHBiptPfbzF1f6W/cxXEcojGmwsl/Kpo1gteW4SCGkkbtq3o3TZQ2gJsFAyY1Y 2xEHmS5ZKmGS/PciALLezzX/qH8P5pII2nvNQikf2MLrEEQoQov6ugtkcBB9Pe1B/JweLd kZVxQQieV6aZym+gmqI3K9DWY56/Uxk= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ab+l4l18; spf=pass (imf28.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=1676394826; a=rsa-sha256; cv=none; b=ER/6cLzD5RoUQQF82B3lBqBAsEVTtifKgvaFnFqbpwL8cps0iwpX1HodpzSoUh+4w+Ql5I Pu1PuM/l5VBxL9OHVEq/jg4ZIw/4fOH3M9c9YOM3lbXHEg5NZXFfJEc4Zlvlz3bnc5TMGb 50/zNAna3B6NTgF9VTL2OYg9b0f3fbo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676394825; 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=zSLOPyPBTyGpP+6+bR7yKU/VhAXOTSaAngOTYdMp3ic=; b=Ab+l4l18HMer0UkCotZtzJxCXsKRuUDnXLPb/4rHVHLifcBrFqsKXqxySP6cswV7sLkDck 2hs+qnVxlyLU3QJYtubGRRlmT0wBuJw1Op7reV82gEP/TjU2F2KTWj4BgNJQMVCacziW49 7+DxLuXi3QXLbzqB9TP0UUlm7mMqXQU= 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-237-r6zz-Qt7OtqamK4CCCrB6g-1; Tue, 14 Feb 2023 12:13:41 -0500 X-MC-Unique: r6zz-Qt7OtqamK4CCCrB6g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 095C2101A521; Tue, 14 Feb 2023 17:13:38 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D5A4492B03; Tue, 14 Feb 2023 17:13:35 +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 , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , John Hubbard Subject: [PATCH v14 01/17] mm: Pass info, not iter, into filemap_get_pages() Date: Tue, 14 Feb 2023 17:13:14 +0000 Message-Id: <20230214171330.2722188-2-dhowells@redhat.com> In-Reply-To: <20230214171330.2722188-1-dhowells@redhat.com> References: <20230214171330.2722188-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E71FCC000E X-Rspam-User: X-Stat-Signature: ga51k8qgtyh51bdodmmjhcsc5bh437ro X-HE-Tag: 1676394825-190680 X-HE-Meta: U2FsdGVkX18ZliY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ZIfzoliW7I6Uq1HwsQmuuAi+KaqlB1YfL5klc6oYNxsWnN8KavzsG+0ZYzWt7aM8d5Gm7ePNpVLrq6w4kVVzdLSBeXFFQwQdYWJB8vUBd0iHdM2w425Z7kOt3QpXiuzRWjqw/4LddZnBMXURhYuVq9jUy84e1MfBZTaGhwk5o+7ZbD8gRxyI/+Vp4ZyCbGJTxh7lYTHRscHVbKhUhStdiGS1I+I2elvmt85MZgJ593fHukp1eLCXmRQwdptw3+YYayZS1OYGEFCeL62JvcLKPlaw9SSHzb+Dtx6NtXYA821PT4Ajalt++4w6lS+gqFJVj1AF0xzlkNXNVHG5s0k1tQ9LTuWCFgYR5jWvn2FdrWzgHKWkMg9g4otaP2UsFqbR5ygH2DEYg== 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: filemap_get_pages() and a number of functions that it calls take an iterator to provide two things: the number of bytes to be got from the file specified and whether partially uptodate pages are allowed. Change these functions so that this information is passed in directly. This allows it to be called without having an iterator to hand. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig cc: Jens Axboe cc: Christoph Hellwig cc: Matthew Wilcox 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 --- mm/filemap.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index c4d4ace9cc70..876e77278d2a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2440,21 +2440,19 @@ static int filemap_read_folio(struct file *file, filler_t filler, } static bool filemap_range_uptodate(struct address_space *mapping, - loff_t pos, struct iov_iter *iter, struct folio *folio) + loff_t pos, size_t count, struct folio *folio, + bool need_uptodate) { - int count; - if (folio_test_uptodate(folio)) return true; /* pipes can't handle partially uptodate pages */ - if (iov_iter_is_pipe(iter)) + if (need_uptodate) return false; if (!mapping->a_ops->is_partially_uptodate) return false; if (mapping->host->i_blkbits >= folio_shift(folio)) return false; - count = iter->count; if (folio_pos(folio) > pos) { count -= folio_pos(folio) - pos; pos = 0; @@ -2466,8 +2464,8 @@ static bool filemap_range_uptodate(struct address_space *mapping, } static int filemap_update_page(struct kiocb *iocb, - struct address_space *mapping, struct iov_iter *iter, - struct folio *folio) + struct address_space *mapping, size_t count, + struct folio *folio, bool need_uptodate) { int error; @@ -2501,7 +2499,8 @@ static int filemap_update_page(struct kiocb *iocb, goto unlock; error = 0; - if (filemap_range_uptodate(mapping, iocb->ki_pos, iter, folio)) + if (filemap_range_uptodate(mapping, iocb->ki_pos, count, folio, + need_uptodate)) goto unlock; error = -EAGAIN; @@ -2577,8 +2576,8 @@ static int filemap_readahead(struct kiocb *iocb, struct file *file, return 0; } -static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, - struct folio_batch *fbatch) +static int filemap_get_pages(struct kiocb *iocb, size_t count, + struct folio_batch *fbatch, bool need_uptodate) { struct file *filp = iocb->ki_filp; struct address_space *mapping = filp->f_mapping; @@ -2588,7 +2587,7 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, struct folio *folio; int err = 0; - last_index = DIV_ROUND_UP(iocb->ki_pos + iter->count, PAGE_SIZE); + last_index = DIV_ROUND_UP(iocb->ki_pos + count, PAGE_SIZE); retry: if (fatal_signal_pending(current)) return -EINTR; @@ -2621,7 +2620,8 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, if ((iocb->ki_flags & IOCB_WAITQ) && folio_batch_count(fbatch) > 1) iocb->ki_flags |= IOCB_NOWAIT; - err = filemap_update_page(iocb, mapping, iter, folio); + err = filemap_update_page(iocb, mapping, count, folio, + need_uptodate); if (err) goto err; } @@ -2691,7 +2691,8 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, if (unlikely(iocb->ki_pos >= i_size_read(inode))) break; - error = filemap_get_pages(iocb, iter, &fbatch); + error = filemap_get_pages(iocb, iter->count, &fbatch, + iov_iter_is_pipe(iter)); if (error < 0) break;