• H
    xfs: check kthread_should_stop() after the setting of task state · 0bd89676
    Hou Tao 提交于
    A umount hang is possible when a race occurs between the umount
    process and the xfsaild kthread. The following sequences outline
    the race:
    
        xfsaild: kthread_should_stop()
    	     => return false, so xfsaild continue
    
        umount: set_bit(KTHREAD_SHOULD_STOP, &kthread->flags)
    	    => by kthread_stop()
        umount: wake_up_process()
    	    => because xfsaild is still running, so 0 is returned
    
        xfsaild: __set_current_state(TASK_INTERRUPTIBLE)
        xfsaild: schedule()
    	    => now, xfsaild will wait indefinitely
    
        umount: wait_for_completion()
    	    => and umount will hang
    
    To fix that, we need to check kthread_should_stop() after we set
    the task state, so the xfsaild will either see the stop bit and
    exit or the task state is reset to runnable by wake_up_process()
    such that it isn't scheduled out indefinitely and detects the stop
    bit at the next iteration.
    Reviewed-by: NChristoph Hellwig <hch@lst.de>
    Reviewed-by: NBrian Foster <bfoster@redhat.com>
    Signed-off-by: NHou Tao <houtao1@huawei.com>
    Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
    0bd89676
xfs_trans_ail.c 21.0 KB