diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-02-05 02:26:56 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2018-02-05 02:26:56 -0500 |
commit | 7ca94bff08883ab97dc1e4e3bbe1c63cc66be9bb (patch) | |
tree | 9c9b872b12e4a9130d16d9a7c7a86e8b6a8be513 | |
parent | 0e765bc37c971c4b0c91ddd281e5ea82e2d682dc (diff) |
bcachefs: fix a race in bch2_check_mark_super()
-rw-r--r-- | fs/bcachefs/super-io.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index e3c319fc5390..1f266ba37386 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -1077,6 +1077,11 @@ static int bch2_check_mark_super_slowpath(struct bch_fs *c, /* allocations done, now commit: */ + if (new_r) + bch2_write_super(c); + + /* don't update in memory replicas until changes are persistent */ + if (new_gc) { rcu_assign_pointer(c->replicas_gc, new_gc); kfree_rcu(old_gc, rcu); @@ -1085,7 +1090,6 @@ static int bch2_check_mark_super_slowpath(struct bch_fs *c, if (new_r) { rcu_assign_pointer(c->replicas, new_r); kfree_rcu(old_r, rcu); - bch2_write_super(c); } mutex_unlock(&c->sb_lock); |