diff mbox series

[v4,57/68] btrfs: file: make btrfs_file_write_iter() to be page aligned

Message ID 20201021062554.68132-58-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
This is mostly for subpage write support, as we don't support to submit
subpage sized write yet, so we have to submit the full page write.

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

Patch

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 30b22303ad2c..8f44bde1d04e 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1909,6 +1909,7 @@  static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
 	struct inode *inode = file_inode(file);
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	struct btrfs_root *root = BTRFS_I(inode)->root;
+	u32 blocksize = PAGE_SIZE;
 	u64 start_pos;
 	u64 end_pos;
 	ssize_t num_written = 0;
@@ -1988,18 +1989,17 @@  static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
 	 */
 	update_time_for_write(inode);
 
-	start_pos = round_down(pos, fs_info->sectorsize);
+	start_pos = round_down(pos, blocksize);
 	oldsize = i_size_read(inode);
 	if (start_pos > oldsize) {
 		/* Expand hole size to cover write data, preventing empty gap */
-		end_pos = round_up(pos + count,
-				   fs_info->sectorsize);
+		end_pos = round_up(pos + count, blocksize);
 		err = btrfs_cont_expand(inode, oldsize, end_pos);
 		if (err) {
 			inode_unlock(inode);
 			goto out;
 		}
-		if (start_pos > round_up(oldsize, fs_info->sectorsize))
+		if (start_pos > round_up(oldsize, blocksize))
 			clean_page = 1;
 	}