Skip to content

Commit ed3b3d3

Browse files
committed
Btrfs: don't walk around with task->state != TASK_RUNNING
Yan Zheng noticed two places we were doing a lot of work without task->state set to TASK_RUNNING. This sets the state properly after we get ready to sleep but decide not to. Signed-off-by: Chris Mason <chris.mason@oracle.com>
1 parent 11c65dc commit ed3b3d3

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎fs/btrfs/async-thread.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ static int worker_loop(void *arg)
377377
if (!list_empty(&worker->pending) ||
378378
!list_empty(&worker->prio_pending)) {
379379
spin_unlock_irq(&worker->lock);
380+
set_current_state(TASK_RUNNING);
380381
goto again;
381382
}
382383

‎fs/btrfs/transaction.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
10631063
snap_pending = 1;
10641064

10651065
WARN_ON(cur_trans != trans->transaction);
1066-
prepare_to_wait(&cur_trans->writer_wait, &wait,
1067-
TASK_UNINTERRUPTIBLE);
1068-
10691066
if (cur_trans->num_writers > 1)
10701067
timeout = MAX_SCHEDULE_TIMEOUT;
10711068
else if (should_grow)
@@ -1088,6 +1085,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
10881085
*/
10891086
btrfs_run_ordered_operations(root, 1);
10901087

1088+
prepare_to_wait(&cur_trans->writer_wait, &wait,
1089+
TASK_UNINTERRUPTIBLE);
1090+
10911091
smp_mb();
10921092
if (cur_trans->num_writers > 1 || should_grow)
10931093
schedule_timeout(timeout);

0 commit comments

Comments
 (0)