* This also has to properly handle the case of inodes with nlink == 0
* in case they are being linked into the PENDING directory
*/
-#ifdef I_LINKABLE
- /* This is necessary to increment from i_nlink == 0 */
- spin_lock(&inode->i_lock);
- inode->i_state |= I_LINKABLE;
- spin_unlock(&inode->i_lock);
-#endif
-
spin_lock(&obj->oo_guard);
- ldiskfs_inc_count(oh->ot_handle, inode);
- if (!S_ISDIR(inode->i_mode))
- LASSERT(inode->i_nlink <= LDISKFS_LINK_MAX);
+ if (unlikely(inode->i_nlink == 0))
+ /* inc_nlink from 0 may cause WARN_ON */
+ set_nlink(inode, 1);
+ else {
+ ldiskfs_inc_count(oh->ot_handle, inode);
+ if (!S_ISDIR(inode->i_mode))
+ LASSERT(inode->i_nlink <= LDISKFS_LINK_MAX);
+ }
spin_unlock(&obj->oo_guard);
ll_dirty_inode(inode, I_DIRTY_DATASYNC);