ocfs2: fix the wrong directory passed to ocfs2_lookup_ino_from_name() when link file
authorXue jiufei <xuejiufei@huawei.com>
Thu, 8 Jan 2015 22:32:23 +0000 (14:32 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 8 Jan 2015 23:10:51 +0000 (15:10 -0800)
commit53dc20b9a3d928b0744dad5aee65b610de1cc85d
tree0aa4e0a783b43b460141744d0e3f7fd1d9bd3bd0
parent75dd112aac25713cd686cb4bfa78cf907519c504
ocfs2: fix the wrong directory passed to ocfs2_lookup_ino_from_name() when link file

In ocfs2_link(), the parent directory inode passed to function
ocfs2_lookup_ino_from_name() is wrong.  Parameter dir is the parent of
new_dentry not old_dentry.  We should get old_dir from old_dentry and
lookup old_dentry in old_dir in case another node remove the old dentry.

With this change, hard linking works again, when paths are relative with
at least one subdirectory.  This is how the problem was reproducable:

  # mkdir a
  # mkdir b
  # touch a/test
  # ln a/test b/test
  ln: failed to create hard link `b/test' => `a/test': No such file or  directory

However when creating links in the same dir, it worked well.

Now the link gets created.

Fixes: 0e048316ff57 ("ocfs2: check existence of old dentry in ocfs2_link()")
Signed-off-by: joyce.xue <xuejiufei@huawei.com>
Reported-by: Szabo Aron - UBIT <aron@ubit.hu>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Tested-by: Aron Szabo <aron@ubit.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/namei.c