]> git.hungrycats.org Git - linux/commit
btrfs: avoid blocking open_ctree from cleaner_kthread
authorZygo Blaxell <zblaxell@serenity.furryterror.org>
Fri, 10 Jun 2016 03:28:04 +0000 (23:28 -0400)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Mon, 13 Jun 2016 03:42:32 +0000 (23:42 -0400)
commitb9a07928f2e8fc04620fd842c69d4432d357b323
tree370df3c9afa91eb65300a6ef23fca162ab1d835c
parent45e87011c06e84e1f880dc7f64e7bbe53633738a
btrfs: avoid blocking open_ctree from cleaner_kthread

This fixes a problem introduced in commit 2f3165ecf103599f82bf0ea254039db335fb5005
"btrfs: don't force mounts to wait for cleaner_kthread to delete one or more subvolumes".

open_ctree eventually calls btrfs_replay_log which in turn calls
btrfs_commit_super which tries to lock the cleaner_mutex, causing a
recursive mutex deadlock during mount.

Instead of playing whack-a-mole trying to keep up with all the
functions that may want to lock cleaner_mutex, put all the cleaner_mutex
lockers back where they were, attack the problem more directly:  keep
cleaner_kthread asleep until the filesystem is mounted.

When filesystems are mounted read-only and later remounted read-write,
open_ctree did not set fs_info->open and neither does anything else.
Set this flag in btrfs_remount so that neither btrfs_delete_unused_bgs
nor cleaner_kthread get confused by the common case of "/" filesystem
read-only mount followed by read-write remount.

Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
(cherry picked from commit 453ed53669ab6bbe936073946b81018b49c59793)
fs/btrfs/disk-io.c
fs/btrfs/super.c