]> git.hungrycats.org Git - linux/commit
zygo: btrfs: don't let btrfs_recover_relocation get stuck waiting for cleaner_kthread...
authorZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sun, 1 May 2016 04:03:14 +0000 (00:03 -0400)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sun, 1 May 2016 04:03:14 +0000 (00:03 -0400)
commitf973d661d2c89be39452df49a7ee3a4e3074d8f4
treee522474d61db9248567e8d2396605288d9399027
parent2f38289c055ae9e9f846f32fdc1b17d451035e38
zygo: btrfs: don't let btrfs_recover_relocation get stuck waiting for cleaner_kthread to delete a snapshot

mounting a filesystem with large deleted snapshots gets stuck at
open_ctree + 0x212b, which is the mutex_lock here:

mutex_lock(&fs_info->cleaner_mutex);
ret = btrfs_recover_relocation(tree_root);
mutex_unlock(&fs_info->cleaner_mutex);

The cleaner_kthread is holding cleaner_mutex for the entire time
it deletes one snapshot, which blocks the mount from proceeding
to completion.

It also seems insane to run cleaner_kthread *before* we've recovered
relocation, but I don't know precisely what btrfs_recover_relocation
does.

I also don't know if there are ordering dependencies between
cleaner_kthread and transaction_kthread; however, I do know that
one can wait indefinitely for the other.  I keep the same startup
order but make sure that btrfs_recover_relocation wins the race
for cleaner_mutex by cheating.
fs/btrfs/disk-io.c