]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Update bcachefs sources to 6dc2a699c6 bcachefs: bch2_path_put_nokeep()
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 11 Oct 2022 10:40:24 +0000 (06:40 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 11 Oct 2022 10:40:30 +0000 (06:40 -0400)
.bcachefs_revision
libbcachefs/backpointers.c
libbcachefs/btree_iter.c
libbcachefs/btree_update_leaf.c
libbcachefs/buckets.c
linux/shrinker.c

index 794a301427e6c338cc6f7c66e352362369229b83..9c88209fce4b45a3eab9ccf1441236e7fc2f841f 100644 (file)
@@ -1 +1 @@
-55f0b5944bb7f02baa6b7b854fd4d294d974bfb6
+6dc2a699c6d2e04027bdc670141e6f313c751ff0
index c9abb5eed5f7b9cfbb1299c8ed68e2e8b3f9de4e..9e0430a73feeb0dcf9ae050961acee9045523962 100644 (file)
@@ -816,9 +816,11 @@ static inline struct bbpos bp_to_bbpos(struct bch_backpointer bp)
 static size_t btree_nodes_fit_in_ram(struct bch_fs *c)
 {
        struct sysinfo i;
+       u64 mem_bytes;
 
        si_meminfo(&i);
-       return (i.totalram >> 1) / btree_bytes(c);
+       mem_bytes = i.totalram * i.mem_unit;
+       return (mem_bytes >> 1) / btree_bytes(c);
 }
 
 int bch2_get_btree_in_memory_pos(struct btree_trans *trans,
@@ -1005,7 +1007,7 @@ int bch2_check_backpointers_to_extents(struct bch_fs *c)
                    bbpos_cmp(end, BBPOS_MAX)) {
                        struct printbuf buf = PRINTBUF;
 
-                       prt_str(&buf, "check_backointers_to_extents(): ");
+                       prt_str(&buf, "check_backpointers_to_extents(): ");
                        bch2_bbpos_to_text(&buf, start);
                        prt_str(&buf, "-");
                        bch2_bbpos_to_text(&buf, end);
index dffb0170850dc06b893eef103ed45b67fca69cd8..cd903fdc426c8baac3a8e94bb7d8a6c63135fd5c 100644 (file)
@@ -1320,6 +1320,20 @@ void bch2_path_put(struct btree_trans *trans, struct btree_path *path, bool inte
        __bch2_path_free(trans, path);
 }
 
+static void bch2_path_put_nokeep(struct btree_trans *trans, struct btree_path *path,
+                                bool intent)
+{
+       struct btree_path *dup;
+
+       EBUG_ON(trans->paths + path->idx != path);
+       EBUG_ON(!path->ref);
+
+       if (!__btree_path_put(path, intent))
+               return;
+
+       __bch2_path_free(trans, path);
+}
+
 void bch2_trans_updates_to_text(struct printbuf *buf, struct btree_trans *trans)
 {
        struct btree_insert_entry *i;
@@ -1952,8 +1966,8 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
        EBUG_ON(iter->flags & BTREE_ITER_ALL_LEVELS);
 
        if (iter->update_path) {
-               bch2_path_put(trans, iter->update_path,
-                             iter->flags & BTREE_ITER_INTENT);
+               bch2_path_put_nokeep(trans, iter->update_path,
+                                    iter->flags & BTREE_ITER_INTENT);
                iter->update_path = NULL;
        }
 
@@ -1984,8 +1998,8 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
 
                if (iter->update_path &&
                    bkey_cmp(iter->update_path->pos, k.k->p)) {
-                       bch2_path_put(trans, iter->update_path,
-                                     iter->flags & BTREE_ITER_INTENT);
+                       bch2_path_put_nokeep(trans, iter->update_path,
+                                            iter->flags & BTREE_ITER_INTENT);
                        iter->update_path = NULL;
                }
 
@@ -2233,7 +2247,7 @@ struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *iter)
                                 * that candidate
                                 */
                                if (saved_path && bkey_cmp(k.k->p, saved_k.p)) {
-                                       bch2_path_put(trans, iter->path,
+                                       bch2_path_put_nokeep(trans, iter->path,
                                                      iter->flags & BTREE_ITER_INTENT);
                                        iter->path = saved_path;
                                        saved_path = NULL;
@@ -2246,7 +2260,7 @@ struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *iter)
                                                              iter->snapshot,
                                                              k.k->p.snapshot)) {
                                        if (saved_path)
-                                               bch2_path_put(trans, saved_path,
+                                               bch2_path_put_nokeep(trans, saved_path,
                                                      iter->flags & BTREE_ITER_INTENT);
                                        saved_path = btree_path_clone(trans, iter->path,
                                                                iter->flags & BTREE_ITER_INTENT);
@@ -2290,7 +2304,7 @@ got_key:
        btree_path_set_should_be_locked(iter->path);
 out_no_locked:
        if (saved_path)
-               bch2_path_put(trans, saved_path, iter->flags & BTREE_ITER_INTENT);
+               bch2_path_put_nokeep(trans, saved_path, iter->flags & BTREE_ITER_INTENT);
 
        bch2_btree_iter_verify_entry_exit(iter);
        bch2_btree_iter_verify(iter);
@@ -2578,7 +2592,7 @@ void bch2_trans_iter_exit(struct btree_trans *trans, struct btree_iter *iter)
                bch2_path_put(trans, iter->path,
                              iter->flags & BTREE_ITER_INTENT);
        if (iter->update_path)
-               bch2_path_put(trans, iter->update_path,
+               bch2_path_put_nokeep(trans, iter->update_path,
                              iter->flags & BTREE_ITER_INTENT);
        if (iter->key_cache_path)
                bch2_path_put(trans, iter->key_cache_path,
index af3fbfcc5fac38ed90355dfbaee2289450f8ecd4..b166ab4b4a3b53fdfbc99b3a5a34ad940e73a5e2 100644 (file)
@@ -1623,7 +1623,7 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id,
        int ret = 0;
 
        bch2_trans_iter_init(trans, &iter, id, start, BTREE_ITER_INTENT);
-       while ((k = bch2_btree_iter_peek_upto(&iter, bpos_predecessor(end))).k) {
+       while ((k = bch2_btree_iter_peek(&iter)).k) {
                struct disk_reservation disk_res =
                        bch2_disk_reservation_init(trans->c, 0);
                struct bkey_i delete;
@@ -1632,6 +1632,9 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id,
                if (ret)
                        goto err;
 
+               if (bkey_cmp(iter.pos, end) >= 0)
+                       break;
+
                bkey_init(&delete.k);
 
                /*
index de57e6253ea5285dfb69c9dfe364d1ae24a68aa8..c611931f88be39cb96e4f76e9024b14f9d9530bb 100644 (file)
@@ -575,7 +575,7 @@ int bch2_mark_alloc(struct btree_trans *trans,
        if ((flags & BTREE_TRIGGER_BUCKET_INVALIDATE) &&
            old_a.cached_sectors) {
                ret = update_cached_sectors(c, new, ca->dev_idx,
-                                           -old_a.cached_sectors,
+                                           -((s64) old_a.cached_sectors),
                                            journal_seq, gc);
                if (ret) {
                        bch2_fs_fatal_error(c, "bch2_mark_alloc(): no replicas entry while updating cached sectors");
index 0f73620bc6e71f8262e0c92c2e434cf927fff276..23e288d845cb67da8030672e58038cbe5b49d2df 100644 (file)
@@ -48,6 +48,7 @@ void si_meminfo(struct sysinfo *val)
        FILE *f;
 
        memset(val, 0, sizeof(*val));
+       val->mem_unit = 1;
 
        f = fopen("/proc/meminfo", "r");
        if (!f)