Whamcloud - gitweb
LU-4416 osd: using set_nlink to calm down WARN_ON message 71/11571/2
authorYang Sheng <yang.sheng@intel.com>
Mon, 25 Aug 2014 03:58:57 +0000 (11:58 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 30 Aug 2014 00:00:52 +0000 (00:00 +0000)
Invoke inc_nlink with nlink=0 will trigger a WARN_ON
message. Flag I_LINKABLE can avoid this problem in
latest upstream kernel. But there exist a case that
WARN_ON was invoked and I_LINKABLE hasn't defined.
RHEL7 does so. Then we just using set_nlink in the
nlink=0 case.

Signed-off-by: Yang Sheng <yang.sheng@intel.com>
Change-Id: I1e110872b359ebd7fa883506c5592f072f26c1dc
Reviewed-on: http://review.whamcloud.com/11571
Tested-by: Jenkins
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-ldiskfs/osd_handler.c

index 0c5a07d..b656a79 100644 (file)
@@ -2809,17 +2809,15 @@ static int osd_object_ref_add(const struct lu_env *env,
         * 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);