Skip to content

Commit

Permalink
ocfs2: fix rename vs unlink race
Browse files Browse the repository at this point in the history
If another node unlinks the destination while ocfs2_rename() is waiting on a
cluster lock, ocfs2_rename() simply logs an error and continues. This causes
a crash because the renaming node is now trying to delete a non-existent
inode. The correct solution is to return -ENOENT.

Signed-off-by: Srinivas Eeda <srinivas.eeda@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
  • Loading branch information
Srinivas Eeda authored and Mark Fasheh committed Nov 6, 2007
1 parent bc7e97c commit e325a88
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions fs/ocfs2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,9 +1105,16 @@ static int ocfs2_rename(struct inode *old_dir,
goto bail;
}

if (!new_de && new_inode)
mlog(ML_ERROR, "inode %lu does not exist in it's parent "
"directory!", new_inode->i_ino);
if (!new_de && new_inode) {
/*
* Target was unlinked by another node while we were
* waiting to get to ocfs2_rename(). There isn't
* anything we can do here to help the situation, so
* bubble up the appropriate error.
*/
status = -ENOENT;
goto bail;
}

/* In case we need to overwrite an existing file, we blow it
* away first */
Expand Down

0 comments on commit e325a88

Please sign in to comment.