Commit 4e9d0d01 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba
Browse files

btrfs: use for loop in prealloc_file_extent_cluster



This function iterates all extents in the extent cluster, make this
intention obvious by using a for loop. No functional chanes.

Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 214e61d0
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -2580,7 +2580,7 @@ int prealloc_file_extent_cluster(struct inode *inode,
	u64 end;
	u64 end;
	u64 offset = BTRFS_I(inode)->index_cnt;
	u64 offset = BTRFS_I(inode)->index_cnt;
	u64 num_bytes;
	u64 num_bytes;
	int nr = 0;
	int nr;
	int ret = 0;
	int ret = 0;
	u64 prealloc_start = cluster->start - offset;
	u64 prealloc_start = cluster->start - offset;
	u64 prealloc_end = cluster->end - offset;
	u64 prealloc_end = cluster->end - offset;
@@ -2593,7 +2593,7 @@ int prealloc_file_extent_cluster(struct inode *inode,
		return ret;
		return ret;


	inode_lock(inode);
	inode_lock(inode);
	while (nr < cluster->nr) {
	for (nr = 0; nr < cluster->nr; nr++) {
		start = cluster->boundary[nr] - offset;
		start = cluster->boundary[nr] - offset;
		if (nr + 1 < cluster->nr)
		if (nr + 1 < cluster->nr)
			end = cluster->boundary[nr + 1] - 1 - offset;
			end = cluster->boundary[nr + 1] - 1 - offset;
@@ -2609,7 +2609,6 @@ int prealloc_file_extent_cluster(struct inode *inode,
		unlock_extent(&BTRFS_I(inode)->io_tree, start, end);
		unlock_extent(&BTRFS_I(inode)->io_tree, start, end);
		if (ret)
		if (ret)
			break;
			break;
		nr++;
	}
	}
	inode_unlock(inode);
	inode_unlock(inode);