[44/46] btrfs: Make prealloc_file_extent_cluster take btrfs_inode
diff mbox series

Message ID 20200603055546.3889-45-nborisov@suse.com
State New
Headers show
Series
  • Trivial BTRFS_I removal
Related show

Commit Message

Nikolay Borisov June 3, 2020, 5:55 a.m. UTC
The vfs inode is only used for a pair of inode_lock/unlock calls all other uses
call for btrfs_inode.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/relocation.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

--
2.17.1

Patch
diff mbox series

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index fd8710837430..b48a8e9c844e 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2572,13 +2572,13 @@  int relocate_tree_blocks(struct btrfs_trans_handle *trans,
 }

 static noinline_for_stack
-int prealloc_file_extent_cluster(struct inode *inode,
+int prealloc_file_extent_cluster(struct btrfs_inode *inode,
 				 struct file_extent_cluster *cluster)
 {
 	u64 alloc_hint = 0;
 	u64 start;
 	u64 end;
-	u64 offset = BTRFS_I(inode)->index_cnt;
+	u64 offset = inode->index_cnt;
 	u64 num_bytes;
 	int nr = 0;
 	int ret = 0;
@@ -2588,10 +2588,9 @@  int prealloc_file_extent_cluster(struct inode *inode,
 	struct extent_changeset *data_reserved = NULL;

 	BUG_ON(cluster->start != cluster->boundary[0]);
-	inode_lock(inode);
+	inode_lock(&inode->vfs_inode);

-	ret = btrfs_check_data_free_space(BTRFS_I(inode), &data_reserved,
-					  prealloc_start,
+	ret = btrfs_check_data_free_space(inode, &data_reserved, prealloc_start,
 					  prealloc_end + 1 - prealloc_start);
 	if (ret)
 		goto out;
@@ -2604,26 +2603,25 @@  int prealloc_file_extent_cluster(struct inode *inode,
 		else
 			end = cluster->end - offset;

-		lock_extent(&BTRFS_I(inode)->io_tree, start, end);
+		lock_extent(&inode->io_tree, start, end);
 		num_bytes = end + 1 - start;
 		if (cur_offset < start)
-			btrfs_free_reserved_data_space(BTRFS_I(inode),
-					data_reserved, cur_offset,
-					start - cur_offset);
-		ret = btrfs_prealloc_file_range(inode, 0, start,
+			btrfs_free_reserved_data_space(inode, data_reserved,
+						cur_offset, start - cur_offset);
+		ret = btrfs_prealloc_file_range(&inode->vfs_inode, 0, start,
 						num_bytes, num_bytes,
 						end + 1, &alloc_hint);
 		cur_offset = end + 1;
-		unlock_extent(&BTRFS_I(inode)->io_tree, start, end);
+		unlock_extent(&inode->io_tree, start, end);
 		if (ret)
 			break;
 		nr++;
 	}
 	if (cur_offset < prealloc_end)
-		btrfs_free_reserved_data_space(BTRFS_I(inode), data_reserved,
-				cur_offset, prealloc_end + 1 - cur_offset);
+		btrfs_free_reserved_data_space(inode, data_reserved, cur_offset,
+					       prealloc_end + 1 - cur_offset);
 out:
-	inode_unlock(inode);
+	inode_unlock(&inode->vfs_inode);
 	extent_changeset_free(data_reserved);
 	return ret;
 }
@@ -2692,7 +2690,7 @@  static int relocate_file_extent_cluster(struct inode *inode,
 	if (!ra)
 		return -ENOMEM;

-	ret = prealloc_file_extent_cluster(inode, cluster);
+	ret = prealloc_file_extent_cluster(BTRFS_I(inode), cluster);
 	if (ret)
 		goto out;