Brian Foster 22419ac9fe xfs: fix broken i_nlink accounting for whiteout tmpfile inode
XFS uses the internal tmpfile() infrastructure for the whiteout inode
used for RENAME_WHITEOUT operations. For tmpfile inodes, XFS allocates
the inode, drops di_nlink, adds the inode to the agi unlinked list,
calls d_tmpfile() which correspondingly drops i_nlink of the vfs inode,
and then finishes the common inode setup (e.g., clear I_NEW and unlock).

The d_tmpfile() call was originally made inxfs_create_tmpfile(), but was
pulled up out of that function as part of the following commit to
resolve a deadlock issue:

	330033d6 xfs: fix tmpfile/selinux deadlock and initialize security

As a result, callers of xfs_create_tmpfile() are responsible for either
calling d_tmpfile() or fixing up i_nlink appropriately. The whiteout
tmpfile allocation helper does neither. As a result, the vfs ->i_nlink
becomes inconsistent with the on-disk ->di_nlink once xfs_rename() links
it back into the source dentry and calls xfs_bumplink().

Update the assert in xfs_rename() to help detect this problem in the
future and update xfs_rename_alloc_whiteout() to decrement the link
count as part of the manual tmpfile inode setup.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-05-29 08:14:55 +10:00
..
2014-07-30 09:12:05 +10:00
2015-02-16 11:49:23 +11:00
2013-05-07 18:45:36 -05:00
2011-08-12 16:21:35 -05:00
2012-11-19 20:11:24 -06:00
2015-04-24 07:08:41 -07:00
2013-08-12 16:53:39 -05:00
2011-08-12 16:21:35 -05:00
2011-08-12 16:21:35 -05:00
2015-02-23 21:24:37 +11:00
2013-08-12 16:56:06 -05:00
2015-02-23 21:22:31 +11:00
2015-02-23 21:22:31 +11:00
2013-05-07 18:45:36 -05:00
2015-02-23 21:24:37 +11:00
2015-03-04 16:06:38 +01:00
2015-02-23 21:22:31 +11:00
2015-01-09 10:47:43 +11:00
2014-09-09 11:52:42 +10:00
2013-05-07 18:45:36 -05:00