UBIFS: do not use inc_link when i_nlink is zero
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Tue, 7 Feb 2012 08:58:51 +0000 (10:58 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 29 Feb 2012 14:10:20 +0000 (16:10 +0200)
commitc43be1085f8480ab36d5c8c76a08e67bdf6d2e18
tree5d77b528c065e6d5c542c631634cd440ae3938ac
parentb06283c7df35b5a49ab141ed38e0280821379096
UBIFS: do not use inc_link when i_nlink is zero

This patch changes the 'i_nlink' counter handling in 'ubifs_unlink()',
'ubifs_rmdir()' and 'ubifs_rename()'. In these function  'i_nlink' may become 0,
and if 'ubifs_jnl_update()' failed, we would use 'inc_nlink()' to restore
the previous 'i_nlink' value, which is incorrect from the VFS point of view and
would cause a 'WARN_ON()' (see 'inc_nlink() implementation).

This patches saves the previous 'i_nlink' value in a local variable and uses it
at the error path instead of calling 'inc_nlink()'. We do this only for the
inodes where 'i_nlink' may potentially become zero.

This change has been requested by Al Viro <viro@ZenIV.linux.org.uk>.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
fs/ubifs/dir.c