summaryrefslogtreecommitdiff
path: root/fs/bcachefs/io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-11-09 19:02:48 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:32 -0400
commit085ab69357e091613625f1505d667b6a5a3ec881 (patch)
treedf5f4d2d258b9bade329e662464a6a3139a7f384 /fs/bcachefs/io.c
parentad44bdc351faeacb9b7294f1689ac76babf379ad (diff)
downloadlwn-085ab69357e091613625f1505d667b6a5a3ec881.tar.gz
lwn-085ab69357e091613625f1505d667b6a5a3ec881.zip
bcachefs: Rework of cut_front & cut_back
This changes bch2_cut_front and bch2_cut_back so that they're able to shorten the size of the value, and it also changes the extent update path to update the accounting in the btree node when this happens. When the size of the value is shortened, they zero out the space that's no longer used, so it's interpreted as noops (as implemented in the last patch). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/io.c')
-rw-r--r--fs/bcachefs/io.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index 4fe61705ae75..0f1be5c5543d 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -345,7 +345,7 @@ int bch2_fpunch_at(struct btree_trans *trans, struct btree_iter *iter,
/* create the biggest key we can */
bch2_key_resize(&delete.k, max_sectors);
- bch2_cut_back(end, &delete.k);
+ bch2_cut_back(end, &delete);
bch2_trans_begin_updates(trans);
@@ -414,6 +414,7 @@ int bch2_write_index_default(struct bch_write_op *op)
bkey_on_stack_realloc(&sk, c, k->k.u64s);
bkey_copy(sk.k, k);
+ bch2_cut_front(iter->pos, sk.k);
bch2_trans_begin_updates(&trans);
@@ -425,9 +426,7 @@ int bch2_write_index_default(struct bch_write_op *op)
if (ret)
break;
- if (bkey_cmp(iter->pos, k->k.p) < 0)
- bch2_cut_front(iter->pos, k);
- else
+ if (bkey_cmp(iter->pos, k->k.p) >= 0)
bch2_keylist_pop_front(keys);
} while (!bch2_keylist_empty(keys));