]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/buckets.c
Update bcachefs sources to 8e1519ccb6 bcachefs: Add tracepoint & counter for btree...
[bcachefs-tools-debian] / libbcachefs / buckets.c
index fd3ba10bc8a74c4df2d24b9a1b4f1c08a51cd50b..95ece2ea8d59082988bfe741de51961ad62a6b1b 100644 (file)
@@ -907,10 +907,10 @@ static int bch2_mark_stripe_ptr(struct btree_trans *trans,
                return -ENOMEM;
        }
 
-       spin_lock(&c->ec_stripes_heap_lock);
+       mutex_lock(&c->ec_stripes_heap_lock);
 
        if (!m || !m->alive) {
-               spin_unlock(&c->ec_stripes_heap_lock);
+               mutex_unlock(&c->ec_stripes_heap_lock);
                bch_err_ratelimited(c, "pointer to nonexistent stripe %llu",
                                    (u64) p.idx);
                bch2_inconsistent_error(c);
@@ -920,7 +920,7 @@ static int bch2_mark_stripe_ptr(struct btree_trans *trans,
        m->block_sectors[p.block] += sectors;
 
        r = m->r;
-       spin_unlock(&c->ec_stripes_heap_lock);
+       mutex_unlock(&c->ec_stripes_heap_lock);
 
        r.e.data_type = data_type;
        update_replicas(c, k, &r.e, sectors, trans->journal_res.seq, true);
@@ -1031,7 +1031,7 @@ int bch2_mark_stripe(struct btree_trans *trans,
        if (!gc) {
                struct stripe *m = genradix_ptr(&c->stripes, idx);
 
-               if (!m || (old_s && !m->alive)) {
+               if (!m) {
                        struct printbuf buf1 = PRINTBUF;
                        struct printbuf buf2 = PRINTBUF;
 
@@ -1047,13 +1047,10 @@ int bch2_mark_stripe(struct btree_trans *trans,
                }
 
                if (!new_s) {
-                       spin_lock(&c->ec_stripes_heap_lock);
                        bch2_stripes_heap_del(c, m, idx);
-                       spin_unlock(&c->ec_stripes_heap_lock);
 
                        memset(m, 0, sizeof(*m));
                } else {
-                       m->alive        = true;
                        m->sectors      = le16_to_cpu(new_s->sectors);
                        m->algorithm    = new_s->algorithm;
                        m->nr_blocks    = new_s->nr_blocks;
@@ -1063,9 +1060,10 @@ int bch2_mark_stripe(struct btree_trans *trans,
                        for (i = 0; i < new_s->nr_blocks; i++)
                                m->blocks_nonempty += !!stripe_blockcount_get(new_s, i);
 
-                       spin_lock(&c->ec_stripes_heap_lock);
-                       bch2_stripes_heap_update(c, m, idx);
-                       spin_unlock(&c->ec_stripes_heap_lock);
+                       if (!old_s)
+                               bch2_stripes_heap_insert(c, m, idx);
+                       else
+                               bch2_stripes_heap_update(c, m, idx);
                }
        } else {
                struct gc_stripe *m =