]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: trans_get_key() now works correctly for extents
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 7 Aug 2019 16:07:13 +0000 (12:07 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:24 +0000 (17:08 -0400)
More prep work for reflink: for extents, we're not looking for an exact
mach on pos, rather that the pos is within the range of the key the
iterator points to.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/buckets.c

index b1914fba1f7f76471e21a004d53efdc36d1576db..4e7c58c518d349639b1671885e1e9e1fb32660fe 100644 (file)
@@ -1342,15 +1342,20 @@ static int trans_get_key(struct btree_trans *trans,
                         struct btree_iter **iter,
                         struct bkey_s_c *k)
 {
-       unsigned i;
+       struct btree_insert_entry *i;
        int ret;
 
-       for (i = 0; i < trans->nr_updates; i++)
-               if (!trans->updates[i].deferred &&
-                   trans->updates[i].iter->btree_id == btree_id &&
-                   !bkey_cmp(pos, trans->updates[i].iter->pos)) {
-                       *iter   = trans->updates[i].iter;
-                       *k      = bkey_i_to_s_c(trans->updates[i].k);
+       for (i = trans->updates;
+            i < trans->updates + trans->nr_updates;
+            i++)
+               if (!i->deferred &&
+                   i->iter->btree_id == btree_id &&
+                   (btree_node_type_is_extents(btree_id)
+                    ? bkey_cmp(pos, bkey_start_pos(&i->k->k)) >= 0 &&
+                      bkey_cmp(pos, i->k->k.p) < 0
+                    : !bkey_cmp(pos, i->iter->pos))) {
+                       *iter   = i->iter;
+                       *k      = bkey_i_to_s_c(i->k);
                        return 0;
                }