Commit 1247017f authored by jiangyiwen's avatar jiangyiwen Committed by Linus Torvalds

ocfs2: fix slot overwritten if storage link down during mount

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
                                 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.

[ coding-style fixes]
Signed-off-by: default avatarYiwen Jiang <>
Reviewed-by: default avatarJoseph Qi <>
Cc: Mark Fasheh <>
Cc: Joel Becker <>
Cc: Junxiao Bi <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent c372f219
......@@ -502,8 +502,17 @@ int ocfs2_find_slot(struct ocfs2_super *osb)
status = ocfs2_update_disk_slot(osb, si, osb->slot_num);
if (status < 0)
if (status < 0) {
* if write block failed, invalidate slot to avoid overwrite
* slot during dismount in case another node rightly has mounted
ocfs2_invalidate_slot(si, osb->slot_num);
osb->slot_num = OCFS2_INVALID_SLOT;
return status;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment