summaryrefslogtreecommitdiff
path: root/fs/bcachefs/io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-10-09 12:50:39 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:29 -0400
commit9a3df993e15e0d44974d6ac7c5749c7028aa9e3c (patch)
tree40cf826c4c05f8b89e7c052db210d5289546b4ee /fs/bcachefs/io.c
parent2e87eae1fb7a61e72d98af9c0ef8cbaad1a6d497 (diff)
downloadlwn-9a3df993e15e0d44974d6ac7c5749c7028aa9e3c.tar.gz
lwn-9a3df993e15e0d44974d6ac7c5749c7028aa9e3c.zip
bcachefs: Kill bchfs_extent_update()
The generic IO path now handles inode updates for i_size and i_sectors - this means we can drop a fair amount of code from fs-io.c. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/io.c')
-rw-r--r--fs/bcachefs/io.c93
1 files changed, 41 insertions, 52 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index c60e52fbf4fe..d6d777bb53da 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -390,6 +390,47 @@ int bch2_fpunch(struct bch_fs *c, u64 inum, u64 start, u64 end,
return ret;
}
+int bch2_write_index_default(struct bch_write_op *op)
+{
+ struct bch_fs *c = op->c;
+ struct keylist *keys = &op->insert_keys;
+ struct bkey_i *k = bch2_keylist_front(keys);
+ struct btree_trans trans;
+ struct btree_iter *iter;
+ int ret;
+
+ bch2_trans_init(&trans, c, BTREE_ITER_MAX, 1024);
+
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ bkey_start_pos(&k->k),
+ BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
+
+ do {
+ BKEY_PADDED(k) tmp;
+
+ bkey_copy(&tmp.k, bch2_keylist_front(keys));
+
+ bch2_trans_begin_updates(&trans);
+
+ ret = bch2_extent_update(&trans, iter, &tmp.k,
+ &op->res, op_journal_seq(op),
+ op->new_i_size, &op->i_sectors_delta);
+ if (ret == -EINTR)
+ continue;
+ if (ret)
+ break;
+
+ if (bkey_cmp(iter->pos, bch2_keylist_front(keys)->k.p) < 0)
+ bch2_cut_front(iter->pos, bch2_keylist_front(keys));
+ else
+ bch2_keylist_pop_front(keys);
+ } while (!bch2_keylist_empty(keys));
+
+ bch2_trans_exit(&trans);
+
+ return ret;
+}
+
/* Writes */
void bch2_submit_wbio_replicas(struct bch_write_bio *wbio, struct bch_fs *c,
@@ -474,58 +515,6 @@ static void bch2_write_done(struct closure *cl)
closure_return(cl);
}
-int bch2_write_index_default(struct bch_write_op *op)
-{
- struct bch_fs *c = op->c;
- struct btree_trans trans;
- struct btree_iter *iter;
- struct keylist *keys = &op->insert_keys;
- int ret;
-
- BUG_ON(bch2_keylist_empty(keys));
- bch2_verify_keylist_sorted(keys);
-
- bch2_trans_init(&trans, c, BTREE_ITER_MAX, 256);
-retry:
- bch2_trans_begin(&trans);
-
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
- bkey_start_pos(&bch2_keylist_front(keys)->k),
- BTREE_ITER_INTENT);
-
- do {
- BKEY_PADDED(k) split;
-
- bkey_copy(&split.k, bch2_keylist_front(keys));
-
- ret = bch2_extent_trim_atomic(&split.k, iter);
- if (ret)
- break;
-
- bch2_trans_update(&trans, iter, &split.k);
-
- ret = bch2_trans_commit(&trans, &op->res, op_journal_seq(op),
- BTREE_INSERT_NOFAIL|
- BTREE_INSERT_USE_RESERVE);
- if (ret)
- break;
-
- if (bkey_cmp(iter->pos, bch2_keylist_front(keys)->k.p) < 0)
- bch2_cut_front(iter->pos, bch2_keylist_front(keys));
- else
- bch2_keylist_pop_front(keys);
- } while (!bch2_keylist_empty(keys));
-
- if (ret == -EINTR) {
- ret = 0;
- goto retry;
- }
-
- bch2_trans_exit(&trans);
-
- return ret;
-}
-
/**
* bch_write_index - after a write, update index to point to new data
*/