]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/subvolume.c
Update bcachefs sources to 33a60d9b05 bcachefs: Assorted fixes for clang
[bcachefs-tools-debian] / libbcachefs / subvolume.c
index 811a6f4286aaef9c6c176cf7c379ea02f06c2d6e..736afb626a8945b75d4bc3300fb15fb60d594de8 100644 (file)
@@ -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,