Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3577582rwl; Sun, 9 Apr 2023 19:43:57 -0700 (PDT) X-Google-Smtp-Source: AKy350YAYmiwERcz3hs3LukXqDgF27VC3o5DqppvUJaForHhedZLNHcaPFVy46U2GT7zxEmpF4fa X-Received: by 2002:a17:906:3da2:b0:8b1:820a:7b60 with SMTP id y2-20020a1709063da200b008b1820a7b60mr5351987ejh.6.1681094636953; Sun, 09 Apr 2023 19:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681094636; cv=none; d=google.com; s=arc-20160816; b=LtgOqUL/pPWxU8dA//c4CbK+ILsWxPF+TIsZpj5z7SoYYcTBYY27lg7RZz3TIbf/+w TaDVMBZkOC/7KwpeUFMkTBPFLhgWHMZ8e2m0FtMEEs3hDiaiKkHAcl9cKUOkyKyn2yjR CMVOO9871NOwaP5l2p9cdGZ6jrHN4A2A/JTLjTXi7t2vvLZEutp7UGSXs4BTxF2h4TrY VJBZyM1Ox4gH2GTTg16aTa5bjjI4OSI9FpJNf7ktFIi8Mx/+yL2OJUiut+bbXNWJisL3 itp47TboFU9bnWsFblcIIcRoLQyM9MgEBz2AeG54CSEaVCgvvOSS1lJ33rhMTW8ur55O daCw== 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=osCWTjxW5unK0xtJEdY5t80ITBTJjLgHDbojKtrVbb4=; b=XbdjCE5mKnSbVMTM3w5V56z03fYmkjovc0GfF8ACHjFQ1xK0wCFYjDKnC4U4sJA52C HPNtBVuH5NlAfQtJyYo9Lc+6nSQ4z7o2q71yyUjqw+zas/+49nyqUC7zODLyq+U4vTQb KjPDzA2bImjrzIQMRPmgMSnYBSe4YkDi+UP9QowzCPCuNAQ3Tchi0qI0R7gOVL6APNsC 7EcD2/ylKNbTnuevTshQG44uraCCEW86FHtObzSNDjg6RqwaKbi0KE6vM5bcbOtXJrx0 Ycm+/rVtmmjmF0wiF4LA5yqx5/8cHrwCGbGV5Rm/YxqLt6cXWJyq7j8MBTA7TDjOQ0mu TRSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mx4UEWTY; 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 fy8-20020a1709069f0800b0093ea57c3e8dsi3834295ejc.534.2023.04.09.19.43.28; Sun, 09 Apr 2023 19:43:56 -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=mx4UEWTY; 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 S229718AbjDJCZN (ORCPT + 99 others); Sun, 9 Apr 2023 22:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbjDJCZK (ORCPT ); Sun, 9 Apr 2023 22:25:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B3E54233 for ; Sun, 9 Apr 2023 19:24:42 -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 8F01061763 for ; Mon, 10 Apr 2023 02:24:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E946C4339E; Mon, 10 Apr 2023 02:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681093479; bh=4A4DyiocA7iSLRN+kYgk0UYrwVmLr56Y98gdBv7T4VM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mx4UEWTYXnX+SvedTlqQ/oWMLdG8xAtkFUZybN8GfM1d6E3CC0YIYGMqUI+j39ZKS mF2SzpSv5lRk3MjsIjYWwugztk/+WfRFTODZnmjTdFKHKMHJ0Ycwo23TdQ7VRhQKfs zr1PsAaFDNV1pbEWgi78izJqiyWRAwN/l+KN10/ivrwpBEn1PCNpgOeRY4G71iuyBP hotGOXlw5JgqiTCljar99yLckXboqKZQhgE1OLnqWURhtlkeByEoAPo0VWRmD0WNgI qZxoMe/3bE3kMjWBP/9yjO8E06NECcZsNR/LEbn5N3Les7/EQkqSzlaWVX3bOncv5X WEB77LaEHKxpw== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH 2/2] f2fs: clean up with {attach,detach}_page_private() Date: Mon, 10 Apr 2023 10:24:18 +0800 Message-Id: <20230410022418.1843178-2-chao@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230410022418.1843178-1-chao@kernel.org> References: <20230410022418.1843178-1-chao@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 No logic changes. Signed-off-by: Chao Yu --- fs/f2fs/f2fs.h | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index ec8387da7f74..c378aedcadea 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1416,11 +1416,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 *)page->private); \ set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)); \ set_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \ } @@ -1429,13 +1426,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); @@ -1464,11 +1456,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, 0); set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)); page_private(page) |= data << PAGE_PRIVATE_MAX; } @@ -1476,13 +1465,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.25.1