Skip to content

Commit

Permalink
btrfs: use for loop in prealloc_file_extent_cluster
Browse files Browse the repository at this point in the history
This function iterates all extents in the extent cluster, make this
intention obvious by using a for loop. No functional chanes.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Nikolay Borisov authored and David Sterba committed Jul 27, 2020
1 parent 214e61d commit 4e9d0d0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -2580,7 +2580,7 @@ int prealloc_file_extent_cluster(struct inode *inode,
u64 end;
u64 offset = BTRFS_I(inode)->index_cnt;
u64 num_bytes;
int nr = 0;
int nr;
int ret = 0;
u64 prealloc_start = cluster->start - offset;
u64 prealloc_end = cluster->end - offset;
Expand All @@ -2593,7 +2593,7 @@ int prealloc_file_extent_cluster(struct inode *inode,
return ret;

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

Expand Down

0 comments on commit 4e9d0d0

Please sign in to comment.