diff mbox series

[v4,56/68] btrfs: file: make btrfs_dirty_pages() follow page size to mark extent io tree

Message ID 20201021062554.68132-57-wqu@suse.com
State New, archived
Headers show
Series btrfs: add basic rw support for subpage sector size | expand

Commit Message

Qu Wenruo Oct. 21, 2020, 6:25 a.m. UTC
Currently btrfs_dirty_pages() follows sector size to mark extent io
tree, but since we currently don't follow subpage data writeback, this
could cause extra problem for subpage support.

Change it to do page alignement.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/file.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index cb8f2b04ccd8..30b22303ad2c 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -504,9 +504,9 @@  int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages,
 		      size_t num_pages, loff_t pos, size_t write_bytes,
 		      struct extent_state **cached)
 {
-	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	int err = 0;
 	int i;
+	u32 blocksize = PAGE_SIZE;
 	u64 num_bytes;
 	u64 start_pos;
 	u64 end_of_last_block;
@@ -514,9 +514,8 @@  int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages,
 	loff_t isize = i_size_read(&inode->vfs_inode);
 	unsigned int extra_bits = 0;
 
-	start_pos = pos & ~((u64) fs_info->sectorsize - 1);
-	num_bytes = round_up(write_bytes + pos - start_pos,
-			     fs_info->sectorsize);
+	start_pos = round_down(pos, blocksize);
+	num_bytes = round_up(write_bytes + pos - start_pos, blocksize);
 
 	end_of_last_block = start_pos + num_bytes - 1;