]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Update bcachefs sources to 71a5b27e017d bcachefs: Make backpointer fsck wb flush...
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 30 Nov 2023 07:20:42 +0000 (02:20 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 30 Nov 2023 07:20:51 +0000 (02:20 -0500)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
12 files changed:
.bcachefs_revision
Makefile
libbcachefs/backpointers.c
libbcachefs/btree_gc.c
libbcachefs/btree_iter.c
libbcachefs/btree_locking.c
libbcachefs/btree_types.h
libbcachefs/data_update.c
libbcachefs/mean_and_variance.c [moved from linux/mean_and_variance.c with 99% similarity]
libbcachefs/mean_and_variance.h [moved from include/linux/mean_and_variance.h with 100% similarity]
libbcachefs/util.c
libbcachefs/util.h

index 9acffb579a94845475f5304b416becc4a734e70e..b0f07a3d4ff618ca813c07de78436c16668dbf00 100644 (file)
@@ -1 +1 @@
-676dd269f0f8d59f730ba8e96474448576e4f677
+71a5b27e017df6ebae391da58857b22fdc406276
index 3bd84874e30067abead73b6e31251e65ea416e3b..738c9e208f9d1f6b63089d4aad95cce26a5faf66 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -218,10 +218,11 @@ update-bcachefs-sources:
        git add include/linux/kmemleak.h
        cp $(LINUX_DIR)/lib/math/int_sqrt.c linux/
        git add linux/int_sqrt.c
-       cp $(LINUX_DIR)/lib/math/mean_and_variance.c linux/
-       git add linux/mean_and_variance.c
-       cp $(LINUX_DIR)/include/linux/mean_and_variance.h include/linux/
-       git add include/linux/mean_and_variance.h
+       rm libbcachefs/mean_and_variance_test.c
+#      cp $(LINUX_DIR)/lib/math/mean_and_variance.c linux/
+#      git add linux/mean_and_variance.c
+#      cp $(LINUX_DIR)/include/linux/mean_and_variance.h include/linux/
+#      git add include/linux/mean_and_variance.h
        cp $(LINUX_DIR)/scripts/Makefile.compiler ./
        git add Makefile.compiler
        $(RM) libbcachefs/*.mod.c
index 2fb96fa99f42716fb7f681477400b37d3cb84b29..9b5f5809ba3798bd7ba2e3b5c0f072045ac14428 100644 (file)
@@ -3,6 +3,7 @@
 #include "bbpos.h"
 #include "alloc_background.h"
 #include "backpointers.h"
+#include "bkey_buf.h"
 #include "btree_cache.h"
 #include "btree_update.h"
 #include "btree_update_interior.h"
@@ -404,18 +405,13 @@ int bch2_check_btree_backpointers(struct bch_fs *c)
        return ret;
 }
 
-struct bpos_level {
-       unsigned        level;
-       struct bpos     pos;
-};
-
 static int check_bp_exists(struct btree_trans *trans,
                           struct bpos bucket,
                           struct bch_backpointer bp,
                           struct bkey_s_c orig_k,
                           struct bpos bucket_start,
                           struct bpos bucket_end,
-                          struct bpos_level *last_flushed)
+                          struct bkey_buf *last_flushed)
 {
        struct bch_fs *c = trans->c;
        struct btree_iter bp_iter = { NULL };
@@ -439,14 +435,19 @@ static int check_bp_exists(struct btree_trans *trans,
 
        if (bp_k.k->type != KEY_TYPE_backpointer ||
            memcmp(bkey_s_c_to_backpointer(bp_k).v, &bp, sizeof(bp))) {
-               if (last_flushed->level != bp.level ||
-                   !bpos_eq(last_flushed->pos, orig_k.k->p)) {
+               if (!bpos_eq(orig_k.k->p, last_flushed->k->k.p) ||
+                   bkey_bytes(orig_k.k) != bkey_bytes(&last_flushed->k->k) ||
+                   memcmp(orig_k.v, &last_flushed->k->v, bkey_val_bytes(orig_k.k))) {
+                       if (bp.level) {
+                               bch2_trans_unlock(trans);
+                               bch2_btree_interior_updates_flush(c);
+                       }
+
                        ret = bch2_btree_write_buffer_flush_sync(trans);
                        if (ret)
                                goto err;
 
-                       last_flushed->level = bp.level;
-                       last_flushed->pos = orig_k.k->p;
+                       bch2_bkey_buf_reassemble(last_flushed, c, orig_k);
                        ret = -BCH_ERR_transaction_restart_write_buffer_flush;
                        goto out;
                }
@@ -477,7 +478,7 @@ static int check_extent_to_backpointers(struct btree_trans *trans,
                                        enum btree_id btree, unsigned level,
                                        struct bpos bucket_start,
                                        struct bpos bucket_end,
-                                       struct bpos_level *last_flushed,
+                                       struct bkey_buf *last_flushed,
                                        struct bkey_s_c k)
 {
        struct bch_fs *c = trans->c;
@@ -511,7 +512,7 @@ static int check_btree_root_to_backpointers(struct btree_trans *trans,
                                            enum btree_id btree_id,
                                            struct bpos bucket_start,
                                            struct bpos bucket_end,
-                                           struct bpos_level *last_flushed,
+                                           struct bkey_buf *last_flushed,
                                            int *level)
 {
        struct bch_fs *c = trans->c;
@@ -616,10 +617,13 @@ static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans,
        struct btree_iter iter;
        enum btree_id btree_id;
        struct bkey_s_c k;
+       struct bkey_buf last_flushed;
        int ret = 0;
 
+       bch2_bkey_buf_init(&last_flushed);
+       bkey_init(&last_flushed.k->k);
+
        for (btree_id = 0; btree_id < btree_id_nr_alive(c); btree_id++) {
-               struct bpos_level last_flushed = { UINT_MAX, POS_MIN };
                int level, depth = btree_type_has_ptrs(btree_id) ? 0 : 1;
 
                ret = commit_do(trans, NULL, NULL,
@@ -664,6 +668,7 @@ static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans,
                }
        }
 
+       bch2_bkey_buf_exit(&last_flushed, c);
        return 0;
 }
 
index d1615607480d33d49ad74e46e126f74fe203119f..5a7b72a461dfde8cf05202f79124a746b15d809a 100644 (file)
@@ -1087,9 +1087,6 @@ static int bch2_gc_btrees(struct bch_fs *c, bool initial, bool metadata_only)
        unsigned i;
        int ret = 0;
 
-       if (initial)
-               trans->is_initial_gc = true;
-
        for (i = 0; i < BTREE_ID_NR; i++)
                ids[i] = i;
        bubble_sort(ids, BTREE_ID_NR, btree_id_gc_phase_cmp);
index f430ca83720673043b135128aa75b272a73dfaff..4d673d470724ef8b38484c468cfac54cd559d13e 100644 (file)
@@ -2870,8 +2870,6 @@ struct btree_trans *__bch2_trans_get(struct bch_fs *c, unsigned fn_idx)
        struct btree_trans *trans;
        struct btree_transaction_stats *s;
 
-       bch2_assert_btree_nodes_not_locked();
-
        trans = bch2_trans_alloc(c);
 
        memset(trans, 0, sizeof(*trans));
index 89f14b5a5eddaf6f47b1f7e08eb3860b96cff392..1eca320e7574ef251c2f62a5463fb93da7530f7c 100644 (file)
@@ -10,15 +10,16 @@ void bch2_btree_lock_init(struct btree_bkey_cached_common *b,
                          enum six_lock_init_flags flags)
 {
        __six_lock_init(&b->lock, "b->c.lock", &bch2_btree_node_lock_key, flags);
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
-       lockdep_set_no_check_recursion(&b->lock.dep_map);
-#endif
+       lockdep_set_novalidate_class(&b->lock);
 }
 
 #ifdef CONFIG_LOCKDEP
 void bch2_assert_btree_nodes_not_locked(void)
 {
+#if 0
+       //Re-enable when lock_class_is_held() is merged:
        BUG_ON(lock_class_is_held(&bch2_btree_node_lock_key));
+#endif
 }
 #endif
 
@@ -769,13 +770,6 @@ void bch2_trans_unlock(struct btree_trans *trans)
 
        trans_for_each_path(trans, path)
                __bch2_btree_path_unlock(trans, path);
-
-       /*
-        * bch2_gc_btree_init_recurse() doesn't use btree iterators for walking
-        * btree nodes, it implements its own walking:
-        */
-       if (!trans->is_initial_gc)
-               bch2_assert_btree_nodes_not_locked();
 }
 
 void bch2_trans_unlock_long(struct btree_trans *trans)
index 2326bceb34f8a81fccc69a5af799317bd0bdf052..ca7526603d0693fd02a7fa18682354bb67e09221 100644 (file)
@@ -399,7 +399,6 @@ struct btree_trans {
        bool                    memory_allocation_failure:1;
        bool                    journal_transaction_names:1;
        bool                    journal_replay_not_finished:1;
-       bool                    is_initial_gc:1;
        bool                    notrace_relock_fail:1;
        bool                    write_locked:1;
        enum bch_errcode        restarted:16;
index 08c664cabf094e423a44c455464797ffca830158..0d58a8727a7b25f6c3ecbb194f14e6612be096dd 100644 (file)
@@ -314,7 +314,7 @@ next:
                }
                continue;
 nowork:
-               if (m->stats && m->stats) {
+               if (m->stats) {
                        BUG_ON(k.k->p.offset <= iter.pos.offset);
                        atomic64_inc(&m->stats->keys_raced);
                        atomic64_add(k.k->p.offset - iter.pos.offset,
similarity index 99%
rename from linux/mean_and_variance.c
rename to libbcachefs/mean_and_variance.c
index eb5f2ba03b7fbdd920b0080600989a0dc76f8e61..1f0801e2e565c5bf7d705649acb4f8e92267155d 100644 (file)
 #include <linux/limits.h>
 #include <linux/math.h>
 #include <linux/math64.h>
-#include <linux/mean_and_variance.h>
 #include <linux/module.h>
 
+#include "mean_and_variance.h"
+
 u128_u u128_div(u128_u n, u64 d)
 {
        u128_u r;
index c3303b02e5de42629f0baab36d81d63bfc5a4a68..e85b1f4672952b2839e073c4516ffd6472f3b877 100644 (file)
@@ -22,9 +22,9 @@
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/sched/clock.h>
-#include <linux/mean_and_variance.h>
 
 #include "eytzinger.h"
+#include "mean_and_variance.h"
 #include "util.h"
 
 static const char si_units[] = "?kMGTPEZY";
index 54e309d94b9bebeb43c0503b145b6ad38b0771c5..b93d5f481c7eee48b3418dfa83ab9f0ab7b53cf0 100644 (file)
@@ -17,7 +17,8 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/workqueue.h>
-#include <linux/mean_and_variance.h>
+
+#include "mean_and_variance.h"
 
 #include "darray.h"