X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libbcachefs%2Fsubvolume.c;h=736afb626a8945b75d4bc3300fb15fb60d594de8;hb=87179c7a6e2a210ea57951d444a3055e883d08fa;hp=811a6f4286aaef9c6c176cf7c379ea02f06c2d6e;hpb=2d7982de784b24e24baa20eee0a97dea451b8fa7;p=bcachefs-tools-debian diff --git a/libbcachefs/subvolume.c b/libbcachefs/subvolume.c index 811a6f4..736afb6 100644 --- a/libbcachefs/subvolume.c +++ b/libbcachefs/subvolume.c @@ -83,7 +83,7 @@ static noinline struct snapshot_t *__snapshot_t_mut(struct bch_fs *c, u32 id) if (!new) return NULL; - old = c->snapshots; + old = rcu_dereference_protected(c->snapshots, true); if (old) memcpy(new->s, rcu_dereference_protected(c->snapshots, true)->s, @@ -698,6 +698,11 @@ err: return ret; } +static int cmp_le32(__le32 l, __le32 r) +{ + return cmp_int(le32_to_cpu(l), le32_to_cpu(r)); +} + static int check_snapshot(struct btree_trans *trans, struct btree_iter *iter, struct bkey_s_c k) @@ -830,7 +835,7 @@ static int check_snapshot(struct btree_trans *trans, for (i = 0; i < ARRAY_SIZE(u->v.skip); i++) u->v.skip[i] = cpu_to_le32(snapshot_skiplist_get(c, parent_id)); - bubble_sort(u->v.skip, ARRAY_SIZE(u->v.skip), cmp_int); + bubble_sort(u->v.skip, ARRAY_SIZE(u->v.skip), cmp_le32); s = u->v; } ret = 0; @@ -946,7 +951,7 @@ int bch2_check_subvols(struct bch_fs *c) void bch2_fs_snapshots_exit(struct bch_fs *c) { - kfree(c->snapshots); + kfree(rcu_dereference_protected(c->snapshots, true)); } int bch2_snapshots_read(struct bch_fs *c) @@ -1123,7 +1128,7 @@ static int create_snapids(struct btree_trans *trans, u32 parent, u32 tree, for (j = 0; j < ARRAY_SIZE(n->v.skip); j++) n->v.skip[j] = cpu_to_le32(snapshot_skiplist_get(c, parent)); - bubble_sort(n->v.skip, ARRAY_SIZE(n->v.skip), cmp_int); + bubble_sort(n->v.skip, ARRAY_SIZE(n->v.skip), cmp_le32); SET_BCH_SNAPSHOT_SUBVOL(&n->v, true); ret = bch2_mark_snapshot(trans, BTREE_ID_snapshots, 0,