Whamcloud - gitweb
LU-588 ldiskfs: Don't release super block buffer_head too early
authorJeremy Filizetti <jeremy.filizetti@gmail.com>
Mon, 30 Jul 2012 16:10:45 +0000 (12:10 -0400)
committerJohann Lombardi <johann.lombardi@intel.com>
Mon, 19 Nov 2012 07:38:20 +0000 (02:38 -0500)
commit1a10bc171cbd6edcfe017b6c98254c36c4a8d8e7
treef903c3eb8d97f24c5abe4924b9c4916da547904d
parent42fa8665c21c01a07c40aa0886b4c6bf6193327f
LU-588 ldiskfs: Don't release super block buffer_head too early

If the super block buffer_head is released prior to MMP stopping
kmmpd can get a zeroed buffer_head and exit. The following code
causes kmmpd to exit when the s_feature_incompat is zero:

if (!(le32_to_cpu(es->s_feature_incompat) &
LDISKFS_FEATURE_INCOMPAT_MMP)) {
ldiskfs_warning(sb, "kmmpd being stopped since MMP feature"
                             " has been disabled.");
LDISKFS_SB(sb)->s_mmp_tsk = NULL;
goto failed;
}

A deadlock can occur with the kthread_stop_lock mutex because
ldiskfs_put_super calls kthread_stop on an already stopped thread
(kmmpd) so it waits for completion of the thread stopping before
releasing the kthread_stop_lock.

This is the result of a race with the kmmpd thread setting s_mmp_tsk
to NULL and ldiskfs_put_super in another thread to checks s_mmp_tsk
for NULL prior to calling kthread_stop.

Signed-off-by: Jeremy Filizetti <jeremy.filizetti@gmail.com>
Change-Id: Ia15d8ff829705a5d51dea4f86e40ba7c5745a9c5
Reviewed-on: http://review.whamcloud.com/3172
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Yu Jian <yujian@whamcloud.com>
ldiskfs/kernel_patches/patches/ext4-mmp-rhel5.patch