• jiangyiwen's avatar
    ocfs2: fix slot overwritten if storage link down during mount · 1247017f
    jiangyiwen authored
    The following case will lead to slot overwritten.
    
    N1                               N2
    mount ocfs2 volume, find and
    allocate slot 0, then set
    osb->slot_num to 0, begin to
    write slot info to disk
                                     mount ocfs2 volume, wait for super lock
    write block fail because of
    storage link down, unlock
    super lock
                                     got super lock and also allocate slot 0
                                     then unlock super lock
    
    mount fail and then dismount,
    since osb->slot_num is 0, try to
    put invalid slot to disk. And it
    will succeed if storage link
    restores.
                                     N2 slot info is now overwritten
    
    Once another node say N3 mount, it will find and allocate slot 0 again,
    which will lead to mount hung because journal has already been locked by
    N2.  so when write slot info failed, invalidate slot in advance to avoid
    overwrite slot.
    
    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: default avatarYiwen Jiang <jiangyiwen@huawei.com>
    Reviewed-by: default avatarJoseph Qi <joseph.qi@huawei.com>
    Cc: Mark Fasheh <mfasheh@suse.de>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Junxiao Bi <junxiao.bi@oracle.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    1247017f
slot_map.c 12.5 KB