Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3288141pxj; Tue, 1 Jun 2021 01:36:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJKFhvgvqLXlS6a43nXKVrrhhPYAmVLMToK7GWjoL7B0Rp/hPoQx4ExvOv9uoRVfY9Hrf0 X-Received: by 2002:a17:906:e0d5:: with SMTP id gl21mr27795212ejb.93.1622536588847; Tue, 01 Jun 2021 01:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622536588; cv=none; d=google.com; s=arc-20160816; b=TOvt4J9MKsLEnz7zYrpd4Ia8yinjCU8QzCDnLkMPZ39XG5Wg6a6DUrpBgQ1GQdOQuc aVyHHlru3a9Atx+/jtSF+iYPHjEBpKn5m18/14lIJ6LkSkkOM28yVaErxmHNLfSy7GT/ p7f6FPyCavE/J56X2XKpYi0O912UWdanD+oiLeyM7V2NI1AaNNaC3Gnqteqlcpz6nm11 24+1AmJlBj+oeoskDsVdWKkze7Lc1uIsKTpcXVuKT+l0qBZEyhJ6itaLrMdM1bSx7KKZ ksOToOp1QLK6JcPQE8cKBt3awDFKn11OwuNB2nGjhqoLUKj1vzKohVs9aPF5M1SLUaLK EBxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:to:from; bh=SWq8BLLDKOeMzrbTVKkxgWRPaFqg8LC4ftc79g/SBsc=; b=YT37QjwzcSTefL/DJ9CR/+8Fyues/hpiWuKB/b/Z4K6a5ZGWAgXuhojgwD0XiqSmps 3JaAkrlMznOXj50TJVSee0oIP9ANXhpbQmb7ChOXCqYlYa7c2e18IPbESdNKE+5LcdWj mepT2AbJGR1Aoi1EhZmJDFjm2ciwbllKDJYuGWWx/SXU/Z6e7pFy1/Ermo9R1j0oJ4XD A7Dbzi7kzD+TjmaxCdGipHbziZywIUDRx3RTPhAa5UYaKo57+Ah5QHEFKeD0eb605hXS nZ1SkJr1G6JybDneg/+Vnt2br3SEO0J0kiLWN7oDb/gr53JlHofaNZIS+XL1KgIyoKfY UfsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di7si10205675ejc.71.2021.06.01.01.35.56; Tue, 01 Jun 2021 01:36:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232963AbhFAIh3 (ORCPT + 99 others); Tue, 1 Jun 2021 04:37:29 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:2819 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbhFAIh2 (ORCPT ); Tue, 1 Jun 2021 04:37:28 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FvQNS5F1LzWmdD; Tue, 1 Jun 2021 16:31:04 +0800 (CST) Received: from dggpeml500023.china.huawei.com (7.185.36.114) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 1 Jun 2021 16:35:46 +0800 Received: from [10.174.176.83] (10.174.176.83) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 1 Jun 2021 16:35:45 +0800 From: "zhangxiaoxu (A)" To: , Anna Schumaker , Linux NFS Mailing List , , "zhangyi (F)" Subject: nfsv4.1 deadlock between evict and nfs_fhget when drain session Message-ID: Date: Tue, 1 Jun 2021 16:35:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.83] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Hello, We're seeing a deadlock on NFSv4.1. The process of the deadlock maybe as below: - task 1: prune icache, and mark inode_A & inode_B on freeing, then evict inode_A first, but waiting for inode_A's delegation return to server - task 2: open file, already got the fh from server, waiting for the inode_B which has the same file handle was freed complete - task 3: state manager is on draining session, but there is a slot is hold by task2 - task 4: run the delegreturn rpc_task, but the session is on draining, so the delegreturn is sleeping on rpc. Then task 1 blocked. then deadlocked. Commit 244fcd2f9a90 ("NFS: Ensure we time out if a delegreturn does not complete") already ensure the delegreturn task can timeout if get slot from session. But can't timeout if task sleep on rpc when session is on draining. I think commit 5fcdfacc01f3 ("NFSv4: Return delegations synchronously in evict_inode") introduce this problem. But if revert it, there maybe another deadlock because task 1 maybe waiting inode_A writeback complete. If make delegreturn privileged in rpc, as the same above. I think the task 2 should free the slot as soon as possible when it's rpc task complete. But ae55e59da0e4 ("pnfs: Don't release the sequence slot until we've processed layoutget on open") made slot freed more late. Any idea about this problem is welcome. Stacks of the problem: # task1: __wait_on_freeing_inode find_inode ilookup5_nowait ilookup5 iget5_locked nfs_fhget _nfs4_opendata_to_nfs4_state nfs4_do_open nfs4_atomic_open nfs_atomic_open path_openat do_filp_open do_sys_open __x64_sys_open do_syscall_64 entry_SYSCALL_64_after_hwframe # task2: rpc_wait_bit_killable __rpc_wait_for_completion_task _nfs4_proc_delegreturn nfs4_proc_delegreturn nfs_do_return_delegation nfs_inode_return_delegation_noreclaim nfs4_evict_inode evict dispose_list prune_icache_sb super_cache_scan do_shrink_slab shrink_slab shrink_node kswapd kthread ret_from_fork # task3: nfs4_drain_slot_tbl nfs4_begin_drain_session nfs4_run_state_manager kthread ret_from_fork