Commit 67c56411 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix loop restart in bch2_btree_transactions_read()

Accidental infinite loop; also fix btree_deadlock_to_text()
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 1539bdf5
...@@ -610,7 +610,7 @@ static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf, ...@@ -610,7 +610,7 @@ static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf,
list_sort(&c->btree_trans_list, list_ptr_order_cmp); list_sort(&c->btree_trans_list, list_ptr_order_cmp);
list_for_each_entry(trans, &c->btree_trans_list, list) { list_for_each_entry(trans, &c->btree_trans_list, list) {
if ((ulong) trans < i->iter) if ((ulong) trans <= i->iter)
continue; continue;
i->iter = (ulong) trans; i->iter = (ulong) trans;
...@@ -832,16 +832,16 @@ static const struct file_operations btree_transaction_stats_op = { ...@@ -832,16 +832,16 @@ static const struct file_operations btree_transaction_stats_op = {
static void btree_deadlock_to_text(struct printbuf *out, struct bch_fs *c) static void btree_deadlock_to_text(struct printbuf *out, struct bch_fs *c)
{ {
struct btree_trans *trans; struct btree_trans *trans;
pid_t iter = 0; ulong iter = 0;
restart: restart:
seqmutex_lock(&c->btree_trans_lock); seqmutex_lock(&c->btree_trans_lock);
list_for_each_entry(trans, &c->btree_trans_list, list) { list_sort(&c->btree_trans_list, list_ptr_order_cmp);
struct task_struct *task = READ_ONCE(trans->locking_wait.task);
if (!task || task->pid <= iter) list_for_each_entry(trans, &c->btree_trans_list, list) {
if ((ulong) trans <= iter)
continue; continue;
iter = task->pid; iter = (ulong) trans;
if (!closure_get_not_zero(&trans->ref)) if (!closure_get_not_zero(&trans->ref))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment