Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2404733rdb; Thu, 21 Sep 2023 19:00:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJ2ayuxQWWwmAgmFYmxXpknSTozYXarIt78cDkzH2ushHzv54mXvwUVN2vku2WblxdT7f2 X-Received: by 2002:a05:6a00:391b:b0:68a:2272:23e9 with SMTP id fh27-20020a056a00391b00b0068a227223e9mr7433888pfb.17.1695348002036; Thu, 21 Sep 2023 19:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695348002; cv=none; d=google.com; s=arc-20160816; b=sV+0cJm78HyKtZIu2tCxRU1ehpn5q2sazCo4lP2odl294PrE5ObvWCDF9Sx0p1+dYh HmfCTDT7tDds+jytMCGef5t5q+cKtv/jAx7h4F6N5MSN0IvNMsPHodP4PH4cdRI4NlQF krk3XIefQUkYu35M2uKWLyKy5hsMAqDOFq2X8XZZPR8IXAOHe7LAISTpDWuJ5ZIlxFPe vBfY6ZkAOCrTHQQsKDWLQneI9VzLLQ3amDN32KwjobGFMz+ORaDw3v8uSYqfVM6I6UZ1 YzHlAcTwWTwNZCz4orw1sONQLlLrwwrwDFJXu0FJ7vKxp2TE5c/8e8p+Lq00LDiAeCi3 RYGw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MrSoluGCY0RkfJ7LMGD8f0s00qedWA5ibN1YzRdIqeI=; fh=c8NKFRvP9+Ml9XvzqG2nGqhVxTjW39J/I/tkc5xa6gs=; b=kiXyxU+wd4MOvN3lkKaoYEPVDS6+gPS33yriimR3yrU+5+5KnXDd7aHlHGWXCj28YR gh+7+S34ljHZ9idQY1BnCwNKjpzjXsQC18GJ31dWNOhbN8FD+eDNZNJfAIo74VAWoqRv rw5R6epkWYYV5MjmqIKNTeDyV7kyObV3js46G0XcQnXr9S38z5kEYGbZsn5pr1c78SN3 7w2JkcsXC0sKD+BMe5fyc9+Bo4yU7fbOHOdxcWKRqrLFu+ekyI3r3zCzDsDxKhuQ+PXG dhkeGJ7W0/SYVFW4yhOL1FBVPE869nuB4u4u2Y6nSHElNP2Q+RSsHgbjOvayol9vAaBM A+/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=thOt56is; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id m9-20020a654389000000b00578bb707e6esi2583523pgp.806.2023.09.21.19.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 19:00:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=thOt56is; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3D60B8329970; Thu, 21 Sep 2023 13:29:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231744AbjIUU2q (ORCPT + 99 others); Thu, 21 Sep 2023 16:28:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232064AbjIUU2X (ORCPT ); Thu, 21 Sep 2023 16:28:23 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 580BD3BE19; Thu, 21 Sep 2023 13:08:05 -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: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=MrSoluGCY0RkfJ7LMGD8f0s00qedWA5ibN1YzRdIqeI=; b=thOt56isfl93if/g9mytqyCLeG Ks9Q8qpnuGmXXpOYg7aIodR53wVzOrYnra38jO6RgPpUodwuqCD6a+YUfKvwauMqkSQMsZQYhR18R 8GCH/scc39BK4hOrPryEg+F37SdIEfGfjMF7uRKwzFbsV+KhWONI1nQXVqzF4QOxzPKIotN7iCrqJ BxMPwV1r3qa6U13aco8KyRsYA7eQDR1dh9S7ro21hiIV+mo8rAyZJCAhrqri4bRZowxJ/Xvtph4K2 B1nQcGz55t2358gHKXqg91qoeu87BLmhR9fTAOBWeEpyTpU545R/udqWm1L2EClCBLIBQUEeZ0US+ WO1K7nNw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qjPxj-00DrVg-KT; Thu, 21 Sep 2023 20:07:47 +0000 From: "Matthew Wilcox (Oracle)" To: Jan Kara Cc: "Matthew Wilcox (Oracle)" , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Fabio M . De Francesco" Subject: [PATCH 01/10] highmem: Add folio_release_kmap() Date: Thu, 21 Sep 2023 21:07:38 +0100 Message-Id: <20230921200746.3303942-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:29:02 -0700 (PDT) This is the folio equivalent of unmap_and_put_page(), which remains as a wrapper for it. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/highmem.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 99c474de800d..4cacc0e43b51 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -551,10 +551,24 @@ static inline void folio_zero_range(struct folio *folio, zero_user_segments(&folio->page, start, start + length, 0, 0); } -static inline void unmap_and_put_page(struct page *page, void *addr) +/** + * folio_release_kmap - Unmap a folio and drop a refcount. + * @folio: The folio to release. + * @addr: The address previously returned by a call to kmap_local_folio(). + * + * It is common, eg in directory handling to kmap a folio. This function + * unmaps the folio and drops the refcount that was being held to keep the + * folio alive while we accessed it. + */ +static inline void folio_release_kmap(struct folio *folio, void *addr) { kunmap_local(addr); - put_page(page); + folio_put(folio); +} + +static inline void unmap_and_put_page(struct page *page, void *addr) +{ + folio_release_kmap(page_folio(page), addr); } #endif /* _LINUX_HIGHMEM_H */ -- 2.40.1