[2/5] btrfs: call __clear_page_buffers to simplify code
diff mbox series

Message ID 20200418225123.31850-3-guoqing.jiang@cloud.ionos.com
State New
Headers show
Series
  • export __clear_page_buffers to cleanup code
Related show

Commit Message

Guoqing Jiang April 18, 2020, 10:51 p.m. UTC
Some places can be replaced with __clear_page_buffers after the function
is exported.

Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 fs/btrfs/disk-io.c   |  5 ++---
 fs/btrfs/extent_io.c |  6 ++----
 fs/btrfs/inode.c     | 14 ++++----------
 3 files changed, 8 insertions(+), 17 deletions(-)

Comments

David Sterba April 19, 2020, 7:46 p.m. UTC | #1
On Sun, Apr 19, 2020 at 12:51:20AM +0200, Guoqing Jiang wrote:
> Some places can be replaced with __clear_page_buffers after the function
> is exported.
> 
> Cc: Chris Mason <clm@fb.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: David Sterba <dsterba@suse.com>
> Cc: linux-btrfs@vger.kernel.org
> Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
> ---
>  fs/btrfs/disk-io.c   |  5 ++---
>  fs/btrfs/extent_io.c |  6 ++----
>  fs/btrfs/inode.c     | 14 ++++----------
>  3 files changed, 8 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index a6cb5cbbdb9f..0f1e5690e8a4 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -17,6 +17,7 @@
>  #include <linux/error-injection.h>
>  #include <linux/crc32c.h>
>  #include <linux/sched/mm.h>
> +#include <linux/buffer_head.h>

I'm not really thrilled to see buffer_head.h being added back, we're on
the track to remove buffer_head usage completely and adding it just for
one helper does not seem great to me.
Guoqing Jiang April 19, 2020, 8:32 p.m. UTC | #2
On 19.04.20 21:46, David Sterba wrote:
> On Sun, Apr 19, 2020 at 12:51:20AM +0200, Guoqing Jiang wrote:
>> Some places can be replaced with __clear_page_buffers after the function
>> is exported.
>>
>> Cc: Chris Mason <clm@fb.com>
>> Cc: Josef Bacik <josef@toxicpanda.com>
>> Cc: David Sterba <dsterba@suse.com>
>> Cc: linux-btrfs@vger.kernel.org
>> Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
>> ---
>>   fs/btrfs/disk-io.c   |  5 ++---
>>   fs/btrfs/extent_io.c |  6 ++----
>>   fs/btrfs/inode.c     | 14 ++++----------
>>   3 files changed, 8 insertions(+), 17 deletions(-)
>>
>> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
>> index a6cb5cbbdb9f..0f1e5690e8a4 100644
>> --- a/fs/btrfs/disk-io.c
>> +++ b/fs/btrfs/disk-io.c
>> @@ -17,6 +17,7 @@
>>   #include <linux/error-injection.h>
>>   #include <linux/crc32c.h>
>>   #include <linux/sched/mm.h>
>> +#include <linux/buffer_head.h>
> I'm not really thrilled to see buffer_head.h being added back, we're on
> the track to remove buffer_head usage completely and adding it just for
> one helper does not seem great to me.

Thanks for your reply, will drop this one.

Thanks,
Guoqing

Patch
diff mbox series

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index a6cb5cbbdb9f..0f1e5690e8a4 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -17,6 +17,7 @@ 
 #include <linux/error-injection.h>
 #include <linux/crc32c.h>
 #include <linux/sched/mm.h>
+#include <linux/buffer_head.h>
 #include <asm/unaligned.h>
 #include <crypto/hash.h>
 #include "ctree.h"
@@ -980,9 +981,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_buffers(page);
 	}
 }
 
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 39e45b8a5031..317a1cdc7d3e 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -13,6 +13,7 @@ 
 #include <linux/pagevec.h>
 #include <linux/prefetch.h>
 #include <linux/cleancache.h>
+#include <linux/buffer_head.h>
 #include "extent_io.h"
 #include "extent-io-tree.h"
 #include "extent_map.h"
@@ -4929,10 +4930,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_buffers(page);
 		}
 
 		if (mapped)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 320d1062068d..95886202c74f 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_buffers(page);
 	return ret;
 }
 
@@ -8458,11 +8455,8 @@  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);
-	}
+	if (PagePrivate(page))
+		__clear_page_buffers(page);
 }
 
 /*