Return-Path: linux-nfs-owner@vger.kernel.org Received: from mx1.netapp.com ([216.240.18.38]:11444 "EHLO mx1.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753997Ab3KYR5z (ORCPT ); Mon, 25 Nov 2013 12:57:55 -0500 From: To: CC: , Andy Adamson Subject: [PATCH 0/1] NFSv4.1 fix a kswap nfs4_state_manger race Date: Mon, 25 Nov 2013 12:57:49 -0500 Message-ID: <1385402270-14284-1-git-send-email-andros@netapp.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-nfs-owner@vger.kernel.org List-ID: From: Andy Adamson This is a three way race between the state manager, kswapd and sys_open. We are hitting this regularily in our long term testing. This patch should fix the race - but before we test with this patch, I'd like comments from the list. The state manager is waiting in __rpc_wait_for_completion_task for a recovery OPEN to complete: kernel: Call Trace: kernel: [] ? __wake_up_common+0x59/0x90 kernel: [] ? rpc_wait_bit_killable+0x0/0xa0 [sunrpc] kernel: [] rpc_wait_bit_killable+0x42/0xa0 [sunrpc] kernel: [] __wait_on_bit+0x5f/0x90 kernel: [] ? rpc_wait_bit_killable+0x0/0xa0 [sunrpc] kernel: [] out_of_line_wait_on_bit+0x78/0x90 kernel: [] ? wake_bit_function+0x0/0x50 kernel: [] __rpc_wait_for_completion_task+0x2d/0x30 [sunrpc] kernel: [] nfs4_run_open_task+0x11c/0x160 [nfs] kernel: [] nfs4_open_recover_helper+0x87/0x120 [nfs] kernel: [] nfs4_open_recover+0xc6/0x150 [nfs] kernel: [] ? nfs4_open_recoverdata_alloc+0x2f/0x60 [nfs] kernel: [] nfs4_open_reclaim+0xad/0x140 [nfs] kernel: [] nfs4_do_reclaim+0x15b/0x5e0 [nfs] kernel: [] ? pnfs_destroy_layout+0x63/0x80 [nfs] kernel: [] nfs4_run_state_manager+0x44b/0x620 [nfs] kernel: [] ? nfs4_run_state_manager+0x0/0x620 [nfs] kernel: [] kthread+0x96/0xa0 kernel: [] child_rip+0xa/0x20 kernel: [] ? kthread+0x0/0xa0 kernel: [] ? child_rip+0x0/0x20 Kswapd is shrinking the inode cache, and waiting for a layoutreturn: kernel: Call Trace: kernel: [] ? rpc_wait_bit_killable+0x0/0xa0 [sunrpc] kernel: [] rpc_wait_bit_killable+0x42/0xa0 [sunrpc] kernel: [] __wait_on_bit+0x5f/0x90 kernel: [] ? _spin_unlock_bh+0x1b/0x20 kernel: [] ? rpc_wait_bit_killable+0x0/0xa0 [sunrpc] kernel: [] out_of_line_wait_on_bit+0x78/0x90 kernel: [] ? wake_bit_function+0x0/0x50 kernel: [] ? rpc_exit_task+0x0/0x60 [sunrpc] kernel: [] __rpc_execute+0xf5/0x350 [sunrpc] kernel: [] ? bit_waitqueue+0x17/0xd0 kernel: [] rpc_execute+0x61/0xa0 [sunrpc] kernel: [] rpc_run_task+0x75/0x90 [sunrpc] kernel: [] nfs4_proc_layoutreturn+0x9c/0x110 [nfs] kernel: [] _pnfs_return_layout+0x11e/0x1e0 [nfs] kernel: [] nfs4_clear_inode+0x44/0x70 [nfs] kernel: [] clear_inode+0xac/0x140 kernel: [] dispose_list+0x40/0x120 kernel: [] shrink_icache_memory+0x274/0x2e0 kernel: [] shrink_slab+0x12a/0x1a0 kernel: [] balance_pgdat+0x59a/0x820 kernel: [] kswapd+0x134/0x3b0 kernel: [] ? autoremove_wake_function+0x0/0x40 kernel: [] ? kswapd+0x0/0x3b0 kernel: [] kthread+0x96/0xa0 kernel: [] child_rip+0xa/0x20 kernel: [] ? kthread+0x0/0xa0 kernel: [] ? child_rip+0x0/0x20 The layoutreturn is on the cl_rpcwaitq waiting for the state manager to complete: kernel: 14628 0a80 0 ffff88013c8a3a00 (null) 0 ffffffffa0430580 nfsv4 LAYOUTRETURN a:rpc_prepare_task q:NFS client Meanwhile, a sys_open is waiting in __wait_on_freeing_inode for kswapd to complete the inode deletion. Note that this OPEN RPC has almost completed - it is stuck processing nfs4_opendata_to_nfs4_state, but it has yet to call nfs_release_seqid: kernel: Call Trace: kernel: [] ? user_match+0x0/0x20 kernel: [] ? prepare_to_wait+0x4e/0x80 kernel: [] __wait_on_freeing_inode+0x98/0xc0 kernel: [] ? wake_bit_function+0x0/0x50 kernel: [] ? nfs_find_actor+0x0/0x90 [nfs] kernel: [] find_inode+0x64/0x90 kernel: [] ? nfs_find_actor+0x0/0x90 [nfs] kernel: [] ifind+0x4d/0xd0 kernel: [] ? nfs_find_actor+0x0/0x90 [nfs] kernel: [] iget5_locked+0x59/0x1b0 kernel: [] ? nfs_init_locked+0x0/0x40 [nfs] kernel: [] nfs_fhget+0xc6/0x6c0 [nfs] kernel: [] nfs4_opendata_to_nfs4_state+0x1c1/0x330 [nfs] kernel: [] _nfs4_do_open+0x21c/0x4f0 [nfs] kernel: [] ? rpcauth_lookup_credcache+0xc5/0x260 [sunrpc] kernel: [] nfs4_do_open+0x85/0x170 [nfs] kernel: [] nfs4_atomic_open+0x28/0x50 [nfs] kernel: [] nfs_atomic_lookup+0x15d/0x310 [nfs] kernel: [] do_lookup+0x1a5/0x230 kernel: [] __link_path_walk+0x78c/0xfe0 kernel: [] ? __generic_file_aio_write+0x260/0x490 kernel: [] ? rpc_do_put_task+0x30/0x40 [sunrpc] kernel: [] path_walk+0x6a/0xe0 kernel: [] filename_lookup+0x6b/0xc0 kernel: [] ? security_file_alloc+0x16/0x20 kernel: [] do_filp_open+0x104/0xd20 kernel: [] ? autoremove_wake_function+0x0/0x40 kernel: [] ? cp_new_stat+0xe4/0x100 kernel: [] ? alloc_fd+0x92/0x160 kernel: [] do_sys_open+0x69/0x140 kernel: [] ? sys_write+0x51/0x90 kernel: [] sys_open+0x20/0x30 kernel: [] system_call_fastpath+0x16/0x1b The OPEN from the state manager (this is an educated guess) is waiting for the above open to release the seqid - so it is waiting on the Seqid_waitqueue kernel: 11683 0081 0 ffff880037827c00 (null) 0 ffffffffa0430180 nfsv4 OPEN a:rpc_prepare_task q:Seqid_waitqueue Turning off error handling for layoutreturn calls that come from nfs4_evict_inode will prevent the race. It would be more accurate to only turn off this error handling when kswapd and the state manager are running, but that seemed too complicated to worry about as layoutreturn already passes in a NULL state to nfs4_async_handle_errors and so does not handle a good number errors. Andy Adamson (1): NFSv4.1 Don't handle layoutreturn errors when state manager is running fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/pnfs.c | 5 ++++- include/linux/nfs_xdr.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) -- 1.8.3.1