Skip to content

Commit

Permalink
Btrfs: try not to sleep as much when doing slow caching
Browse files Browse the repository at this point in the history
When the fs is super full and we unmount the fs, we could get stuck in this
thing where unmount is waiting for the caching kthread to make progress and the
caching kthread keeps scheduling because we're in the middle of a commit.  So
instead just let the caching kthread keep going and only yeild if
need_resched().  This makes my horrible umount case go from taking up to 10
minutes to taking less than 20 seconds.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
  • Loading branch information
Josef Bacik committed May 23, 2011
1 parent d82a6f1 commit 589d8ad
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,18 @@ static int caching_kthread(void *data)
if (ret)
break;

caching_ctl->progress = last;
btrfs_release_path(extent_root, path);
up_read(&fs_info->extent_commit_sem);
mutex_unlock(&caching_ctl->mutex);
if (btrfs_transaction_in_commit(fs_info))
schedule_timeout(1);
else
if (need_resched() ||
btrfs_next_leaf(extent_root, path)) {
caching_ctl->progress = last;
btrfs_release_path(extent_root, path);
up_read(&fs_info->extent_commit_sem);
mutex_unlock(&caching_ctl->mutex);
cond_resched();
goto again;
goto again;
}
leaf = path->nodes[0];
nritems = btrfs_header_nritems(leaf);
continue;
}

if (key.objectid < block_group->key.objectid) {
Expand Down

0 comments on commit 589d8ad

Please sign in to comment.