Message ID | 20200617091044.27846-4-nborisov@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | None | expand |
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
I've you have to re-post another potential candidate in this
function would be:
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 9235c671bef8..3ebf64578a32 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2578,7 +2578,8 @@ int prealloc_file_extent_cluster(struct inode *inode,
u64 alloc_hint = 0;
u64 start;
u64 end;
- u64 offset = BTRFS_I(inode)->index_cnt;
+ struct btrfs_inode *btrfs_inode = BTRFS_I(inode);
+ u64 offset = btrfs_inode->index_cnt;
u64 num_bytes;
int nr = 0;
int ret = 0;
@@ -2589,7 +2590,7 @@ int prealloc_file_extent_cluster(struct inode *inode,
BUG_ON(cluster->start != cluster->boundary[0]);
inode_lock(inode);
- ret = btrfs_alloc_data_chunk_ondemand(BTRFS_I(inode),
+ ret = btrfs_alloc_data_chunk_ondemand(btrfs_inode,
prealloc_end + 1 - prealloc_start);
if (ret)
goto out;
@@ -2611,7 +2612,7 @@ int prealloc_file_extent_cluster(struct inode *inode,
num_bytes, num_bytes,
end + 1, &alloc_hint);
cur_offset = end + 1;
- unlock_extent(&BTRFS_I(inode)->io_tree, start, end);
+ unlock_extent(&btrfs_inode->io_tree, start, end);
if (ret)
break;
nr++;
This would save 3 BTRFS_I() calls, but not sure how much of a difference it
makes in the end.
On 17.06.20 г. 16:02 ч., Johannes Thumshirn wrote: > Looks good, > Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > > I've you have to re-post another potential candidate in this > function would be: > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c > index 9235c671bef8..3ebf64578a32 100644 > --- a/fs/btrfs/relocation.c > +++ b/fs/btrfs/relocation.c > @@ -2578,7 +2578,8 @@ int prealloc_file_extent_cluster(struct inode *inode, > u64 alloc_hint = 0; > u64 start; > u64 end; > - u64 offset = BTRFS_I(inode)->index_cnt; > + struct btrfs_inode *btrfs_inode = BTRFS_I(inode); > + u64 offset = btrfs_inode->index_cnt; > u64 num_bytes; > int nr = 0; > int ret = 0; > @@ -2589,7 +2590,7 @@ int prealloc_file_extent_cluster(struct inode *inode, > BUG_ON(cluster->start != cluster->boundary[0]); > inode_lock(inode); > > - ret = btrfs_alloc_data_chunk_ondemand(BTRFS_I(inode), > + ret = btrfs_alloc_data_chunk_ondemand(btrfs_inode, > prealloc_end + 1 - prealloc_start); > if (ret) > goto out; > @@ -2611,7 +2612,7 @@ int prealloc_file_extent_cluster(struct inode *inode, > num_bytes, num_bytes, > end + 1, &alloc_hint); > cur_offset = end + 1; > - unlock_extent(&BTRFS_I(inode)->io_tree, start, end); > + unlock_extent(&btrfs_inode->io_tree, start, end); > if (ret) > break; > nr++; > > > This would save 3 BTRFS_I() calls, but not sure how much of a difference it > makes in the end. > As a matter of fact I've already done this in my monstrous in patch 44/46.
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 020d04035be1..8972aa574a05 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -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; @@ -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; @@ -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);
This function iterates all extents in the extent cluster, make this intention obvious by using a for loop. No functional chanes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- fs/btrfs/relocation.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)