From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752826AbbINWoJ (ORCPT ); Mon, 14 Sep 2015 18:44:09 -0400 Received: from linuxhacker.ru ([217.76.32.60]:44283 "EHLO fiona.linuxhacker.ru" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752334AbbINWma (ORCPT ); Mon, 14 Sep 2015 18:42:30 -0400 From: green@linuxhacker.ru To: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger Cc: Linux Kernel Mailing List , Andrew Perepechko , Oleg Drokin Subject: [PATCH 13/19] staging/lustre/llite: ASSERTION( atomic_read(&d->ld_ref) == 0 ) failed Date: Mon, 14 Sep 2015 18:41:29 -0400 Message-Id: <1442270495-1655259-14-git-send-email-green@linuxhacker.ru> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1442270495-1655259-1-git-send-email-green@linuxhacker.ru> References: <1442270495-1655259-1-git-send-email-green@linuxhacker.ru> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Perepechko ll_iget_for_nfs() can call unbalanced iput() causing memory leaks. This patch removes this iput() call. Also, avoid unhashing disconnected dentries in d_lustre_invalidate(), which is another source of memory leaks. One of the symptoms of the leak is the following crash pattern: LustreError: 14812:0:(lu_object.c:1251:lu_device_fini()) ASSERTION( atomic_read(&d->ld_ref) == 0 ) failed: Refcount is 1 LustreError: 14812:0:(lu_object.c:1251:lu_device_fini()) LBUG Pid: 14812, comm: umount Call Trace: [] libcfs_debug_dumpstack+0x55/0x80 [libcfs] [] lbug_with_loc+0x47/0xb0 [libcfs] [] lu_device_fini+0xb8/0xc0 [obdclass] [] lovsub_device_free+0x52/0x220 [lov] [] lu_stack_fini+0x7e/0xc0 [obdclass] [] cl_stack_fini+0xe/0x10 [obdclass] [] lov_device_fini+0x58/0x120 [lov] [] lu_stack_fini+0x49/0xc0 [obdclass] [] cl_stack_fini+0xe/0x10 [obdclass] [] cl_sb_fini+0x6d/0x190 [lustre] [] ll_put_super+0x1bc/0x11e0 [lustre] [] ? fsnotify_clear_marks_by_inode+0x32/0xf0 [] ? destroy_inode+0x2f/0x60 [] ? dispose_list+0xfc/0x120 [] ? invalidate_inodes+0xf6/0x190 [] generic_shutdown_super+0x5b/0xe0 [] kill_anon_super+0x16/0x60 [] lustre_kill_super+0x4a/0x60 [obdclass] [] deactivate_super+0x57/0x80 [] mntput_no_expire+0xbf/0x110 [] sys_umount+0x7b/0x3a0 [] system_call_fastpath+0x16/0x1b Signed-off-by: Andrew Perepechko Reviewed-on: http://review.whamcloud.com/15480 Xyratex-bug-id: MRP-2414 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6794 Reviewed-by: Lai Siyao Reviewed-by: Bobi Jam Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/llite/llite_internal.h | 10 +++++++++- drivers/staging/lustre/lustre/llite/llite_nfs.c | 5 +---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 8a3b03e..37bf331 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -1466,7 +1466,15 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested) spin_lock_nested(&dentry->d_lock, nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL); __d_lustre_invalidate(dentry); - if (d_count(dentry) == 0) + /* + * We should be careful about dentries created by d_obtain_alias(). + * These dentries are not put in the dentry tree, instead they are + * linked to sb->s_anon through dentry->d_hash. + * shrink_dcache_for_umount() shrinks the tree and sb->s_anon list. + * If we unhashed such a dentry, unmount would not be able to find + * it and busy inodes would be reported. + */ + if (d_count(dentry) == 0 && !(dentry->d_flags & DCACHE_DISCONNECTED)) __d_drop(dentry); spin_unlock(&dentry->d_lock); } diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 8d1c253..400acacc 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -168,11 +168,8 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren spin_unlock(&lli->lli_lock); } + /* N.B. d_obtain_alias() drops inode ref on error */ result = d_obtain_alias(inode); - if (IS_ERR(result)) { - iput(inode); - return result; - } return result; } -- 2.1.0