Commit 85103d15 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix error path in bch2_replicas_gc_end()

We were dropping a lock we hadn't taken when entering with an error.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent b65db750
...@@ -462,18 +462,13 @@ int bch2_replicas_gc_end(struct bch_fs *c, int ret) ...@@ -462,18 +462,13 @@ int bch2_replicas_gc_end(struct bch_fs *c, int ret)
{ {
lockdep_assert_held(&c->replicas_gc_lock); lockdep_assert_held(&c->replicas_gc_lock);
if (ret)
goto err;
mutex_lock(&c->sb_lock); mutex_lock(&c->sb_lock);
percpu_down_write(&c->mark_lock); percpu_down_write(&c->mark_lock);
ret = bch2_cpu_replicas_to_sb_replicas(c, &c->replicas_gc); ret = ret ?:
if (ret) bch2_cpu_replicas_to_sb_replicas(c, &c->replicas_gc) ?:
goto err; replicas_table_update(c, &c->replicas_gc);
ret = replicas_table_update(c, &c->replicas_gc);
err:
kfree(c->replicas_gc.entries); kfree(c->replicas_gc.entries);
c->replicas_gc.entries = NULL; c->replicas_gc.entries = NULL;
...@@ -579,12 +574,9 @@ int bch2_replicas_gc2(struct bch_fs *c) ...@@ -579,12 +574,9 @@ int bch2_replicas_gc2(struct bch_fs *c)
bch2_cpu_replicas_sort(&new); bch2_cpu_replicas_sort(&new);
ret = bch2_cpu_replicas_to_sb_replicas(c, &new); ret = bch2_cpu_replicas_to_sb_replicas(c, &new) ?:
if (ret) replicas_table_update(c, &new);
goto err;
ret = replicas_table_update(c, &new);
err:
kfree(new.entries); kfree(new.entries);
percpu_up_write(&c->mark_lock); percpu_up_write(&c->mark_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment