Skip to content

Commit 85103d1

Browse files
author
Kent Overstreet
committed
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: Kent Overstreet <kent.overstreet@linux.dev>
1 parent b65db75 commit 85103d1

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

fs/bcachefs/replicas.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,13 @@ int bch2_replicas_gc_end(struct bch_fs *c, int ret)
462462
{
463463
lockdep_assert_held(&c->replicas_gc_lock);
464464

465-
if (ret)
466-
goto err;
467-
468465
mutex_lock(&c->sb_lock);
469466
percpu_down_write(&c->mark_lock);
470467

471-
ret = bch2_cpu_replicas_to_sb_replicas(c, &c->replicas_gc);
472-
if (ret)
473-
goto err;
468+
ret = ret ?:
469+
bch2_cpu_replicas_to_sb_replicas(c, &c->replicas_gc) ?:
470+
replicas_table_update(c, &c->replicas_gc);
474471

475-
ret = replicas_table_update(c, &c->replicas_gc);
476-
err:
477472
kfree(c->replicas_gc.entries);
478473
c->replicas_gc.entries = NULL;
479474

@@ -579,12 +574,9 @@ int bch2_replicas_gc2(struct bch_fs *c)
579574

580575
bch2_cpu_replicas_sort(&new);
581576

582-
ret = bch2_cpu_replicas_to_sb_replicas(c, &new);
583-
if (ret)
584-
goto err;
577+
ret = bch2_cpu_replicas_to_sb_replicas(c, &new) ?:
578+
replicas_table_update(c, &new);
585579

586-
ret = replicas_table_update(c, &new);
587-
err:
588580
kfree(new.entries);
589581

590582
percpu_up_write(&c->mark_lock);

0 commit comments

Comments
 (0)