From: Yang Sheng Date: Mon, 25 Aug 2014 03:58:57 +0000 (+0800) Subject: LU-4416 osd: using set_nlink to calm down WARN_ON message X-Git-Tag: 2.6.52~6 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F11571%2F2;p=fs%2Flustre-release.git LU-4416 osd: using set_nlink to calm down WARN_ON message 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 Change-Id: I1e110872b359ebd7fa883506c5592f072f26c1dc Reviewed-on: http://review.whamcloud.com/11571 Tested-by: Jenkins Reviewed-by: Bob Glossman Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 0c5a07d..b656a79 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -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);