From patchwork Wed Oct 4 16:53:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13409063 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 DCB7EE7C4E5 for ; Wed, 4 Oct 2023 16:53:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A1EC6B0269; Wed, 4 Oct 2023 12:53:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6798D6B0266; Wed, 4 Oct 2023 12:53:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CB0E6B026C; Wed, 4 Oct 2023 12:53:24 -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 3B3466B0266 for ; Wed, 4 Oct 2023 12:53:24 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 13B59140371 for ; Wed, 4 Oct 2023 16:53:24 +0000 (UTC) X-FDA: 81308374728.24.54FA9D5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id C17C1180014 for ; Wed, 4 Oct 2023 16:53:21 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YtNGtSMz; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696438402; 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=+0PawpxhJKqaj77T374P+o4JeUu6sT89JK6ue2yK9T0=; b=TcBMP9LDlocRO/oAF69a0vMHoiTDTSLG+Tln79vtYjRv4ORFVI8tc2xiGyHrlrcEp75X2B bN6TpnN5Qx9IIVBl23qiljdJoM7A/jcLGIB2NwA7oPnOMXKNQJjdgopD37oFDFjJpzzD3Z 01NXq1S+71dyugdH9qRdTr3uy6tbFwc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696438402; a=rsa-sha256; cv=none; b=LPvnyGy7uSx1l1FQPCtxmaPlRw7ZGkspzkklDW6dykpx6PhHNtvL1Pl/hOR+IQICYF6S3D KqLUVpIVTwq1x+q3xqiJ6JnadB8TsKg2lQfMndKyP1ODObaPY7ay4kZR2fO48MvHXJfhQE M5gkFfd1O0/uMIGAz0H/cQsN61/vo10= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YtNGtSMz; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=+0PawpxhJKqaj77T374P+o4JeUu6sT89JK6ue2yK9T0=; b=YtNGtSMzne6N+0JeD40RVE95Pv 2LaBF0plT+dXJTT9umXL9Q5qH94HYx6QSxE5QGemVyAB+9qEYNOT01LEgHewvUIBwN+9CI5PB7rq6 V5RF+KubKhJsLsz/OCz1jCq5k9YDLQX0jJeOWqvB/xZqbrmDwN65iDoS2M/N04QW9IbCzVHaA79v3 TY7Q+Bi0Jfx2ve9d3/ryDr2L5Jde8QbzA20cm4EyfXY0A6IGsnqwIYyU1oPZHj5S9eibEbOV5BOCw L5FZQALvQ8eYHOf3cdx1O/M0HmQ7xHKgkP5uWOZlwFPTYoBIjWnmMMjt1EGy3f1zmuTJJHFMFzLvj oqp7VTFg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qo57f-004SEx-BB; Wed, 04 Oct 2023 16:53:19 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, torvalds@linux-foundation.org, npiggin@gmail.com Subject: [PATCH v2 03/17] mm: Add folio_end_read() Date: Wed, 4 Oct 2023 17:53:03 +0100 Message-Id: <20231004165317.1061855-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231004165317.1061855-1-willy@infradead.org> References: <20231004165317.1061855-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C17C1180014 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ju9ya1ubedtqhgw8cxpcxpjqcigkiy4w X-HE-Tag: 1696438401-915664 X-HE-Meta: U2FsdGVkX1/pp42HK/Ja/+0thvJqaH2oP3ARVAcMs8raziwchc5bhBBrjTgfOFXCMCqkvhgRiJbi8phHWz1d57Us5qwOzgrIl9LbbcTiKaRyyLbizMOx6hRkzE6dIc8K/il5oBk1xSbQfMeA47NtMhtMXFzeSLYxzyLfqmDCRCqDrGIbVFq7B3f4LR6eXBZnSLIkFnn/4usj8vyWhPTmQ7nGeEArqbsmgxBgpkWt7yU9Me56MsJsd2bKxBiW0bYNef5SQkxpZSRVQLTavDsKInvA0iOb+SIDSofSYnWhUH/R8x8p8erR+tkrTNTQK6NkUgMZ79WzFozFESpBXaiM+DPdl7k1eIB9RonEtyT/1/KWsrV7/VNc/j3y0y6Wg+7yl1gBzz6fgV1oJjyas/ZbUJVwLhcySRAH/M1jjnSIz3NJ/2EsAPhJ35EhaTt0GENH26ALX0FKG5EeLV42RUfTE4vVh3B+MjIXmj80P8Q0Qu3T1Cvas3rXgZvvE76ECXuF+AsgcylY/E/52fHY54M+mLlWABBjB+V86QW2ub6sWbi1TwysenzjlKFgmao1Z+t60fiOzVR//CvyvsH6Yi2cPlEL8V8hf9EDZ69EyMVnVvC4yBNLOlMuJ50oVTJ6U/cdXUD/6b8uChvk1MG3D3u4mZqPhTHYsrR/Q8i9gfdRoCWEC8L7XkxxkB+YlJqxM0aR1ddR/5gpoVBm50aL3LXaHw16S6aKtE/G6YGzEzwScpAYrGDsdLpYOCeOeniAL3jOLAHYVS53sVDqD74XxU2tcwm6oyarcdmpvbzM0XDd/VPH83yQ5lU/Jylwhr37eVB2lBpRc8KyDQME57110DotbWhY9KqDJ24nnW27t88EVRuHkAkYAaVp2cGTZvzHExaaibrU+41A50T/Zlb8Hf5sjQW+BRkVP2BxB76qI7frB70CO6DH1IEV3++tDRnockGoFXDFAI06uCU8kjWBeWy kcUF6Vtl zLdDPvkPHQ9yHxII2v/u/sdR2rDQeyGfyTIZtfAU3X+44J/OiFdhUx5eRR2Z/kpgU0eJdAmalYt95b3jaXiAVUzWsJGzimc0knwFP4SNHP8pLAAcvyX40SyaFyadjUI+yeFAPwTB0QNxztr7CeBdTYasJSljhDcjVUJHz0YE/dXYLrVfaczgxCZDSP0LYc23600KWcrSAtFshkgFhNKStk8v+R2JwgxjlbEgQ 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: Provide a function for filesystems to call when they have finished reading an entire folio. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 1 + mm/filemap.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 351c3b7f93a1..5bb2f5f802bc 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1129,6 +1129,7 @@ static inline void wait_on_page_locked(struct page *page) folio_wait_locked(page_folio(page)); } +void folio_end_read(struct folio *folio, bool success); void wait_on_page_writeback(struct page *page); void folio_wait_writeback(struct folio *folio); int folio_wait_writeback_killable(struct folio *folio); diff --git a/mm/filemap.c b/mm/filemap.c index f0a15ce1bd1b..ea317cdf9532 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1527,6 +1527,28 @@ void folio_unlock(struct folio *folio) } EXPORT_SYMBOL(folio_unlock); +/** + * folio_end_read - End read on a folio. + * @folio: The folio. + * @success: True if all reads completed successfully. + * + * When all reads against a folio have completed, filesystems should + * call this function to let the pagecache know that no more reads + * are outstanding. This will unlock the folio and wake up any thread + * sleeping on the lock. The folio will also be marked uptodate if all + * reads succeeded. + * + * Context: May be called from interrupt or process context. May not be + * called from NMI context. + */ +void folio_end_read(struct folio *folio, bool success) +{ + if (likely(success)) + folio_mark_uptodate(folio); + folio_unlock(folio); +} +EXPORT_SYMBOL(folio_end_read); + /** * folio_end_private_2 - Clear PG_private_2 and wake any waiters. * @folio: The folio.