From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= Subject: Re: [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private Date: Fri, 1 May 2020 00:10:15 +0200 Message-ID: References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> <20200430214450.10662-2-guoqing.jiang@cloud.ionos.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20200430214450.10662-2-guoqing.jiang@cloud.ionos.com> Sender: linux-kernel-owner@vger.kernel.org To: Guoqing Jiang Cc: Linux FS-devel Mailing List , Linux Kernel Mailing List , Christoph Hellwig , Dave Chinner , willy@infradead.org, Andrew Morton , "Darrick J. Wong" , William Kucharski , "Kirill A. Shutemov" , Andreas Gruenbacher , Yang Shi , Yafang Shao , Song Liu , linux-raid@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Alexander Viro , Jaegeuk Kim List-Id: linux-raid.ids Hi, Am Do., 30. Apr. 2020 um 23:56 Uhr schrieb Guoqing Jiang : > 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 attach/clear_page_private to replace them. With > the new pair of function, we will remove the usage of attach_page_buffers > and __clear_page_buffers in next patches. Thanks for the new names from > Christoph Hellwig. > > 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 > Cc: Song Liu > Cc: linux-raid@vger.kernel.org > Cc: Chris Mason > Cc: Josef Bacik > Cc: David Sterba > Cc: linux-btrfs@vger.kernel.org > Cc: Alexander Viro > Cc: Jaegeuk Kim > Cc: Chao Yu > Cc: linux-f2fs-devel@lists.sourceforge.net > Cc: Christoph Hellwig > Cc: linux-xfs@vger.kernel.org > Cc: Anton Altaparmakov > Cc: linux-ntfs-dev@lists.sourceforge.net > Cc: Mike Marshall > Cc: Martin Brandenburg > Cc: devel@lists.orangefs.org > Cc: Thomas Gleixner > Cc: Sebastian Andrzej Siewior > Cc: Roman Gushchin > Cc: Andreas Dilger > Signed-off-by: Guoqing Jiang > --- > RFC -> RFC V2: Address the comments from Christoph Hellwig > 1. change function names to attach/clear_page_private and add comments. > 2. change the return type of attach_page_private. > > include/linux/pagemap.h | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index a8f7bd8ea1c6..2e515f210b18 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -205,6 +205,41 @@ static inline int page_cache_add_speculative(struct page *page, int count) > return __page_cache_add_speculative(page, count); > } > > +/** > + * attach_page_private - attach data to page's private field and set PG_private. > + * @page: page to be attached and set flag. > + * @data: data to attach to page's private field. > + * > + * Need to take reference as mm.h said "Setting PG_private should also increment > + * the refcount". > + */ > +static inline void attach_page_private(struct page *page, void *data) > +{ > + get_page(page); > + set_page_private(page, (unsigned long)data); > + SetPagePrivate(page); > +} > + > +/** > + * clear_page_private - clear page's private field and PG_private. > + * @page: page to be cleared. > + * > + * The counterpart function of attach_page_private. > + * Return: private data of page or NULL if page doesn't have private data. > + */ > +static inline void *clear_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; > +} > + I like this in general, but the name clear_page_private suggests that this might be the inverse operation of set_page_private, which it is not. So maybe this can be renamed to detach_page_private to more clearly indicate that it pairs with attach_page_private? > #ifdef CONFIG_NUMA > extern struct page *__page_cache_alloc(gfp_t gfp); > #else > -- > 2.17.1 > Thanks, Andreas From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AE07C47257 for ; Thu, 30 Apr 2020 22:10:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BF1C20873 for ; Thu, 30 Apr 2020 22:10:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DEPtrDBe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbgD3WK2 (ORCPT ); Thu, 30 Apr 2020 18:10:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbgD3WK2 (ORCPT ); Thu, 30 Apr 2020 18:10:28 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2C8BC035494; Thu, 30 Apr 2020 15:10:27 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id u189so2918850ilc.4; Thu, 30 Apr 2020 15:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2ET+MOiHcfDMgOrMdmamXFlGdEeR/f0vqWkjUxmdClw=; b=DEPtrDBeYCAoQ0fIRW9vAO9AKdIBDd19yOKxqpCf33m+D4aDmFK0jWp2gDkDUfLIF3 a0RiY8WUBuL/OywF0Sfe7Mw+U8PZHBrvRLi/cWr1L1zS3KXtS0LME1w+kYJIPn7rausY nZhWTdF599LEhKufQQYjD1zsGEBgcBeH3K1sOcIdbr8EtnqnwRv4/l6hVhEMsdoJUqpk XjIQpgLOLavv3PmRpNfqyxxh4+hksm0y3AwKeb0sOmtqDJXCcblH+SeQl3NWtKJFZ0bP L4LI0dNHCatdsYd8Gkx8mfgs4X1yi/Bli1OkCGFhW4U70l4V5687nZe5sfnbXXVoZr1N GG5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2ET+MOiHcfDMgOrMdmamXFlGdEeR/f0vqWkjUxmdClw=; b=lh/YhRsTPEyAIm6mGIauGy0rrfIdukqmi/Lg6I0k8vejtQ9HwFTdPWAOkKlMCy+lqv 6u33qT6Ldqp72zO0wZ9uD/3RcufmaOeVAajS0FPoC3ShLhaNwN2T78QZzqsa1y3bGkDR YqU2tVFW9uRMbgKfjsFC2d/t93hCivTei35JWyjAP95nYik3Kbsvi4LyUATtE2khrPxH BndInfG6l/ypbOl8S9RyPq+gCBoUZl5oLLWfPyvO7Yl7Pac1XCWO6p0pXMeG/2ZI4BvM 05yavQwgAE3yWYp3IFvE0OzGaDhLO+GS8r+KGLCmFHdoCEl8Z24NmYGVn/c66roIJR37 mcOg== X-Gm-Message-State: AGi0PuZEI6IlfpIUdMJl6M1Aro+Wem6OyndJO22BI9/WS9hzekmX3547 aBan1eiqUgt/zEusNqeRAtWqJ5fEuE20haTtjOQ= X-Google-Smtp-Source: APiQypJJdXHu9wsfILyXAYVgqjt8UsMKQuE8/0rB4pSAfnWGHEsBd9R1cDbXdgQq9K8UTJgqdLieT21my6+JZOjxZdE= X-Received: by 2002:a92:9e0b:: with SMTP id q11mr601506ili.133.1588284626957; Thu, 30 Apr 2020 15:10:26 -0700 (PDT) MIME-Version: 1.0 References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> <20200430214450.10662-2-guoqing.jiang@cloud.ionos.com> In-Reply-To: <20200430214450.10662-2-guoqing.jiang@cloud.ionos.com> From: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= Date: Fri, 1 May 2020 00:10:15 +0200 Message-ID: Subject: Re: [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private To: Guoqing Jiang Cc: Linux FS-devel Mailing List , Linux Kernel Mailing List , Christoph Hellwig , Dave Chinner , willy@infradead.org, Andrew Morton , "Darrick J. Wong" , William Kucharski , "Kirill A. Shutemov" , Andreas Gruenbacher , Yang Shi , Yafang Shao , Song Liu , linux-raid@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Alexander Viro , Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-xfs , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net, Mike Marshall , Martin Brandenburg , devel@lists.orangefs.org, Thomas Gleixner , Sebastian Andrzej Siewior , Roman Gushchin , Andreas Dilger Content-Type: text/plain; charset="UTF-8" Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Hi, Am Do., 30. Apr. 2020 um 23:56 Uhr schrieb Guoqing Jiang : > 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 attach/clear_page_private to replace them. With > the new pair of function, we will remove the usage of attach_page_buffers > and __clear_page_buffers in next patches. Thanks for the new names from > Christoph Hellwig. > > 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 > Cc: Song Liu > Cc: linux-raid@vger.kernel.org > Cc: Chris Mason > Cc: Josef Bacik > Cc: David Sterba > Cc: linux-btrfs@vger.kernel.org > Cc: Alexander Viro > Cc: Jaegeuk Kim > Cc: Chao Yu > Cc: linux-f2fs-devel@lists.sourceforge.net > Cc: Christoph Hellwig > Cc: linux-xfs@vger.kernel.org > Cc: Anton Altaparmakov > Cc: linux-ntfs-dev@lists.sourceforge.net > Cc: Mike Marshall > Cc: Martin Brandenburg > Cc: devel@lists.orangefs.org > Cc: Thomas Gleixner > Cc: Sebastian Andrzej Siewior > Cc: Roman Gushchin > Cc: Andreas Dilger > Signed-off-by: Guoqing Jiang > --- > RFC -> RFC V2: Address the comments from Christoph Hellwig > 1. change function names to attach/clear_page_private and add comments. > 2. change the return type of attach_page_private. > > include/linux/pagemap.h | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index a8f7bd8ea1c6..2e515f210b18 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -205,6 +205,41 @@ static inline int page_cache_add_speculative(struct page *page, int count) > return __page_cache_add_speculative(page, count); > } > > +/** > + * attach_page_private - attach data to page's private field and set PG_private. > + * @page: page to be attached and set flag. > + * @data: data to attach to page's private field. > + * > + * Need to take reference as mm.h said "Setting PG_private should also increment > + * the refcount". > + */ > +static inline void attach_page_private(struct page *page, void *data) > +{ > + get_page(page); > + set_page_private(page, (unsigned long)data); > + SetPagePrivate(page); > +} > + > +/** > + * clear_page_private - clear page's private field and PG_private. > + * @page: page to be cleared. > + * > + * The counterpart function of attach_page_private. > + * Return: private data of page or NULL if page doesn't have private data. > + */ > +static inline void *clear_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; > +} > + I like this in general, but the name clear_page_private suggests that this might be the inverse operation of set_page_private, which it is not. So maybe this can be renamed to detach_page_private to more clearly indicate that it pairs with attach_page_private? > #ifdef CONFIG_NUMA > extern struct page *__page_cache_alloc(gfp_t gfp); > #else > -- > 2.17.1 > Thanks, Andreas From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70854C47254 for ; Thu, 30 Apr 2020 22:10:36 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4168620870 for ; Thu, 30 Apr 2020 22:10:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="TYExg8DG"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="hH5Uc2X/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DEPtrDBe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4168620870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jUHO7-0002yP-Nh; Thu, 30 Apr 2020 22:10:35 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUHO6-0002y3-A7; Thu, 30 Apr 2020 22:10:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=2ET+MOiHcfDMgOrMdmamXFlGdEeR/f0vqWkjUxmdClw=; b=TYExg8DGous7QNWOUy9GozVgYU +A1F/0Ey1RRBaOFyg68eE2gg5sDXYFfns5Gw//T3fb7Zi+OgeFGuoM1f4INPVtQ8CeWrynuCxfeTN zsvENvdmxYGvPWC1gkPuMFNZZ/62NV+xxHnrWCrST4xNtsaa8Ym2ObjyePI0q0HIkgyA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=2ET+MOiHcfDMgOrMdmamXFlGdEeR/f0vqWkjUxmdClw=; b=hH5Uc2X/7syX+5zzypeJQCIPI4 B00QdVmdHusNI0HcievEX1UB2GUjlCKd28QC3i0LZw/BqMWfeKGawL9tpphWb4T64NEENOliwQd7S Dh+G3xQZleo8ff7JmspfONF3GGlmkbvhnmBL0LuFUiTWHa8KOyGYh8vCdxLLCSXJqCQo=; Received: from mail-il1-f193.google.com ([209.85.166.193]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jUHO4-005ohL-Vn; Thu, 30 Apr 2020 22:10:34 +0000 Received: by mail-il1-f193.google.com with SMTP id t12so2898683ile.9; Thu, 30 Apr 2020 15:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2ET+MOiHcfDMgOrMdmamXFlGdEeR/f0vqWkjUxmdClw=; b=DEPtrDBeYCAoQ0fIRW9vAO9AKdIBDd19yOKxqpCf33m+D4aDmFK0jWp2gDkDUfLIF3 a0RiY8WUBuL/OywF0Sfe7Mw+U8PZHBrvRLi/cWr1L1zS3KXtS0LME1w+kYJIPn7rausY nZhWTdF599LEhKufQQYjD1zsGEBgcBeH3K1sOcIdbr8EtnqnwRv4/l6hVhEMsdoJUqpk XjIQpgLOLavv3PmRpNfqyxxh4+hksm0y3AwKeb0sOmtqDJXCcblH+SeQl3NWtKJFZ0bP L4LI0dNHCatdsYd8Gkx8mfgs4X1yi/Bli1OkCGFhW4U70l4V5687nZe5sfnbXXVoZr1N GG5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2ET+MOiHcfDMgOrMdmamXFlGdEeR/f0vqWkjUxmdClw=; b=QVk8eZBi4PYXF6ZDyDCPLLSbXFslUMzk1itkfCVDU7YiR/uI+JLd0A5MqydD8uY1zE tzvrl5K6cK90IzyOBXPMDiBpesUVw1GcsuRHpa5EmvVGapHP92EfP1VDHqOTiNrGqEFM H036EVdepds56EoDFgneatFtX/7xtbIzrpvopbSsE1fJmImIewEmn2u6ZTbwj0G5bWhj Te1fnzV/39B5nt/dwPntPkc+xpR3Oz5xlDU07Sgw4YYnZoTncteD+ET9P3YFyIcWoIfE CSRZlZpYgYxLufDFIa4hlnxxQNZXZUbNo7iEGBsil8iU222mDGIh6Qcjd9SBVXBUBOkk m4AA== X-Gm-Message-State: AGi0PuZ/txuYFoA3CERTEYMUqKyd2hzZ5NHXN5G4EahlZShtzu2WcA1m M3OK88FSNLmR01Kb5A08qM4PHrMvq6k3C9/g3Kw= X-Google-Smtp-Source: APiQypJJdXHu9wsfILyXAYVgqjt8UsMKQuE8/0rB4pSAfnWGHEsBd9R1cDbXdgQq9K8UTJgqdLieT21my6+JZOjxZdE= X-Received: by 2002:a92:9e0b:: with SMTP id q11mr601506ili.133.1588284626957; Thu, 30 Apr 2020 15:10:26 -0700 (PDT) MIME-Version: 1.0 References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> <20200430214450.10662-2-guoqing.jiang@cloud.ionos.com> In-Reply-To: <20200430214450.10662-2-guoqing.jiang@cloud.ionos.com> From: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= Date: Fri, 1 May 2020 00:10:15 +0200 Message-ID: To: Guoqing Jiang X-Headers-End: 1jUHO4-005ohL-Vn Subject: Re: [f2fs-dev] [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Brandenburg , Sebastian Andrzej Siewior , Dave Chinner , Song Liu , Yafang Shao , Mike Marshall , Andreas Gruenbacher , "Darrick J. Wong" , Chris Mason , willy@infradead.org, Christoph Hellwig , devel@lists.orangefs.org, Josef Bacik , linux-raid@vger.kernel.org, Alexander Viro , David Sterba , Jaegeuk Kim , Thomas Gleixner , Anton Altaparmakov , Andreas Dilger , Yang Shi , William Kucharski , linux-ntfs-dev@lists.sourceforge.net, Linux Kernel Mailing List , linux-f2fs-devel@lists.sourceforge.net, linux-xfs , "Kirill A. Shutemov" , Linux FS-devel Mailing List , Andrew Morton , Roman Gushchin , linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Hi, Am Do., 30. Apr. 2020 um 23:56 Uhr schrieb Guoqing Jiang : > 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 attach/clear_page_private to replace them. With > the new pair of function, we will remove the usage of attach_page_buffers > and __clear_page_buffers in next patches. Thanks for the new names from > Christoph Hellwig. > > 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 > Cc: Song Liu > Cc: linux-raid@vger.kernel.org > Cc: Chris Mason > Cc: Josef Bacik > Cc: David Sterba > Cc: linux-btrfs@vger.kernel.org > Cc: Alexander Viro > Cc: Jaegeuk Kim > Cc: Chao Yu > Cc: linux-f2fs-devel@lists.sourceforge.net > Cc: Christoph Hellwig > Cc: linux-xfs@vger.kernel.org > Cc: Anton Altaparmakov > Cc: linux-ntfs-dev@lists.sourceforge.net > Cc: Mike Marshall > Cc: Martin Brandenburg > Cc: devel@lists.orangefs.org > Cc: Thomas Gleixner > Cc: Sebastian Andrzej Siewior > Cc: Roman Gushchin > Cc: Andreas Dilger > Signed-off-by: Guoqing Jiang > --- > RFC -> RFC V2: Address the comments from Christoph Hellwig > 1. change function names to attach/clear_page_private and add comments. > 2. change the return type of attach_page_private. > > include/linux/pagemap.h | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index a8f7bd8ea1c6..2e515f210b18 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -205,6 +205,41 @@ static inline int page_cache_add_speculative(struct page *page, int count) > return __page_cache_add_speculative(page, count); > } > > +/** > + * attach_page_private - attach data to page's private field and set PG_private. > + * @page: page to be attached and set flag. > + * @data: data to attach to page's private field. > + * > + * Need to take reference as mm.h said "Setting PG_private should also increment > + * the refcount". > + */ > +static inline void attach_page_private(struct page *page, void *data) > +{ > + get_page(page); > + set_page_private(page, (unsigned long)data); > + SetPagePrivate(page); > +} > + > +/** > + * clear_page_private - clear page's private field and PG_private. > + * @page: page to be cleared. > + * > + * The counterpart function of attach_page_private. > + * Return: private data of page or NULL if page doesn't have private data. > + */ > +static inline void *clear_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; > +} > + I like this in general, but the name clear_page_private suggests that this might be the inverse operation of set_page_private, which it is not. So maybe this can be renamed to detach_page_private to more clearly indicate that it pairs with attach_page_private? > #ifdef CONFIG_NUMA > extern struct page *__page_cache_alloc(gfp_t gfp); > #else > -- > 2.17.1 > Thanks, Andreas _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel