diff mbox series

[v4,59/68] btrfs: delalloc-space: make data space reservation to be page aligned

Message ID 20201021062554.68132-60-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 for initial subpage data write support.
Currently we don't yet support full subpage data write, but still full
page data writeback.

Thus change data reserve and release code to be page aligned.

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

Patch

diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c
index 0e354e9e57d0..1f2b324485f5 100644
--- a/fs/btrfs/delalloc-space.c
+++ b/fs/btrfs/delalloc-space.c
@@ -116,13 +116,14 @@  int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes)
 	struct btrfs_root *root = inode->root;
 	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct btrfs_space_info *data_sinfo = fs_info->data_sinfo;
+	u32 blocksize = PAGE_SIZE;
 	u64 used;
 	int ret = 0;
 	int need_commit = 2;
 	int have_pinned_space;
 
-	/* Make sure bytes are sectorsize aligned */
-	bytes = ALIGN(bytes, fs_info->sectorsize);
+	/* Make sure bytes are aligned */
+	bytes = round_up(bytes, blocksize);
 
 	if (btrfs_is_free_space_inode(inode)) {
 		need_commit = 0;
@@ -241,12 +242,12 @@  int btrfs_check_data_free_space(struct btrfs_inode *inode,
 			struct extent_changeset **reserved, u64 start, u64 len)
 {
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
+	u32 blocksize = PAGE_SIZE;
 	int ret;
 
 	/* align the range */
-	len = round_up(start + len, fs_info->sectorsize) -
-	      round_down(start, fs_info->sectorsize);
-	start = round_down(start, fs_info->sectorsize);
+	len = round_up(start + len, blocksize) - round_down(start, blocksize);
+	start = round_down(start, blocksize);
 
 	ret = btrfs_alloc_data_chunk_ondemand(inode, len);
 	if (ret < 0)
@@ -293,11 +294,11 @@  void btrfs_free_reserved_data_space(struct btrfs_inode *inode,
 			struct extent_changeset *reserved, u64 start, u64 len)
 {
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
+	u32 blocksize = PAGE_SIZE;
 
-	/* Make sure the range is aligned to sectorsize */
-	len = round_up(start + len, fs_info->sectorsize) -
-	      round_down(start, fs_info->sectorsize);
-	start = round_down(start, fs_info->sectorsize);
+	/* Make sure the range is aligned */
+	len = round_up(start + len, blocksize) - round_down(start, blocksize);
+	start = round_down(start, blocksize);
 
 	btrfs_free_reserved_data_space_noquota(fs_info, len);
 	btrfs_qgroup_free_data(inode, reserved, start, len);