Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1187369rwl; Wed, 12 Apr 2023 09:19:39 -0700 (PDT) X-Google-Smtp-Source: AKy350aeDbRlXYJ2hc87UGz1CBysRYRY1tcmpO1ThfeFEOy8YXE4QHee6PDEJFx/OCcNiVjxv2Lq X-Received: by 2002:a17:906:3958:b0:94a:4ec9:cf27 with SMTP id g24-20020a170906395800b0094a4ec9cf27mr10883897eje.20.1681316379402; Wed, 12 Apr 2023 09:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681316379; cv=none; d=google.com; s=arc-20160816; b=MDUXdU7D85y3uO0QSRKgfRYcXS0cYNG+ye/MUySX5sd+P2WgFowHtMBPx75o4GomVB YgtGTEwb5yqWzErdEpTPC7/lqoAtOLB+iwd5uVzSKdkaAOM0YffvGVCcWmWLWMuQ/68+ hmOHQBgKRRUDiAqJTEp65SyLh8lDLr3eWNdwZMvlU1jV9HzXx8GYx9GWjCuLp9t/8jgf zapmKGPGYWzdogAiLx37NZtc65eG0hM7heOhmuWpkR/mjnOaX5sk1wtarfjC3o0MZOqt uq7TAngcgAys9rv70rYuvcK1lGlQVkYen12sYJWwtXGJSOzVdgEZ7ZvhxefPB9KaK6n+ 0qBA== 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=6tHcvpNWiPht801PO9Zrv9yhnQM7CzF7GEisM5jFpsg=; b=YmqYd3VXScitbn2CQO8h+0FlIwNvc1EqgEFbmRk3d2EBNKbf1X8Pznd0+YxioKrXc6 EdJVP+HpbHhTlLoA4LHcS4OuuOmvnhqKAiKJplCFYGzEbulELfnLzwxkXy0kGmWB75YO bSfZqrwwjoSNNVwiwMfCCHg5SnaXQ2yezo8o2VF+URq+vqxmhg5DkIEjupRw15wByB3x 44fny8MyDh9g1gXMHWoXJZ7n2CEj3fQCPVARebXpCanygJwqFpqLH7pzEs34qd3vr7vx l/xKM4gxtE33Z1nrjZ4w5yY1LIY6mEOQVNIkpvepLlJ7Nr8aX8gjVB1+Ui9GmhoKLXlE /9HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BTJQXgFh; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss13-20020a170907c00d00b0094e4d067a3asi2073714ejc.991.2023.04.12.09.19.08; Wed, 12 Apr 2023 09:19:39 -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=@kernel.org header.s=k20201202 header.b=BTJQXgFh; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbjDLQI3 (ORCPT + 99 others); Wed, 12 Apr 2023 12:08:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbjDLQIZ (ORCPT ); Wed, 12 Apr 2023 12:08:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5386D6E8B for ; Wed, 12 Apr 2023 09:08:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E379E636C8 for ; Wed, 12 Apr 2023 16:08:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 476C9C4339B; Wed, 12 Apr 2023 16:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681315702; bh=ErdIVpMC3VDYiThvtybryY3eGzznLtXvGbiDRfOIaas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BTJQXgFhL2eaZ4SKpHjGxCwSPn0yTAk4ZK7EMWcE7zMzFlGbA90+FDDf+t7vijQj0 o2dGPaDEr0c+iEwgZofIu1EkKZtyRO1nqT5WKMNfCyubomd2SOm9+lXh4gyVcYNDBC 48Qxbt6waTRzbBV67xtSZ2YGq6A3de7QL4T1E8nAg6FKPmHWPrUTe6Ye5rlf1e/3l1 rVRbuKgt4sOKunV3NJui7CdWH/ggJ4wjb/tCOfA2WknXupSytJJQAP3iPpU2mpIZF2 DReKRlsCuhtSKLjclcXBCSvWlDOY9sE5PwJ5dEiO/9pH7faL2bT6+D1Gz+LyfphcNo 8j1sLLKapRn3w== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Chao Yu , Jaegeuk Kim Subject: [PATCH 2/2] f2fs: remove folio_detach_private() in .invalidate_folio and .release_folio Date: Wed, 12 Apr 2023 09:08:10 -0700 Message-Id: <20230412160810.1534632-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog In-Reply-To: <20230412160810.1534632-1-jaegeuk@kernel.org> References: <20230412160810.1534632-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org From: Chao Yu We have maintain PagePrivate and page_private and page reference w/ {set,clear}_page_private_*, it doesn't need to call folio_detach_private() in the end of .invalidate_folio and .release_folio, remove it and use f2fs_bug_on instead. This patch should be applied along with ("f2fs: remove set|get_private_inline to clean up"). Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/data.c | 4 ++-- fs/f2fs/dir.c | 5 ++--- fs/f2fs/f2fs.h | 32 ++++++++------------------------ 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 14cd647d727d..037e70e85f63 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3732,7 +3732,7 @@ void f2fs_invalidate_folio(struct folio *folio, size_t offset, size_t length) inode->i_ino == F2FS_COMPRESS_INO(sbi)) clear_page_private_data(&folio->page); - folio_detach_private(folio); + f2fs_bug_on(sbi, page_private(&folio->page)); } bool f2fs_release_folio(struct folio *folio, gfp_t wait) @@ -3754,7 +3754,7 @@ bool f2fs_release_folio(struct folio *folio, gfp_t wait) clear_page_private_reference(&folio->page); clear_page_private_gcing(&folio->page); - folio_detach_private(folio); + f2fs_bug_on(sbi, page_private(&folio->page)); return true; } diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index d6dd8327e82d..cea179dec3b6 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -906,13 +906,12 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, clear_page_dirty_for_io(page); ClearPageUptodate(page); + clear_page_private_reference(page); clear_page_private_gcing(page); + f2fs_bug_on(F2FS_I_SB(dir), page_private(page)); inode_dec_dirty_pages(dir); f2fs_remove_dirty_inode(dir); - - detach_page_private(page); - set_page_private(page, 0); } f2fs_put_page(page, 1); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 200fb2243e8a..48fbd8b54e69 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1407,11 +1407,8 @@ static inline bool page_private_##name(struct page *page) \ #define PAGE_PRIVATE_SET_FUNC(name, flagname) \ static inline void set_page_private_##name(struct page *page) \ { \ - if (!PagePrivate(page)) { \ - get_page(page); \ - SetPagePrivate(page); \ - set_page_private(page, 0); \ - } \ + if (!PagePrivate(page)) \ + attach_page_private(page, (void *)0); \ set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)); \ set_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \ } @@ -1420,13 +1417,8 @@ static inline void set_page_private_##name(struct page *page) \ static inline void clear_page_private_##name(struct page *page) \ { \ clear_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \ - if (page_private(page) == BIT(PAGE_PRIVATE_NOT_POINTER)) { \ - set_page_private(page, 0); \ - if (PagePrivate(page)) { \ - ClearPagePrivate(page); \ - put_page(page); \ - }\ - } \ + if (page_private(page) == BIT(PAGE_PRIVATE_NOT_POINTER)) \ + detach_page_private(page); \ } PAGE_PRIVATE_GET_FUNC(nonpointer, NOT_POINTER); @@ -1452,11 +1444,8 @@ static inline unsigned long get_page_private_data(struct page *page) static inline void set_page_private_data(struct page *page, unsigned long data) { - if (!PagePrivate(page)) { - get_page(page); - SetPagePrivate(page); - set_page_private(page, 0); - } + if (!PagePrivate(page)) + attach_page_private(page, (void *)0); set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)); page_private(page) |= data << PAGE_PRIVATE_MAX; } @@ -1464,13 +1453,8 @@ static inline void set_page_private_data(struct page *page, unsigned long data) static inline void clear_page_private_data(struct page *page) { page_private(page) &= GENMASK(PAGE_PRIVATE_MAX - 1, 0); - if (page_private(page) == BIT(PAGE_PRIVATE_NOT_POINTER)) { - set_page_private(page, 0); - if (PagePrivate(page)) { - ClearPagePrivate(page); - put_page(page); - } - } + if (page_private(page) == BIT(PAGE_PRIVATE_NOT_POINTER)) + detach_page_private(page); } /* For compression */ -- 2.40.0.577.gac1e443424-goog