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)
committerOleg Drokin <green@whamcloud.com>
Mon, 18 Mar 2013 04:59:30 +0000 (00:59 -0400)
commitfd25ec31647a35a2d7fc856af8d3da901524b23f
tree9f3e8c8f27c8ea78f554fe321f9939ce89d98f19
parent25170d2c786f3b7aebda83b50791abf9b42ba358
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