btrfs: make btrfs_dirty_pages() to be subpage compatible
authorQu Wenruo <wqu@suse.com>
Mon, 31 May 2021 08:50:41 +0000 (16:50 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jun 2021 13:19:09 +0000 (15:19 +0200)
Since the extent io tree operations in btrfs_dirty_pages() are already
subpage compatible, we only need to make the page status update to use
subpage helpers.

Tested-by: Ritesh Harjani <riteshh@linux.ibm.com> # [ppc64]
Tested-by: Anand Jain <anand.jain@oracle.com> # [aarch64]
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c

index a56a13999bd66e9be3f1649045585e785efb606a..617af76e876e54e1cc02fc78a92c29cc69e9e794 100644 (file)
@@ -28,6 +28,7 @@
 #include "compression.h"
 #include "delalloc-space.h"
 #include "reflink.h"
+#include "subpage.h"
 
 static struct kmem_cache *btrfs_inode_defrag_cachep;
 /*
@@ -482,6 +483,7 @@ int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages,
        start_pos = round_down(pos, fs_info->sectorsize);
        num_bytes = round_up(write_bytes + pos - start_pos,
                             fs_info->sectorsize);
+       ASSERT(num_bytes <= U32_MAX);
 
        end_of_last_block = start_pos + num_bytes - 1;
 
@@ -500,9 +502,10 @@ int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages,
 
        for (i = 0; i < num_pages; i++) {
                struct page *p = pages[i];
-               SetPageUptodate(p);
+
+               btrfs_page_clamp_set_uptodate(fs_info, p, start_pos, num_bytes);
                ClearPageChecked(p);
-               set_page_dirty(p);
+               btrfs_page_clamp_set_dirty(fs_info, p, start_pos, num_bytes);
        }
 
        /*