ocfs2: fix the wrong directory passed to ocfs2_lookup_ino_from_name() when link file
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 <e513a8cfffdd1761b5c8047b6b6cbe23f11326f2@huawei.com>
Reported-by: Szabo Aron - UBIT <ce30127eefa07a02d568832e3de6952fb491981c@ubit.hu>
Cc: Mark Fasheh <8f0bc92cac940f3e83deb53ced7a1f201bce5732@suse.com>
Cc: Joel Becker <9d3d88cacb47f143c6cf36b9a61c09b528b2c49a@evilplan.org>
Tested-by: Aron Szabo <ce30127eefa07a02d568832e3de6952fb491981c@ubit.hu>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs