Message ID | e38da2f7e722fbbb6e7653e69f1d28aa2e9e3bf4.1711488980.git.boris@bur.io (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: various qg meta rsv leak fixes | expand |
在 2024/3/27 08:09, Boris Burkov 写道: > It is possible to clear a root's IN_TRANS tag from the radix tree, but > not clear its pertrans, if there is some error in between. Eliminate > that possibility by moving the free up to where we clear the tag. > > Signed-off-by: Boris Burkov <boris@bur.io> Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/transaction.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c > index 1c449d1cea1b..df2e58aa824a 100644 > --- a/fs/btrfs/transaction.c > +++ b/fs/btrfs/transaction.c > @@ -1494,6 +1494,7 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) > radix_tree_tag_clear(&fs_info->fs_roots_radix, > (unsigned long)root->root_key.objectid, > BTRFS_ROOT_TRANS_TAG); > + btrfs_qgroup_free_meta_all_pertrans(root); > spin_unlock(&fs_info->fs_roots_radix_lock); > > btrfs_free_log(trans, root); > @@ -1518,7 +1519,6 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) > if (ret2) > return ret2; > spin_lock(&fs_info->fs_roots_radix_lock); > - btrfs_qgroup_free_meta_all_pertrans(root); > } > } > spin_unlock(&fs_info->fs_roots_radix_lock);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 1c449d1cea1b..df2e58aa824a 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1494,6 +1494,7 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) radix_tree_tag_clear(&fs_info->fs_roots_radix, (unsigned long)root->root_key.objectid, BTRFS_ROOT_TRANS_TAG); + btrfs_qgroup_free_meta_all_pertrans(root); spin_unlock(&fs_info->fs_roots_radix_lock); btrfs_free_log(trans, root); @@ -1518,7 +1519,6 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) if (ret2) return ret2; spin_lock(&fs_info->fs_roots_radix_lock); - btrfs_qgroup_free_meta_all_pertrans(root); } } spin_unlock(&fs_info->fs_roots_radix_lock);
It is possible to clear a root's IN_TRANS tag from the radix tree, but not clear its pertrans, if there is some error in between. Eliminate that possibility by moving the free up to where we clear the tag. Signed-off-by: Boris Burkov <boris@bur.io> --- fs/btrfs/transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)