Btrfs: cleanup to remove reduplicate code in iterate_extent_inode()
PATCH 1/1 Btrfs: cleanup to remove reduplicate code in iterate_extent_inode()
From: Wang Shilong <[email protected]>
Just remove the unnecessary check and assignment.
--- fs/btrfs/backref.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/backref.c +1 -2
@@ -1499,7 +1499,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,if (ret)break ;ULIST_ITER_INIT (&root_uiter); -while (!ret && (root_node =ulist_next (roots, &root_uiter))) { +while ((root_node =ulist_next (roots, &root_uiter))) {pr_debug ("root %llu references leaf %llu, data list " "%#llx\n" , root_node->val, ref_node->val, (long long )ref_node->aux);
@@ -1510,7 +1510,6 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, iterate, ctx); }ulist_free (roots); - roots =NULL ; }free_leaf_list (refs);
Signature · 1 line
1.7.11.7
Quoted 14 lines · Wang Shilong
From: Wang Shilong <[email protected]>
Just remove the unnecessary check and assignment.
Signed-off-by Wang Shilong <[email protected]>--- fs/btrfs/backref.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/backref.c +0
-0
fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1502
Quoted 5 lines
fs/btrfs/backref.c +1
-1@@ -1499,7 +1499,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,if (ret)break ;ULIST_ITER_INIT (&root_uiter); -while (!ret && (root_node =ulist_next (roots, &root_uiter))) { +while ((root_node =ulist_next (roots, &root_uiter))) {
It doesn't look unnecessary at all to me. ret is set in the loop and only checked in the while condition.
fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1513
Quoted 8 lines
fs/btrfs/backref.c +0
-1pr_debug ("root %llu references leaf %llu, data list " "%#llx\n" , root_node->val, ref_node->val, (long long )ref_node->aux);@@ -1510,7 +1510,6 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, iterate, ctx); }ulist_free (roots); - roots =NULL ;
roots gets freed again later on. If you don't set it to NULL, it will result in a double free.
-Arne
Quoted 4 lines
fs/btrfs/backref.c +0
-0}free_leaf_list (refs);
Hello,
Quoted 10 lines · Wang Shilong
Quoted 9 lines
From: Wang Shilong <[email protected]>
Just remove the unnecessary check and assignment.
Signed-off-by Wang Shilong <[email protected]>---
fs/btrfs/backref.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 13 lines
fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1502
Quoted 10 lines
fs/btrfs/backref.c +1
-1@@ -1499,7 +1499,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,if (ret)break ;ULIST_ITER_INIT (&root_uiter); -while (!ret && (root_node =ulist_next (roots, &root_uiter))) { +while ((root_node =ulist_next (roots, &root_uiter))) {It doesn't look unnecessary at all to me. ret is set in the loop and only checked in the while condition.
Yeah, you are right..
Quoted 12 lines
fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1513
Quoted 9 lines
fs/btrfs/backref.c +0
-1pr_debug ("root %llu references leaf %llu, data list " "%#llx\n" , root_node->val, ref_node->val, (long long )ref_node->aux);@@ -1510,7 +1510,6 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, iterate, ctx); }ulist_free (roots); - roots =NULL ;roots gets freed again later on. If you don't set it to NULL, it will result in a double free.
If we are in the loop, 'roots' will be reallocated again, if relocation in the find_all_roots() fails, 'roots' has been dealt in the find_all_roots(), and we have breaked out the loop.
I don't know where a double may happen? Am i missing something?
Thanks,
Wang
Quoted 8 lines
-Arne
Quoted 4 lines
fs/btrfs/backref.c +0
-0}free_leaf_list (refs);
<snip>
Quoted 24 lines · Wang Shilong
Quoted 14 lines
From: Wang Shilong <[email protected]>
Just remove the unnecessary check and assignment.
Signed-off-by Wang Shilong <[email protected]>---
fs/btrfs/backref.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/backref.c +0
-0fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1502
Quoted 5 lines
fs/btrfs/backref.c +1
-1@@ -1499,7 +1499,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,if (ret)break ;ULIST_ITER_INIT (&root_uiter); -while (!ret && (root_node =ulist_next (roots, &root_uiter))) { +while ((root_node =ulist_next (roots, &root_uiter))) {It doesn't look unnecessary at all to me. ret is set in the loop and only checked in the while condition.
Quoted 11 lines
fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1513
Quoted 8 lines
fs/btrfs/backref.c +0
-1pr_debug ("root %llu references leaf %llu, data list " "%#llx\n" , root_node->val, ref_node->val, (long long )ref_node->aux);@@ -1510,7 +1510,6 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, iterate, ctx); }ulist_free (roots); - roots =NULL ;roots gets freed again later on. If you don't set it to NULL, it will result in a double free.
Maybe you mean this?
http://marc.info/?l=linux-btrfs&m=136456233929528&w=2ulist_free() here is unnecessary and may cause a double free… So we don't need to set it to NULL again..
Quoted 8 lines
-Arne
Quoted 4 lines
fs/btrfs/backref.c +0
-0}free_leaf_list (refs);
Quoted 38 lines · Wang Shilong
<snip>
Quoted 24 lines · Wang Shilong
Quoted 14 lines
From: Wang Shilong <[email protected]>
Just remove the unnecessary check and assignment.
Signed-off-by Wang Shilong <[email protected]>---
fs/btrfs/backref.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/backref.c +0
-0fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1502
Quoted 5 lines
fs/btrfs/backref.c +1
-1@@ -1499,7 +1499,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,if (ret)break ;ULIST_ITER_INIT (&root_uiter); -while (!ret && (root_node =ulist_next (roots, &root_uiter))) { +while ((root_node =ulist_next (roots, &root_uiter))) {It doesn't look unnecessary at all to me. ret is set in the loop and only checked in the while condition.
Quoted 11 lines
fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1513
Quoted 8 lines
fs/btrfs/backref.c +0
-1pr_debug ("root %llu references leaf %llu, data list " "%#llx\n" , root_node->val, ref_node->val, (long long )ref_node->aux);@@ -1510,7 +1510,6 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, iterate, ctx); }ulist_free (roots); - roots =NULL ;roots gets freed again later on. If you don't set it to NULL, it will result in a double free.
Quoted 5 lines
Maybe you mean this?
http://marc.info/?l=linux-btrfs&m=136456233929528&w=2
ulist_free()here is unnecessary and may cause a double free… So we don't need to set it to NULL again..
Yeah, I haven't seen your other patch.
Quoted 12 lines
Quoted 11 lines
-Arne
Quoted 4 lines
fs/btrfs/backref.c +0
-0}free_leaf_list (refs);
Just ignore this patch, i have merge the correct modification
of this patch to the [patch V2] fix double free in the iterate_extent_inodes().
Thanks,
Wang
Quoted 60 lines · Wang Shilong
Quoted 38 lines
<snip>
Quoted 24 lines · Wang Shilong
Quoted 14 lines
From: Wang Shilong <[email protected]>
Just remove the unnecessary check and assignment.
Signed-off-by Wang Shilong <[email protected]>---
fs/btrfs/backref.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/backref.c +0
-0fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1502
Quoted 5 lines
fs/btrfs/backref.c +1
-1@@ -1499,7 +1499,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,if (ret)break ;ULIST_ITER_INIT (&root_uiter); -while (!ret && (root_node =ulist_next (roots, &root_uiter))) { +while ((root_node =ulist_next (roots, &root_uiter))) {It doesn't look unnecessary at all to me. ret is set in the loop and only checked in the while condition.
Quoted 11 lines
fs/btrfs/backref.c int iterate_extent_inodes(struct btrfs_fs_info *fs_info, · line 1513
Quoted 8 lines
fs/btrfs/backref.c +0
-1pr_debug ("root %llu references leaf %llu, data list " "%#llx\n" , root_node->val, ref_node->val, (long long )ref_node->aux);@@ -1510,7 +1510,6 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, iterate, ctx); }ulist_free (roots); - roots =NULL ;roots gets freed again later on. If you don't set it to NULL, it will result in a double free.
Quoted 5 lines
Maybe you mean this?
http://marc.info/?l=linux-btrfs&m=136456233929528&w=2
ulist_free()here is unnecessary and may cause a double free… So we don't need to set it to NULL again..Yeah, I haven't seen your other patch.
Quoted 12 lines
Quoted 11 lines
-Arne
Quoted 4 lines
fs/btrfs/backref.c +0
-0}free_leaf_list (refs);