summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/debug.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-09-12 23:16:02 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 23:10:13 +0200
commit6bd68ec266ad71827ef940151067b67b62fb8fed (patch)
tree158da84712ff58061a2bfbbe6f0e858b58c6140d /fs/bcachefs/debug.c
parentbcachefs: Fix W=12 build errors (diff)
downloadlinux-6bd68ec266ad71827ef940151067b67b62fb8fed.tar.xz
linux-6bd68ec266ad71827ef940151067b67b62fb8fed.zip
bcachefs: Heap allocate btree_trans
We're using more stack than we'd like in a number of functions, and btree_trans is the biggest object that we stack allocate. But we have to do a heap allocatation to initialize it anyways, so there's no real downside to heap allocating the entire thing. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/debug.c')
-rw-r--r--fs/bcachefs/debug.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c
index 7593ba04dfb2..404148bd348a 100644
--- a/fs/bcachefs/debug.c
+++ b/fs/bcachefs/debug.c
@@ -366,7 +366,7 @@ static ssize_t bch2_read_btree(struct file *file, char __user *buf,
size_t size, loff_t *ppos)
{
struct dump_iter *i = file->private_data;
- struct btree_trans trans;
+ struct btree_trans *trans;
struct btree_iter iter;
struct bkey_s_c k;
ssize_t ret;
@@ -379,17 +379,17 @@ static ssize_t bch2_read_btree(struct file *file, char __user *buf,
if (ret)
return ret;
- bch2_trans_init(&trans, i->c, 0, 0);
- ret = for_each_btree_key2(&trans, iter, i->id, i->from,
+ trans = bch2_trans_get(i->c);
+ ret = for_each_btree_key2(trans, iter, i->id, i->from,
BTREE_ITER_PREFETCH|
BTREE_ITER_ALL_SNAPSHOTS, k, ({
bch2_bkey_val_to_text(&i->buf, i->c, k);
prt_newline(&i->buf);
- drop_locks_do(&trans, flush_buf(i));
+ drop_locks_do(trans, flush_buf(i));
}));
i->from = iter.pos;
- bch2_trans_exit(&trans);
+ bch2_trans_put(trans);
if (!ret)
ret = flush_buf(i);
@@ -408,7 +408,7 @@ static ssize_t bch2_read_btree_formats(struct file *file, char __user *buf,
size_t size, loff_t *ppos)
{
struct dump_iter *i = file->private_data;
- struct btree_trans trans;
+ struct btree_trans *trans;
struct btree_iter iter;
struct btree *b;
ssize_t ret;
@@ -424,26 +424,26 @@ static ssize_t bch2_read_btree_formats(struct file *file, char __user *buf,
if (bpos_eq(SPOS_MAX, i->from))
return i->ret;
- bch2_trans_init(&trans, i->c, 0, 0);
+ trans = bch2_trans_get(i->c);
retry:
- bch2_trans_begin(&trans);
+ bch2_trans_begin(trans);
- for_each_btree_node(&trans, iter, i->id, i->from, 0, b, ret) {
+ for_each_btree_node(trans, iter, i->id, i->from, 0, b, ret) {
bch2_btree_node_to_text(&i->buf, i->c, b);
i->from = !bpos_eq(SPOS_MAX, b->key.k.p)
? bpos_successor(b->key.k.p)
: b->key.k.p;
- ret = drop_locks_do(&trans, flush_buf(i));
+ ret = drop_locks_do(trans, flush_buf(i));
if (ret)
break;
}
- bch2_trans_iter_exit(&trans, &iter);
+ bch2_trans_iter_exit(trans, &iter);
if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
goto retry;
- bch2_trans_exit(&trans);
+ bch2_trans_put(trans);
if (!ret)
ret = flush_buf(i);
@@ -462,7 +462,7 @@ static ssize_t bch2_read_bfloat_failed(struct file *file, char __user *buf,
size_t size, loff_t *ppos)
{
struct dump_iter *i = file->private_data;
- struct btree_trans trans;
+ struct btree_trans *trans;
struct btree_iter iter;
struct bkey_s_c k;
ssize_t ret;
@@ -475,9 +475,9 @@ static ssize_t bch2_read_bfloat_failed(struct file *file, char __user *buf,
if (ret)
return ret;
- bch2_trans_init(&trans, i->c, 0, 0);
+ trans = bch2_trans_get(i->c);
- ret = for_each_btree_key2(&trans, iter, i->id, i->from,
+ ret = for_each_btree_key2(trans, iter, i->id, i->from,
BTREE_ITER_PREFETCH|
BTREE_ITER_ALL_SNAPSHOTS, k, ({
struct btree_path_level *l = &iter.path->l[0];
@@ -490,11 +490,11 @@ static ssize_t bch2_read_bfloat_failed(struct file *file, char __user *buf,
}
bch2_bfloat_to_text(&i->buf, l->b, _k);
- drop_locks_do(&trans, flush_buf(i));
+ drop_locks_do(trans, flush_buf(i));
}));
i->from = iter.pos;
- bch2_trans_exit(&trans);
+ bch2_trans_put(trans);
if (!ret)
ret = flush_buf(i);