From patchwork Thu Apr 30 21:44:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521733 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D151913 for ; Thu, 30 Apr 2020 21:53:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F1AB20873 for ; Thu, 30 Apr 2020 21:53:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="NGAEKGru" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728014AbgD3VxS (ORCPT ); Thu, 30 Apr 2020 17:53:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbgD3Vwj (ORCPT ); Thu, 30 Apr 2020 17:52:39 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C6EDC09B040 for ; Thu, 30 Apr 2020 14:52:39 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id re23so5985664ejb.4 for ; Thu, 30 Apr 2020 14:52:39 -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=2Cwm7q37wd5a49T4hM9tpsz7D3qzUxu8CT8JBwv0w4c=; b=NGAEKGruhKtx7ZWTrFdEqTmqAVl/YDbNX5SVHiheCt5mgGQXMvPqVsB2mWj4W+6TZx avj1y2aqFM2fM4mYbpeY1mNHjz5L5wFBJHZ7nqGDO/UfrsVe7K3fK+19Qz0xhaRBCJF8 cnG9jsv0Y3cuCHExnrUC59PgGg5ldN6zReZ4l/MkqDih/pWf2Qq5leOqyJa1Ea1uUvqL KSJUgjKhSgiIMTbhcESV0rK/2/wlrqs0rRp/j53oVanG3NSXpHazoglUXFC2CIoq8QGs T0RBK7fYVyj0odwSJ7t5g5PDfIz9c6vhMkT7fz1ruAgadlRAj8EWlz0SjkauUs46ppHW r7PQ== 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=2Cwm7q37wd5a49T4hM9tpsz7D3qzUxu8CT8JBwv0w4c=; b=scWJ6guJUJBDTLKn97K0vk5a9QgvR4GmOmEMU8POoNzs3EW3vW4lt9zmNA/RCfN7DU JfbOXpgeP4E/YA1PWY8Zbh32lIdWsQdjcoqyTFGYPssffJ5ZNnVr8jPmV2sNrwTi6lXX GYQsclxNdOo4Eit97PPKEX1N9oJfuXRHteGPGz30pioie2O8Yt9E/MT6GfboR5wtVVoX Pv0mQgWsSo46UzR9M2dxyG5IcpeQl6C89QW5G4i5uekoQ3Wh2GaduiwFQzjjhbFt8Usu luzclZ0vp3Zc7S9ycr4xNlQ4xwDdptgQWSUy/DNg7SXNX2EWd7PUVw6wzj2nZ5k+Vgpq njrg== X-Gm-Message-State: AGi0PuZy8HQuK+T1JV9cfha/FlhKVcF7SAWAkK66gGqxfpNioLxZu8+o z7GNg3goY317MPd0NUjUmcBJ4nOJOTBLiA== X-Google-Smtp-Source: APiQypIDTj3Uj7biPphTd2Cba892cORi5pdinqFvBm6XPxrzHDikqrxlAy/dZ1nN6NDVa1Eq5TMhqw== X-Received: by 2002:a17:906:b2c4:: with SMTP id cf4mr538626ejb.340.1588283557346; Thu, 30 Apr 2020 14:52:37 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:36 -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 , 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@vger.kernel.org, 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 Subject: [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private Date: Thu, 30 Apr 2020 23:44:42 +0200 Message-Id: <20200430214450.10662-2-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 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; +} + #ifdef CONFIG_NUMA extern struct page *__page_cache_alloc(gfp_t gfp); #else From patchwork Thu Apr 30 21:44:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521727 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADF11913 for ; Thu, 30 Apr 2020 21:53:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96E7620873 for ; Thu, 30 Apr 2020 21:53:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="UOPZmwOF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbgD3VxK (ORCPT ); Thu, 30 Apr 2020 17:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbgD3Vwl (ORCPT ); Thu, 30 Apr 2020 17:52:41 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA22DC09B042 for ; Thu, 30 Apr 2020 14:52:39 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id r16so5831417edw.5 for ; Thu, 30 Apr 2020 14:52:39 -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=jPlN3fZ7s3A++1C7sjyXHDQViaM0ZwVaqGJ/ArH8ydc=; b=UOPZmwOFBz31CA1a013XCSUWOTz7+nHfoiYRSbBtN9DTrVUw2HSjsz2tXg/V4BYZ2c 8kHvJ1qceIU5vULZn7JEiYulYGw5R7/x1A7zSCjqntBD9zeG+2E4ndkO6t+9iQpB+RRF ksYbCWMkTUG4zF0GfztaqimkvrbkwBrSJjfW10WETmEA9E+Gt8PDdB679AJKe6bIhaj8 loRLKU2TTfgNIgSBPoypHr8C+alLR1Cp5Tj5VrOfOv4Hgu2wwPGU3hSBDCjXPtRNcw3z qAUejIde2vbObWtIkpGtIRUXfQONKK9z7FBHqhKKGmEfxxWwvpYwRp0WYqSRaV8jCI0e esDg== 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=jPlN3fZ7s3A++1C7sjyXHDQViaM0ZwVaqGJ/ArH8ydc=; b=kqsMdDUtGdJPZsE2AEB0WmdpMB4OCQCrm/ZH1ZRofq6Pu3as7i0Fu30qSrWEZ4GsSD jlafXKLczCL0NrDVdvOGD0Imc+0iEJyGZg0XS7NCfnfpnQuEI7DNqcsWBFC8kxhV27jd OakmSCnB8EuH1hfk3c0lOL+5MtUiVIF16ecYn47zukHOVpYlv56Q9T9XRQfZb+KBiyZT zC2fIVqBQOEA0NyOWuhBU/eBqxHQEndjCiHygaXpZTcyLB5toq9TrPK0HilkiF7kbXIr u2Rnfecj8FeE1ft9HTgUOS6Jdgrbl21luW336bkThU3xrkhfllX2GjoIB+BXTWzWpXAp IJFA== X-Gm-Message-State: AGi0PubPHDsvNTqfiWRQKPpVBdhl8OA0FgRQmur37B/OUkRWKjRHYCDp AUs/dYbenBEQQVr1F7LbCBSu3UJeu0QuXw== X-Google-Smtp-Source: APiQypKU16GiA01s65hPwNkOTaUje+/he/O4OTLJGHb+/4rc2Vf1fIUqVKimDiLTjtArR3CW7lCK2A== X-Received: by 2002:a05:6402:1651:: with SMTP id s17mr1043143edx.173.1588283558338; Thu, 30 Apr 2020 14:52:38 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:37 -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 , Song Liu , linux-raid@vger.kernel.org Subject: [RFC PATCH V2 2/9] md: remove __clear_page_buffers and use attach/clear_page_private Date: Thu, 30 Apr 2020 23:44:43 +0200 Message-Id: <20200430214450.10662-3-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org After introduce attach/clear_page_private in pagemap.h, we can remove the duplicat code and call the new functions. Cc: Song Liu Cc: linux-raid@vger.kernel.org Signed-off-by: Guoqing Jiang --- RFC -> RFC V2 1. change the name of new functions to attach/clear_page_private. drivers/md/md-bitmap.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index b952bd45bd6a..033d12063600 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -324,14 +324,6 @@ static void end_bitmap_write(struct buffer_head *bh, int uptodate) wake_up(&bitmap->write_wait); } -/* copied from buffer.c */ -static void -__clear_page_buffers(struct page *page) -{ - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); -} static void free_buffers(struct page *page) { struct buffer_head *bh; @@ -345,7 +337,7 @@ static void free_buffers(struct page *page) free_buffer_head(bh); bh = next; } - __clear_page_buffers(page); + clear_page_private(page); put_page(page); } @@ -374,7 +366,7 @@ static int read_page(struct file *file, unsigned long index, ret = -ENOMEM; goto out; } - attach_page_buffers(page, bh); + attach_page_private(page, bh); blk_cur = index << (PAGE_SHIFT - inode->i_blkbits); while (bh) { block = blk_cur; From patchwork Thu Apr 30 21:44:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521725 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05C2515AB for ; Thu, 30 Apr 2020 21:53:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E07ED207DD for ; Thu, 30 Apr 2020 21:53:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="coBxNrXx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727818AbgD3Vwn (ORCPT ); Thu, 30 Apr 2020 17:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbgD3Vwl (ORCPT ); Thu, 30 Apr 2020 17:52:41 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F36CC08E859 for ; Thu, 30 Apr 2020 14:52:41 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id nv1so6003604ejb.0 for ; Thu, 30 Apr 2020 14:52:41 -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=A09pnxCtmHNFxtu5/7SWNRBZ57kuvjkQtubB+do4qv0=; b=coBxNrXxFKfsgd7ezmeRSMXArxrt4d5nG71g2m2wa3tS/g6U6HEWU9BoF6/hkAXZoG 577qwNithCoeR1JzQnF6A6JRGXpAqNL/fRuja5anAhDdJq+TkHUONmaDVzJlSNgkhc2I dk1pmVRAlGg9aVQ8aELP8PYAzHz0JrF3DN9gQryz1pVoAsJMJVIRe1Pd1N3gCghHC9yL yqSQiDQ4el0qSc//QT9+h3Ogegpsh3a/5yhPvrkMTmpnw7OE+Mow6HAZhgv8VOKOTUyE IIQVwnF5yomS1DIMau0s9YDJqLuIR0w15xpkZXu6XOffLWkGdQhWNRbqXSNiibl6KsAh vDjg== 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=A09pnxCtmHNFxtu5/7SWNRBZ57kuvjkQtubB+do4qv0=; b=ADQ2eke7UXex1HdRf/ew4Hzty050xMEGrS4HOlBNep7dFLQRQKYcoGKkoopDXXIIYh uZUDHJox+kcVIGFzDi1p9CX6jEVypVQcfii7jkaMPqbCqCEM+Ob7JB6T0rNJeNkR86ki wCa/1iE7BZ8DFS1NyMwfA35h1dFjv7tK0SseW8REMY7X/NyX6StBR9mjTBqXO3vB285n ybpLZ0h0RPCzVmHDHh03VX2cDB4GPnnkToV/yZtVVs6d1K+ppI9fuLfUZvoBisseI4pK 2K+kXHg0CHwB63Po5qkiF1Xptma5ZVdYYW4Y+48ykf+tR4MPVmzMTJR2gXfxdKbQoP1r YDTg== X-Gm-Message-State: AGi0PuYsCpDnVOAXXIv3XkhSnfbnd1nRytuBo7/e0Lgq9MyA6kJ42KMo 3HA7XU333mTAo+Ho+3WiypDCH4Xtuodp/w== X-Google-Smtp-Source: APiQypK91YmJ/zypDwWYeiUGGTtRcY3r6jBUkl5+7k4v01U2o6zcWTEhskl4b2aH+/9BYKgT54UQQw== X-Received: by 2002:a17:906:90cc:: with SMTP id v12mr504911ejw.211.1588283559260; Thu, 30 Apr 2020 14:52:39 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:38 -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 , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: [RFC PATCH V2 3/9] btrfs: use attach/clear_page_private Date: Thu, 30 Apr 2020 23:44:44 +0200 Message-Id: <20200430214450.10662-4-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Since the new pair function is introduced, we can call them to clean the code in btrfs. Cc: Chris Mason Cc: Josef Bacik Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Signed-off-by: Guoqing Jiang --- RFC -> RFC V2 1. change the name of new functions to attach/clear_page_private. 2. call attach_page_private(newpage, clear_page_private(page)) to cleanup code further as suggested by Dave Chinner. fs/btrfs/disk-io.c | 4 +--- fs/btrfs/extent_io.c | 21 ++++++--------------- fs/btrfs/inode.c | 23 +++++------------------ 3 files changed, 12 insertions(+), 36 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a6cb5cbbdb9f..fe4acf821110 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -980,9 +980,7 @@ static void btree_invalidatepage(struct page *page, unsigned int offset, btrfs_warn(BTRFS_I(page->mapping->host)->root->fs_info, "page private not zero on page %llu", (unsigned long long)page_offset(page)); - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); + clear_page_private(page); } } diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 39e45b8a5031..095a5e83e660 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3076,22 +3076,16 @@ static int submit_extent_page(unsigned int opf, static void attach_extent_buffer_page(struct extent_buffer *eb, struct page *page) { - if (!PagePrivate(page)) { - SetPagePrivate(page); - get_page(page); - set_page_private(page, (unsigned long)eb); - } else { + if (!PagePrivate(page)) + attach_page_private(page, eb); + else WARN_ON(page->private != (unsigned long)eb); - } } void set_page_extent_mapped(struct page *page) { - if (!PagePrivate(page)) { - SetPagePrivate(page); - get_page(page); - set_page_private(page, EXTENT_PAGE_PRIVATE); - } + if (!PagePrivate(page)) + attach_page_private(page, (void *)EXTENT_PAGE_PRIVATE); } static struct extent_map * @@ -4929,10 +4923,7 @@ static void btrfs_release_extent_buffer_pages(struct extent_buffer *eb) * We need to make sure we haven't be attached * to a new eb. */ - ClearPagePrivate(page); - set_page_private(page, 0); - /* One for the page private */ - put_page(page); + clear_page_private(page); } if (mapped) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 320d1062068d..34b09ab2c32a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8303,11 +8303,8 @@ btrfs_readpages(struct file *file, struct address_space *mapping, static int __btrfs_releasepage(struct page *page, gfp_t gfp_flags) { int ret = try_release_extent_mapping(page, gfp_flags); - if (ret == 1) { - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); - } + if (ret == 1) + clear_page_private(page); return ret; } @@ -8329,14 +8326,8 @@ static int btrfs_migratepage(struct address_space *mapping, if (ret != MIGRATEPAGE_SUCCESS) return ret; - if (page_has_private(page)) { - ClearPagePrivate(page); - get_page(newpage); - set_page_private(newpage, page_private(page)); - set_page_private(page, 0); - put_page(page); - SetPagePrivate(newpage); - } + if (page_has_private(page)) + attach_page_private(newpage, clear_page_private(page)); if (PagePrivate2(page)) { ClearPagePrivate2(page); @@ -8458,11 +8449,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset, } ClearPageChecked(page); - if (PagePrivate(page)) { - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); - } + clear_page_private(page); } /* From patchwork Thu Apr 30 21:44:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521717 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAF7915AB for ; Thu, 30 Apr 2020 21:53:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3C78214D8 for ; Thu, 30 Apr 2020 21:53:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="MVZuBrg6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727862AbgD3Vwo (ORCPT ); Thu, 30 Apr 2020 17:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727799AbgD3Vwm (ORCPT ); Thu, 30 Apr 2020 17:52:42 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67F30C09B040 for ; Thu, 30 Apr 2020 14:52:42 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id gr25so5963816ejb.10 for ; Thu, 30 Apr 2020 14:52:42 -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=RDyvyO8rwFmcvJyegxtOlIWyfKh2lKfO2lMdBviLIWw=; b=MVZuBrg6oa0B3+oPEUC9E3MHJsz7b1vOQU68STAjII2XEWrovdVYpyUKVXwhxlLycC 6SqHUtbNoruOVUIG50+L5nfg62ylVmz1h1arB+uxy+ffqXcJcnB9vGyFOM9Hcnutr0Mo 5YX2gldpMUjtoeZ7A+F5CNuYlTkLT5QhTIacRexmuxsOFdV0d21RO4SlSbIqGtGjwxzU +rydx4uwGaY+fpxemnQmqtoDGz1KBM8nzE9ame1omYKoK/Xbo6tQAtwnCu+wf1CSn/xl QgL3r7YzLqopwed5S5NrJLno49ahjtsMP5BxXsM0X/3Z8ZnkSXCYulEZcuFq2lxcIBMh Ve+w== 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=RDyvyO8rwFmcvJyegxtOlIWyfKh2lKfO2lMdBviLIWw=; b=a1IX6XwwadUP/Ous23fVfFuKujox/847F3xwrLEAThZI0QsGukfM/E4ujsZHMGuI2M +QnO1A12U7Bxz/FWs6hPX4W1uV5rwS4TTw0IVADLc9ED4vuf2NfrQNYTSRMUVxk8DCCX iQWEGFJP2oJFUIiFG1VhSj7EJhUam0kdfHrs3zSzLKo3d+lPrXZUmKA446iKvJPfxARu 33bAxGuq43RgcO8moXqyYCemxpNxcmoRaKtAxLEt7dQfbvGrUClzib6XcW1AV8cTXnAa 1z/YVFVZrFhguh0Q59LlWODdlKndNDrOewt8L7y1/StM9d7sMNuV5U7Sds2SZ/a2wPEL VEjw== X-Gm-Message-State: AGi0PuaoOlDP8Dn0imQ34+IvHn+XTTPzW3ZwB09VeiLvnhOUWOSkJfVh +mfKAITxC6laEK1PlmgZW8xPXF+ALdqsBQ== X-Google-Smtp-Source: APiQypJG7QnDdETcRAJ6jnMQlEhFUkN8OM6SSlzSW0BC0GNEexmz4jIQLd3z5S87e1gEFOPgjS+QKQ== X-Received: by 2002:a17:907:11de:: with SMTP id va30mr519015ejb.121.1588283560575; Thu, 30 Apr 2020 14:52:40 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:39 -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 , Alexander Viro Subject: [RFC PATCH V2 4/9] fs/buffer.c: use attach/clear_page_private Date: Thu, 30 Apr 2020 23:44:45 +0200 Message-Id: <20200430214450.10662-5-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Since the new pair function is introduced, we can call them to clean the code in buffer.c. Cc: Alexander Viro Signed-off-by: Guoqing Jiang --- RFC -> RFC V2 1. change the name of new functions to attach/clear_page_private. fs/buffer.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index a60f60396cfa..60dd61384b13 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -123,14 +123,6 @@ void __wait_on_buffer(struct buffer_head * bh) } EXPORT_SYMBOL(__wait_on_buffer); -static void -__clear_page_buffers(struct page *page) -{ - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); -} - static void buffer_io_error(struct buffer_head *bh, char *msg) { if (!test_bit(BH_Quiet, &bh->b_state)) @@ -906,7 +898,7 @@ link_dev_buffers(struct page *page, struct buffer_head *head) bh = bh->b_this_page; } while (bh); tail->b_this_page = head; - attach_page_buffers(page, head); + attach_page_private(page, head); } static sector_t blkdev_max_block(struct block_device *bdev, unsigned int size) @@ -1580,7 +1572,7 @@ void create_empty_buffers(struct page *page, bh = bh->b_this_page; } while (bh != head); } - attach_page_buffers(page, head); + attach_page_private(page, head); spin_unlock(&page->mapping->private_lock); } EXPORT_SYMBOL(create_empty_buffers); @@ -2567,7 +2559,7 @@ static void attach_nobh_buffers(struct page *page, struct buffer_head *head) bh->b_this_page = head; bh = bh->b_this_page; } while (bh != head); - attach_page_buffers(page, head); + attach_page_private(page, head); spin_unlock(&page->mapping->private_lock); } @@ -3227,7 +3219,7 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free) bh = next; } while (bh != head); *buffers_to_free = head; - __clear_page_buffers(page); + clear_page_private(page); return 1; failed: return 0; From patchwork Thu Apr 30 21:44:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C74B415AB for ; Thu, 30 Apr 2020 21:53:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABB27207DD for ; Thu, 30 Apr 2020 21:53:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="AUo5ie4M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727986AbgD3VxH (ORCPT ); Thu, 30 Apr 2020 17:53:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbgD3Vwn (ORCPT ); Thu, 30 Apr 2020 17:52:43 -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 3E7EFC035495 for ; Thu, 30 Apr 2020 14:52:43 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id s10so5798457edy.9 for ; Thu, 30 Apr 2020 14:52:43 -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=VQtiN0YF68ouYEl0FBCwGef51NS629CikCik/xuB3mA=; b=AUo5ie4M5LC6EyVTONtWCWaK6x9Glpt0fKqCXZVKpIls4fS+TQMg9AZVj57+ZKp657 KxpTHzcmRADvXQhinXFVjaJFVsM9IuKylOT606jy/n3S8NWY7zE2X3rHDq7FW+dv5OL5 1HMaxuBEfufCr2WCuB4rDNQOV8qEERy8iOyCbgO42UphAQhYWWLT2Kl7Ouklm/t3uF1a fBBUzA+7kF8C+npPOk3+v2AgOy9vTvhHtGfHdvNk/1rBbn6A5aQS1qjv/ZBpzIHD8l/5 RK7vYHRT3JNA6f1tCk3T27BEPLr6hIdu7kSYpHu2/hF36qamf3WGbDphvY/vVIgJThmr 9n9Q== 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=VQtiN0YF68ouYEl0FBCwGef51NS629CikCik/xuB3mA=; b=JXNFvZPf8427PjcEjSkgQwlmijN4D239l4MFbDmmvcgiwV1NdsccCt61FvLM2E4TUj mZqbejSG5r/3FYbgfssxY1nxOC0dHxDhS/txH0CwCDemXrOarwCB78KfeipqqBsyzWhW PXvz6idWfQJWvVq742DVFQnlHnL7Uqc+qGsEMje3Bvp7MMjNNvUmzvtV81ayTWWm3Egh Pr5ogqvkI+vNeFqEK/Q1XASJT25p0EpiUPn4fJ5Q2GICK/33ET0HWUop6GYPxDYN7wmM Scv8c4jN00t9JYAY8TbHMfwqFjl488Q2V8k4zMzcLHtyqSGB7PPuWxtUqXwBm3yT9FU6 LcoQ== X-Gm-Message-State: AGi0PuYYbOz1m4VQnjXxmJMBfNBqSApa55VwWiuSJBa0b0ExPeL7Q64y 3GZtp9a5BDQtxBOp+2Wh+lzGmiEGp8eNNw== X-Google-Smtp-Source: APiQypL49Bp/BPGNJL3rW/dArQDsk2UFazjTXaUNS6oloFuEsd404kXblrgA4wta20gl8BWTl2ZM7w== X-Received: by 2002:a05:6402:286:: with SMTP id l6mr1062803edv.134.1588283561709; Thu, 30 Apr 2020 14:52:41 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:40 -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 , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net Subject: [RFC PATCH V2 5/9] f2fs: use attach/clear_page_private Date: Thu, 30 Apr 2020 23:44:46 +0200 Message-Id: <20200430214450.10662-6-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Since the new pair function is introduced, we can call them to clean the code in f2fs.h. Cc: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net Acked-by: Chao Yu Signed-off-by: Guoqing Jiang --- RFC -> RFC V2 1. change the name of new functions to attach/clear_page_private. fs/f2fs/f2fs.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index ba470d5687fe..24d22bd7352d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3051,19 +3051,12 @@ static inline void f2fs_set_page_private(struct page *page, if (PagePrivate(page)) return; - get_page(page); - SetPagePrivate(page); - set_page_private(page, data); + attach_page_private(page, (void *)data); } static inline void f2fs_clear_page_private(struct page *page) { - if (!PagePrivate(page)) - return; - - set_page_private(page, 0); - ClearPagePrivate(page); - f2fs_put_page(page, 0); + clear_page_private(page); } /* From patchwork Thu Apr 30 21:44:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521719 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F97515E6 for ; Thu, 30 Apr 2020 21:53:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57FE2214D8 for ; Thu, 30 Apr 2020 21:53:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="K0b9BUEb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727985AbgD3VxF (ORCPT ); Thu, 30 Apr 2020 17:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727799AbgD3Vwo (ORCPT ); Thu, 30 Apr 2020 17:52:44 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31089C08ED7D for ; Thu, 30 Apr 2020 14:52:44 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id k8so5995732ejv.3 for ; Thu, 30 Apr 2020 14:52:44 -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=LDEyu4DqGHwJ7t/wlLTaUyFP1PKV8rYydYP0xvjnvj8=; b=K0b9BUEbUMN4c/HcO3EMetbwDKa/bQB7gEHoueMz+xCk9NFN8tJEEGyelIxvpaZToN ECQhJ9+wuy6qVtEwW9mUbisrOp3Pj/n5ULKfaLTMyrAgHJ/y7vfV7+QRzZcu/ByCJwZV CPuAb8QHPy18fm4QKel2ZHntwvTIDJWCm5hPjM+GtW6xp2scc5EbWir72q2kghoVWPxH Az6OQH50Tuf5V695TOo+L4tAZIwvPVOvxxLMV5G8tX86ymSPIZ2N9QR403Il6RFjXg4b ouaTyJZDdGlDGYke3obk+Sa+ExaUEl1q26wAKLnV/KKIMOjQcxkwBOITpksORcNhKjYu O75w== 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=LDEyu4DqGHwJ7t/wlLTaUyFP1PKV8rYydYP0xvjnvj8=; b=mxt3dsRo6rr1/EJAtDPWs6cC7zMk2xn/RUJZmXbLlR2J4Hs8ej0iXWIQH9d+jOHcHI tjIcoRR683cdBUDu64XZjXwNPRVEp9HW5wDgHpJWeR5c40tdDlnOr6uvh+xX7SHbb79i OXJOfXAG+Z/IUvmkeGTgksyqrfw4WjqaCxNzNGZW2mXgNXW8wekXfqyVWOwp5Yo9beyx E9/CsRk7jsYStIpwy5ZIzHxdBDl35Ka3MJLRAF5viPFn+ihlmq/RtcPAFWcDIOBhakBO W3wProZ5J3YhDl22FtuJZzaemqQopGJMvSGhYfhq047NcFofgP0RLr1tJzKmdCd8nWDB 4jHQ== X-Gm-Message-State: AGi0PuYIqxoqlz+w1VzesPGCAT5f5Q0ofJugPOrVPfBvOWqnpDp+l/tF cAcsoVs1bjHls5vyP+jMjUybM9/zKl9Jmg== X-Google-Smtp-Source: APiQypJYcY11pPgGBq9YSYemUl02BKlG2gtWtnLYjB8d8jL0gxleYPu+2YtHv3X6Kc4Pait6eLK1vg== X-Received: by 2002:a17:906:5918:: with SMTP id h24mr537740ejq.210.1588283562672; Thu, 30 Apr 2020 14:52:42 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:42 -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 , "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [RFC PATCH V2 6/9] iomap: use attach/clear_page_private Date: Thu, 30 Apr 2020 23:44:47 +0200 Message-Id: <20200430214450.10662-7-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Since the new pair function is introduced, we can call them to clean the code in iomap. Cc: Christoph Hellwig Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Signed-off-by: Guoqing Jiang --- RFC -> RFC V2 1. change the name of new functions to attach/clear_page_private. 2. call attach_page_private(newpage, clear_page_private(page)) to cleanup code further as suggested by Matthew Wilcox. 3. don't return attach_page_private in iomap_page_create per the comment from Christoph Hellwig. fs/iomap/buffered-io.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 89e21961d1ad..cf4c1b02a9d8 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -59,24 +59,19 @@ iomap_page_create(struct inode *inode, struct page *page) * migrate_page_move_mapping() assumes that pages with private data have * their count elevated by 1. */ - get_page(page); - set_page_private(page, (unsigned long)iop); - SetPagePrivate(page); + attach_page_private(page, iop); return iop; } static void iomap_page_release(struct page *page) { - struct iomap_page *iop = to_iomap_page(page); + struct iomap_page *iop = clear_page_private(page); if (!iop) return; WARN_ON_ONCE(atomic_read(&iop->read_count)); WARN_ON_ONCE(atomic_read(&iop->write_count)); - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); kfree(iop); } @@ -554,14 +549,8 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage, if (ret != MIGRATEPAGE_SUCCESS) return ret; - if (page_has_private(page)) { - ClearPagePrivate(page); - get_page(newpage); - set_page_private(newpage, page_private(page)); - set_page_private(page, 0); - put_page(page); - SetPagePrivate(newpage); - } + if (page_has_private(page)) + attach_page_private(newpage, clear_page_private(page)); if (mode != MIGRATE_SYNC_NO_COPY) migrate_page_copy(newpage, page); From patchwork Thu Apr 30 21:44:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521713 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1D59913 for ; Thu, 30 Apr 2020 21:53:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97742207DD for ; Thu, 30 Apr 2020 21:53:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="hWSupT2l" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727895AbgD3Vwr (ORCPT ); Thu, 30 Apr 2020 17:52:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbgD3Vwp (ORCPT ); Thu, 30 Apr 2020 17:52:45 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B7C6C035495 for ; Thu, 30 Apr 2020 14:52:45 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id pg17so5977302ejb.9 for ; Thu, 30 Apr 2020 14:52:45 -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=+HP7z6Hg8lzRP/U1gFmfA3WajvLlBxqo/6VD8xCmFbY=; b=hWSupT2lw0h4JkwT99fJDHoFXbGY/qi6K3JHIXf5XBVKrA1IxBVU9BjwR9JRYAP5M3 mQNvDt+6buK5JxU3IZxBmLzv2kDzBUP6Gel0wdmJlpz/KnhWIY7jFwNA+BriUUF4zQ6e F9cGtBvaIgbMyqxC8HVgrTcDdKGLR7mCDmD7KpHofoQk1AYm7qd5z0fb8cCn032cGOWf MQPJXejMcv3AkFk6a0BUHTG61C8Bn41oPqbRdS5B/l8Ck9sMF0foC2alUi4NmJaLp6Ol Z7ewU8Jdmv3xb8msOTEVnp/iHyk1XgmTBbyFwZCFwhT0W8lD9F5M0SbP32SSiPb2dbI7 432g== 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=+HP7z6Hg8lzRP/U1gFmfA3WajvLlBxqo/6VD8xCmFbY=; b=qHXdDKX4RWvUktnJjRJsS6dku1SndWxzxQ+mgEuCllpHRRPit8GSI6+qBK8AF2cyrA py4V7giqHsqaOkOuwyKXhrTM43uCdJ3DmKUFSf2d2VBxEgcNUXzjc/7Uu/q5DXMhZSee FSOa7UsC/v2MJziqe4Ao3PuKmaUgm4iqH6dKYiUGuxixj0+DJr3j/ekGTJm16fYR/2c7 qMHnUx1G9gbzBfa40J3vnuB2H/0tYjRcfD9l3tbhKO8Y6cvKh4qValQ0K5+gE3TP/qqK Fp7iwpOrGAfYBzMIqctCE5vuxN+08p3DUnQekwd5plnenFtsCElHro4UJgbBcJT2UdgM D+Xw== X-Gm-Message-State: AGi0PuYlO1w7j5W3oFLQgwZWb+OvNhfNuzqNcTaxVpxBVODPrBuBzJUB bjKS8qmsXnfTxyzHSuc3Ew1V+HvR8cN9vA== X-Google-Smtp-Source: APiQypLxnuHJHZvv+dCCIXb9HbZa2z7yfUHGFVq7rRLwlffWLOh/A1m6HRhFPDQQ2qs6EOYeAyuRQg== X-Received: by 2002:a17:907:2155:: with SMTP id rk21mr517017ejb.163.1588283563771; Thu, 30 Apr 2020 14:52:43 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:43 -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 , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net Subject: [RFC PATCH V2 7/9] ntfs: replace attach_page_buffers with attach_page_private Date: Thu, 30 Apr 2020 23:44:48 +0200 Message-Id: <20200430214450.10662-8-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Call the new function since attach_page_buffers will be removed. Cc: Anton Altaparmakov Cc: linux-ntfs-dev@lists.sourceforge.net Signed-off-by: Guoqing Jiang --- RFC -> RFC V2 1. change the name of new function to attach_page_private. fs/ntfs/aops.c | 2 +- fs/ntfs/mft.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 554b744f41bf..bb0a43860ad2 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -1732,7 +1732,7 @@ void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) { bh = bh->b_this_page; } while (bh); tail->b_this_page = head; - attach_page_buffers(page, head); + attach_page_private(page, head); } else buffers_to_free = bh; } diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 3aac5c917afe..fbb9f1bc623d 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -504,7 +504,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no, bh = bh->b_this_page; } while (bh); tail->b_this_page = head; - attach_page_buffers(page, head); + attach_page_private(page, head); } bh = head = page_buffers(page); BUG_ON(!bh); From patchwork Thu Apr 30 21:44:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521715 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6006C913 for ; Thu, 30 Apr 2020 21:53:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 461DA20731 for ; Thu, 30 Apr 2020 21:53:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="EKSoG5Ew" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727972AbgD3VxB (ORCPT ); Thu, 30 Apr 2020 17:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727890AbgD3Vwq (ORCPT ); Thu, 30 Apr 2020 17:52:46 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70932C035495 for ; Thu, 30 Apr 2020 14:52:46 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id r16so5831660edw.5 for ; Thu, 30 Apr 2020 14:52:46 -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=0x0u2gx9fn/eR0FN5+bPGwv0n6eHZLnbohIE4ZZX1xA=; b=EKSoG5Ew33JLpPLoDYTtE+/Mgaiip4zvgBvwtrD+hzLSfo0W4PoRueJtf0vHDfylth bljRy4d4FM68XWGdNeOkwmfpot8DYA8ccYVAgwhAOhIi49XGb7to4+pAAZneDZCwf4G6 IkFcj1IZ9Qq8NOMnothYcg8j2FPeyvEg43skasH+eZw77B+t7Qfs+j68ULZzmwKal/h3 9saDCk1g1y7x4x+j5cKc0w4eHvhoxpHehsWHYcMrqIF522cmVjrQX9TO1JsfPCvOuR/I zHxuTKM5R0LSq/EtBs1ZI6S/nV/ouTfbgPwVZmpLRJi6srnLa57HKoMQe8NfaoufTaQa mUJg== 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=0x0u2gx9fn/eR0FN5+bPGwv0n6eHZLnbohIE4ZZX1xA=; b=jdE+/rYgYnDxr2cL5UzY6mNFtrO597quXSfOgxc7CuvDKrjoa083NUfFalVUpQ0FcS ugQreSbMmHIZRkhhCRLUMxPCD/h+ok4sTtM5zsyqrIQD4jv69Z2QzEQ1OuGYoY+KJ1ib ntjvzNFjp84sS7r9wubBw2Du14cfrxJzuiHAug28MAq9lba9b0yXi4Ka6v01PcymyzZS b3ZRLK0isy3fd2mTU8BYj9RpERoirG6xfMpO34Wq8kF2fqt33PfjCl6fEqzKz7iysuOD V6VS4KddqfgjDMh71ODdzQBcarYsGr6h7DevgmBX5iku8eYdZpfOhHsTa0KorX2TvYHG HiuA== X-Gm-Message-State: AGi0PuYxA0A5WIpytcyHsKLBn7Ghxq9wY96EzqLJX2XWKiCH5HPAQ8Ss 7Dzopr11ZSHvZZIeSLA6YxS7Ch1IrwK8Kg== X-Google-Smtp-Source: APiQypKmEI+P+Q9Igmy/Z+wtCcfy41Y3uqyWZUCr4Xom2jUvuVGNOvsSANgZbWuTvpeKE8zdOXrN5A== X-Received: by 2002:aa7:ce0f:: with SMTP id d15mr995432edv.327.1588283565020; Thu, 30 Apr 2020 14:52:45 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:44 -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 , Mike Marshall , Martin Brandenburg , devel@lists.orangefs.org Subject: [RFC PATCH V2 8/9] orangefs: use attach/clear_page_private Date: Thu, 30 Apr 2020 23:44:49 +0200 Message-Id: <20200430214450.10662-9-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Since the new pair function is introduced, we can call them to clean the code in orangefs. Cc: Mike Marshall Cc: Martin Brandenburg Cc: devel@lists.orangefs.org Signed-off-by: Guoqing Jiang --- RFC -> RFC V2 1. change the name of new functions to attach/clear_page_private. 2. avoid potential use-after-free as suggested by Dave Chinner. fs/orangefs/inode.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index 12ae630fbed7..139c450aca68 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -62,12 +62,7 @@ static int orangefs_writepage_locked(struct page *page, } else { ret = 0; } - if (wr) { - kfree(wr); - set_page_private(page, 0); - ClearPagePrivate(page); - put_page(page); - } + kfree(clear_page_private(page)); return ret; } @@ -409,9 +404,7 @@ static int orangefs_write_begin(struct file *file, wr->len = len; wr->uid = current_fsuid(); wr->gid = current_fsgid(); - SetPagePrivate(page); - set_page_private(page, (unsigned long)wr); - get_page(page); + attach_page_private(page, wr); okay: return 0; } @@ -459,18 +452,12 @@ static void orangefs_invalidatepage(struct page *page, wr = (struct orangefs_write_range *)page_private(page); if (offset == 0 && length == PAGE_SIZE) { - kfree((struct orangefs_write_range *)page_private(page)); - set_page_private(page, 0); - ClearPagePrivate(page); - put_page(page); + kfree(clear_page_private(page)); return; /* write range entirely within invalidate range (or equal) */ } else if (page_offset(page) + offset <= wr->pos && wr->pos + wr->len <= page_offset(page) + offset + length) { - kfree((struct orangefs_write_range *)page_private(page)); - set_page_private(page, 0); - ClearPagePrivate(page); - put_page(page); + kfree(clear_page_private(page)); /* XXX is this right? only caller in fs */ cancel_dirty_page(page); return; @@ -535,12 +522,7 @@ static int orangefs_releasepage(struct page *page, gfp_t foo) static void orangefs_freepage(struct page *page) { - if (PagePrivate(page)) { - kfree((struct orangefs_write_range *)page_private(page)); - set_page_private(page, 0); - ClearPagePrivate(page); - put_page(page); - } + kfree(clear_page_private(page)); } static int orangefs_launder_page(struct page *page) @@ -740,9 +722,7 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf) wr->len = PAGE_SIZE; wr->uid = current_fsuid(); wr->gid = current_fsgid(); - SetPagePrivate(page); - set_page_private(page, (unsigned long)wr); - get_page(page); + attach_page_private(page, wr); okay: file_update_time(vmf->vma->vm_file); From patchwork Thu Apr 30 21:44:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 11521711 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D1F4913 for ; Thu, 30 Apr 2020 21:52:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 153E121775 for ; Thu, 30 Apr 2020 21:52:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="h2hh4ukd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727947AbgD3Vwy (ORCPT ); Thu, 30 Apr 2020 17:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727919AbgD3Vwt (ORCPT ); Thu, 30 Apr 2020 17:52:49 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA7BC08E934 for ; Thu, 30 Apr 2020 14:52:47 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id w2so5810488edx.4 for ; Thu, 30 Apr 2020 14:52:47 -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=sVC4XtCI51zwuXU4kfWUPmx3mXCoCkfv76JEys4qRWI=; b=h2hh4ukdjcrj1rKmeKUhGkIVIjVb+CMDuH/sGucO7vCFGioyAXpgts7c4azzs0Gv7I wrrOrJwzU58JHtDYO/oOtVLQCBlpEQUKurGOOWp5RON/lTp6xfIclss2781r6FT2zQjS waJNn4vy45DkGKi2F57eOjNlloFB9D2TGMAF2DfeQd8ohuFn2EMA9lBw3MtHlItasTn9 wOTEDBE7MleC0ix9SqqkvpZrZ1sgdUaF2T+Av7FJzZBBcKhUcdAmdu9JJMmDy91e2g+Z LF1NGTxFVnN7PPxwmfknLpvMMpUf8O1hq9o353eJlvR73KIYEeo13Rl69tHDdOm7Bj85 8f3A== 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=sVC4XtCI51zwuXU4kfWUPmx3mXCoCkfv76JEys4qRWI=; b=FqsSJt8vBzyXylRntP+IOD/SnKR66BFZx1WpTQDvOhg94MByCsVsvt0gkKVayFQWPM ah5ig+9f11rSXuD9nsIFV8KPZmGzgkRHwOlpjKF1UIYledWNJwuk9n6qZuolM1xRJwLJ DDUsFqDdG3AbmNMzqVnpx7uWyQPJ5/AVEueXgORtk8JHhSMQMMwZUhiqStEUSYEzZIIH tQvmDYmRDl+y2KZfqYK+9XtsAG4cqdwfFMkHK2Jygukwu0k19BPj+OmGE27Z2o67Q/8c HxDRJejJZZMMzEazMC5pdw0rt0HqfTfBGZWIrwWRFkphiquRzaCOG3hpZ7/tMn3lJlgk vDyw== X-Gm-Message-State: AGi0PubkiDRgWsMtgqjWy2+O2Q/kbsm+wDDBFeLsKIMdY8zwezmupcFF cs6wH3wCKkceND3tnGfFa9j8woHzUZXxLA== X-Google-Smtp-Source: APiQypLipNJe1CcB6DTPAa4UTwx9mH+5ihqyAcGLs5v0DbpMIgL9Cfj+7fXuU233MI38OzTIhsROgw== X-Received: by 2002:aa7:d481:: with SMTP id b1mr1073575edr.226.1588283565949; Thu, 30 Apr 2020 14:52:45 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:45 -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 , Thomas Gleixner , Sebastian Andrzej Siewior , Roman Gushchin , Andreas Dilger Subject: [RFC PATCH V2 9/9] buffer_head.h: remove attach_page_buffers Date: Thu, 30 Apr 2020 23:44:50 +0200 Message-Id: <20200430214450.10662-10-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org All the callers have replaced attach_page_buffers with the new function attach_page_private, so remove it. Cc: Thomas Gleixner Cc: Sebastian Andrzej Siewior Cc: Roman Gushchin Cc: Andreas Dilger Signed-off-by: Guoqing Jiang --- include/linux/buffer_head.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 15b765a181b8..22fb11e2d2e0 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -272,14 +272,6 @@ void buffer_init(void); * inline definitions */ -static inline void attach_page_buffers(struct page *page, - struct buffer_head *head) -{ - get_page(page); - SetPagePrivate(page); - set_page_private(page, (unsigned long)head); -} - static inline void get_bh(struct buffer_head *bh) { atomic_inc(&bh->b_count);