Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp998476iof; Mon, 6 Jun 2022 17:43:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwddr83sWsUb5pCCPP/XGfXpMuQzeQWP5RAssBaihvjshJiBujp378RXsG45OHwkqgA7PYe X-Received: by 2002:a17:906:99c4:b0:6ff:46f7:b7b6 with SMTP id s4-20020a17090699c400b006ff46f7b7b6mr23744618ejn.707.1654562613060; Mon, 06 Jun 2022 17:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654562613; cv=none; d=google.com; s=arc-20160816; b=ir2aIp9hV9qZqjyzI/X9APMJ0wfKGW+UAh0PLzVgTVy1ynjdvtzwKlG7hHJzUPXP3d iYIX/P9umuSNZKrseoX5l0er+cEoyfOvW1O8caW5qPAxH2DqDtGguyyKzUogYp64INE1 Ekmwxxn99BBYcgEK0oLhuVzVtVuCw7zR71L4wgnnnEBXuiU12saDKMmtvFjoGRlBBJxz X9hShpcYeFfC1SYZEDVwETCOYUuGF/cImiDzWnC46ifRIf9fdvG/Tt3RduYJ8QuXANsQ nPJQIqq3OvJRaE0bGCaYZiZ+7yVOee9eQeIX7HKSUggUZ6z4CvzQmb/jsP9V7PnJWFpf Ncqw== 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=PTb1fSw49y2qxNUUq4k5t2uIOYf1rKQU0qM36b/uqdM=; b=wfmBqMMD7RgEMrst0YCObk2Wr1AahXd06/FY9kwoai1TKRHX3+IAh3L+hAwSQZhKiY eF1OuueOnVunmNWSrStJToEtmfxjFv7lHSiHG0E0dO7wD00jU/w8/c2WDyTZCCJNM1Nt lcgpmMnD+Af83OxXwGgIzXidrIaVcNLTozjl1x9APRwr5we/6mHn2h/hFptbVVKMfAaW zgBMAP2BA/ozY06BDcpETW/2XcGRc4pkik61+o35Kt3xZlnI3bXbyIAtdG3mkcX+7nT/ nhPTQWP4EOIQH1UnoruWwirySs6o1UBUjfz79SCCyF6AFyopHOiYVwFTr/NxV6ulX9+M 2SJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=moAsLc7x; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb25-20020a1709071c9900b0070f54c5a06asi14883131ejc.226.2022.06.06.17.43.02; Mon, 06 Jun 2022 17:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@infradead.org header.s=casper.20170209 header.b=moAsLc7x; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234448AbiFFUvT (ORCPT + 99 others); Mon, 6 Jun 2022 16:51:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234664AbiFFUt4 (ORCPT ); Mon, 6 Jun 2022 16:49:56 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA339F5BE; Mon, 6 Jun 2022 13:41:28 -0700 (PDT) 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=PTb1fSw49y2qxNUUq4k5t2uIOYf1rKQU0qM36b/uqdM=; b=moAsLc7xAe9cCO2yLS/2VDmHEw YBwWTVJr9kJRjwoeFhsNnd8JLuuJjbq0xBtc3hJNd0koz0AzNRiu2y+N5Os1g1/u53LaRvxXW4rdM tHwy5XlETEs430Lov51yIttD+nu/AmMuCt1+6O5d08aKIMBYPTBY0Yt54xqFYELLNo0/O6twSwDnU wa3c1U/y/ETekmwC5gKHpa1nMck5VNxLTjucI7KCgMp9l5cOztmW0nCXmpkBfBeAli7aijjbj7GhC zHPVo0ax+4QE/HagbZZ6pGGOB2yVWmyQYd5p+40+xWsAl8Ab1eGJlEDyjqzfn+/+j35DgUlM4Y7a4 FS4d0iCw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyJWw-00B19S-UW; Mon, 06 Jun 2022 20:40:54 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-aio@kvack.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-mtd@lists.infradead.org, virtualization@lists.linux-foundation.org Subject: [PATCH 05/20] mm/migrate: Convert expected_page_refs() to folio_expected_refs() Date: Mon, 6 Jun 2022 21:40:35 +0100 Message-Id: <20220606204050.2625949-6-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220606204050.2625949-1-willy@infradead.org> References: <20220606204050.2625949-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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-ext4@vger.kernel.org Now that both callers have a folio, convert this function to take a folio & rename it. Signed-off-by: Matthew Wilcox (Oracle) --- mm/migrate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 77b8c662c9ca..e0a593e5b5f9 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -337,13 +337,18 @@ void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd) } #endif -static int expected_page_refs(struct address_space *mapping, struct page *page) +static int folio_expected_refs(struct address_space *mapping, + struct folio *folio) { - int expected_count = 1; + int refs = 1; + if (!mapping) + return refs; - if (mapping) - expected_count += compound_nr(page) + page_has_private(page); - return expected_count; + refs += folio_nr_pages(folio); + if (folio_get_private(folio)) + refs++; + + return refs;; } /* @@ -360,7 +365,7 @@ int folio_migrate_mapping(struct address_space *mapping, XA_STATE(xas, &mapping->i_pages, folio_index(folio)); struct zone *oldzone, *newzone; int dirty; - int expected_count = expected_page_refs(mapping, &folio->page) + extra_count; + int expected_count = folio_expected_refs(mapping, folio) + extra_count; long nr = folio_nr_pages(folio); if (!mapping) { @@ -670,7 +675,7 @@ static int __buffer_migrate_folio(struct address_space *mapping, return migrate_page(mapping, &dst->page, &src->page, mode); /* Check whether page does not have extra refs before we do more work */ - expected_count = expected_page_refs(mapping, &src->page); + expected_count = folio_expected_refs(mapping, src); if (folio_ref_count(src) != expected_count) return -EAGAIN; -- 2.35.1