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 D950AC47247 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 AB9A520873 for ; Thu, 30 Apr 2020 22:10:33 +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 S1726973AbgD3WK2 (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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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