Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2260492ybz; Sun, 26 Apr 2020 14:53:38 -0700 (PDT) X-Google-Smtp-Source: APiQypLsAQfnThPUUpHNt1rZrPsPrFjthieW2PSERySSpapGWG43JkMNOcEKAxgg5gi+s+Uw8TYq X-Received: by 2002:a17:906:cd1:: with SMTP id l17mr16389533ejh.319.1587938018398; Sun, 26 Apr 2020 14:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587938018; cv=none; d=google.com; s=arc-20160816; b=gmPjyArMoh9NewcmP2qMeWYL+bvcHS8v14IA8OSTSYoDdTbV8rbw0i1j4tMYQWCeC/ lOU/IBJSvJDoAQcmnqvTcQHM/+IJ98MGWTXHi32ytBA/Qa3ZjykqnUNoc2ztwE0FEgCY 12jXQdcj8h9+gh4ejV8gSkGM7A2pvI3OZitM0XeSAh612CHeFwubq08jf+KEwCt85Ecu lAE3DFLmnEjzgPpbmw0Qgva4ABIJ5AlaLk5BqPtSVIJ/1FF6Qq5mdG784kUJ3or95rlk 2gkOCgfg9u7CA1OBe53oUGktAAaymfO/4BWRT/j8TH3TeLa1JWNG/sCii3aapjTWHkcQ 9f4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=aGrqSyBlWee4qlVzfbrxmXDEIitY77BfW8OPiMV+fGw=; b=Pzhkb6wi7C3+SpnobFosYSIdDQWvOtXWeADddCllB5ScRyGhIpsSHkHaWcf13rvp0z pr8F58Yg8GDT1ongp1iG1C46vK1w3JkBm/zWn8y/47XWYUK/JaMiC8QPWpxCO7uJh1xJ ip+ENQzhneBq5d2Hxv6U08JFls/BqW5Lb/A/7N0uTENjJi2t/IPtm7zDior/GSrA43pc 2VBVARPfGHYpSm5kostoafoktINRmI2f+rFn08m9n9vRwI997J7dyKmE3XSIFrQB4iU6 Prg3a4Eyf7gBBkwO7vOx7NPPfW69EHAlutA9DHgnYPEGUNxgoXnoS3nyz3QGksr2vEpB aARw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=VAfCURwT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si8068388ejr.370.2020.04.26.14.53.15; Sun, 26 Apr 2020 14:53:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=VAfCURwT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbgDZVuc (ORCPT + 99 others); Sun, 26 Apr 2020 17:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726215AbgDZVtu (ORCPT ); Sun, 26 Apr 2020 17:49:50 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5A4EC061A10 for ; Sun, 26 Apr 2020 14:49:48 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id p16so11993836edm.10 for ; Sun, 26 Apr 2020 14:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aGrqSyBlWee4qlVzfbrxmXDEIitY77BfW8OPiMV+fGw=; b=VAfCURwTPIE4rJfC8KB4FYWrz+JTx0GQK6awVyjDZRrnwDaaVDjgUgtGtQZznZmmxi wFl7jNmlcKuqIyO8p7/DqWXiTjP4SvaWAQzjxmulMXt8Ts4RDHfUM3ELErJt0x5C73AC zJywnyx9Cz5oWsMeQfO4c5ejUQ+vDm3Amp7tf72mheUEv9saFlblV0qG8GxVzGe8BxvY XbgofnU5SgEU582wK1e9C5GxLR0JqVzv67TRQVvRHms797+XWJFR5orBv3ADbbrwceBM E7ucIimM6ELJKj4Xxei35ZC9m3xzeGhs+QRaifvldaOwSBMIrEuwBPzLsQUyxEp4i+95 N6LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aGrqSyBlWee4qlVzfbrxmXDEIitY77BfW8OPiMV+fGw=; b=HOOQRG74WRPQ7aQ0jb2MVK369ydiX2/p8IFT1BWMY/spKQObfRm8fL07uTAtnzab6e 3NeTbmzTQGl5nODQlU3vumUdBVmVG7U96ADzq5qxwWXr3W1iJOFzxF3ZOYTXt6HdbRxz td0fHe7WCGfdIyrQUMQH6BSZWxtaL9EGTKuwiQve9/NsgVpxQz2eAPeQbsq5RAPspcpu B/AQ0sRHBxgo9faHtNr1fJvemyn7kvyWyFUYTz1XH4chrFXqhvT/E2PMPtliLyh6dOdQ 4h7LHiAvrcZOzcWl9qdQbT3zh6wSj7KyzXlWA4U1N/nMhT1Z3H1BXgQwQXLd3Su9j3YB Q0hw== X-Gm-Message-State: AGi0PuYarReI7lRIHR+kf9zPUm/gq7hWox0ObUsVd3gcWz3pcRoXmvVd vP3ZAvDZLIgARZF3gYf5tr5jlA== X-Received: by 2002:a05:6402:356:: with SMTP id r22mr17183505edw.3.1587937787466; Sun, 26 Apr 2020 14:49:47 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:fab1:56ff:feab:56b1]) by smtp.gmail.com with ESMTPSA id ce18sm2270108ejb.61.2020.04.26.14.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 14:49:46 -0700 (PDT) From: Guoqing Jiang To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: hch@infradead.org, david@fromorbit.com, willy@infradead.org, Guoqing Jiang , Andrew Morton , "Darrick J. Wong" , William Kucharski , "Kirill A. Shutemov" , Andreas Gruenbacher , Yang Shi , Yafang Shao Subject: [RFC PATCH 1/9] include/linux/pagemap.h: introduce set/clear_fs_page_private Date: Sun, 26 Apr 2020 23:49:17 +0200 Message-Id: <20200426214925.10970-2-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200426214925.10970-1-guoqing.jiang@cloud.ionos.com> References: <20200426214925.10970-1-guoqing.jiang@cloud.ionos.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The logic in attach_page_buffers and __clear_page_buffers are quite paired, but 1. they are located in different files. 2. attach_page_buffers is implemented in buffer_head.h, so it could be used by other files. But __clear_page_buffers is static function in buffer.c and other potential users can't call the function, md-bitmap even copied the function. So, introduce the new set/clear_fs_page_private to replace them since they are mostly used in fs layer. With the new pair of function, we will remove the usage of attach_page_buffers and __clear_page_buffers in next patches. Suggested-by: Matthew Wilcox Cc: Andrew Morton Cc: "Darrick J. Wong" Cc: William Kucharski Cc: "Kirill A. Shutemov" Cc: Andreas Gruenbacher Cc: Yang Shi Cc: Yafang Shao Signed-off-by: Guoqing Jiang --- include/linux/pagemap.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index a8f7bd8ea1c6..2a165ea647fe 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -205,6 +205,28 @@ static inline int page_cache_add_speculative(struct page *page, int count) return __page_cache_add_speculative(page, count); } +static inline void *set_fs_page_private(struct page *page, void *data) +{ + get_page(page); + set_page_private(page, (unsigned long)data); + SetPagePrivate(page); + + return data; +} + +static inline void *clear_fs_page_private(struct page *page) +{ + void *data = (void *)page_private(page); + + if (!PagePrivate(page)) + return NULL; + ClearPagePrivate(page); + set_page_private(page, 0); + put_page(page); + + return data; +} + #ifdef CONFIG_NUMA extern struct page *__page_cache_alloc(gfp_t gfp); #else -- 2.17.1