summaryrefslogtreecommitdiff
path: root/fs/bcachefs/fs-io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-08-05 17:46:41 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:09 -0400
commite2d9912c6f25301923783e7e785870f821d31c40 (patch)
treeac38181623d4dd6763103e6cff5f2cbd0fe538b7 /fs/bcachefs/fs-io.c
parent581edb634140fe3da0bc3c8430116e735ebff897 (diff)
downloadlwn-e2d9912c6f25301923783e7e785870f821d31c40.tar.gz
lwn-e2d9912c6f25301923783e7e785870f821d31c40.zip
bcachefs: bch2_extent_trim_atomic()
Prep work for extents insert hook removal Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs-io.c')
-rw-r--r--fs/bcachefs/fs-io.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index cc99eb1b36e0..da8c1917c760 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -6,6 +6,7 @@
#include "buckets.h"
#include "clock.h"
#include "error.h"
+#include "extents.h"
#include "fs.h"
#include "fs-io.h"
#include "fsck.h"
@@ -430,17 +431,22 @@ static int bchfs_write_index_update(struct bch_write_op *wop)
hook.need_inode_update = false;
do {
- /* XXX: inode->i_size locking */
- k = bch2_keylist_front(keys);
- if (min(k->k.p.offset << 9, op->new_i_size) >
- op->inode->ei_inode.bi_size)
- hook.need_inode_update = true;
+ BKEY_PADDED(k) tmp;
- /* optimization for fewer transaction restarts: */
ret = bch2_btree_iter_traverse(extent_iter);
if (ret)
goto err;
+ bkey_copy(&tmp.k, bch2_keylist_front(keys));
+ k = &tmp.k;
+
+ bch2_extent_trim_atomic(k, extent_iter);
+
+ /* XXX: inode->i_size locking */
+ if (min(k->k.p.offset << 9, op->new_i_size) >
+ op->inode->ei_inode.bi_size)
+ hook.need_inode_update = true;
+
if (hook.need_inode_update) {
struct bkey_s_c inode;
@@ -515,8 +521,10 @@ err:
if (hook.need_inode_update)
op->inode->ei_inode = hook.inode_u;
- BUG_ON(bkey_cmp(extent_iter->pos, k->k.p) < 0);
- bch2_keylist_pop_front(keys);
+ if (bkey_cmp(extent_iter->pos, bch2_keylist_front(keys)->k.p) < 0)
+ bch2_cut_front(extent_iter->pos, bch2_keylist_front(keys));
+ else
+ bch2_keylist_pop_front(keys);
} while (!bch2_keylist_empty(keys));
bch2_trans_exit(&trans);
@@ -2458,6 +2466,12 @@ static long bch2_fcollapse(struct bch_inode_info *inode,
bch2_cut_front(src->pos, &copy.k);
copy.k.k.p.offset -= len >> 9;
+ ret = bch2_btree_iter_traverse(dst);
+ if (ret)
+ goto btree_iter_err;
+
+ bch2_extent_trim_atomic(&copy.k, dst);
+
BUG_ON(bkey_cmp(dst->pos, bkey_start_pos(&copy.k.k)));
ret = bch2_disk_reservation_get(c, &disk_res, copy.k.k.size,