Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1804953pxv; Sat, 26 Jun 2021 00:45:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAB/QkXRcmYWobLgzG2a0zGfPCp0TQkoegrhfJU/gaBj5rB5bOMZAZgCcNmo7bd+jrmYoT X-Received: by 2002:a05:6402:53:: with SMTP id f19mr20403363edu.200.1624693543564; Sat, 26 Jun 2021 00:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624693543; cv=none; d=google.com; s=arc-20160816; b=c1giDFnxSqHvGkv2ZAeGJVAtWK8zBY6FKOcEMITO1qe8rMbxDkcQGi0+npEQs0dc3U 9jNI/tg5szhfBWFKJff2GDtF7wqb+9gnbVLBXCNtD4cz1kkh3zxLHyyuX+7HNtS+pUuZ ToVXLYincfqgFAD7ubHGDl3ptZ/ifrT9GXRxC+83HpfJOODY6hpXGbKnk1vJFAsjlrFG kKzrA271Ear/dbRCwUXVV7L+Vw2oRXxHoOZvUcx5tqZ9fjeJbU+6gv9uvExdaGF3sHGq s3conbIuMX2koF1i3HbeK/IOfE6tF556gDMonSLQGVKc2WQ9mVaW/AAg3ZNoW6ltlRLC nt+A== 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 :references:in-reply-to:message-id:date:subject:to:from; bh=EsK2JmhpqdAPWMeK1YSt+CBO7TxRFa75XikkvhQiKRk=; b=ROEsmzkviALK/a8QMNXZq7Cyz9bcTd9BUodOCRFNT1AIL61ZAFZ/ucxlvxF5ESD7aE njtMKnwKPcEKFev5iObO+mGP8WEFVSxFcq8okeO5Hgd32yFgE6xMdHJnvADJHncsKDhr f23gyopbG8i0/yBaHYajqqh34yclDQrFEzLAjAFgNJtpeaR7MqJ1D+EPu6BMokmS+OuK RLjnHqJn0DInEsrIzyhYuZxlbFgiDTKpLCZi4eRQvFTlTCAk1l5xEOVZyW70ef8i5Hik B6ULXY46WN+6nMiw4KkfKBo2BcOd8Sza5U90WPBEHCaFtcxz8axptv7eydMVdsXukh+i Lv4Q== 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 p4si8798235edr.248.2021.06.26.00.45.16; Sat, 26 Jun 2021 00:45:43 -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 S229573AbhFZHrI (ORCPT + 99 others); Sat, 26 Jun 2021 03:47:08 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:5438 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbhFZHrF (ORCPT ); Sat, 26 Jun 2021 03:47:05 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GBm5b5ws8z71Rl; Sat, 26 Jun 2021 15:41:23 +0800 (CST) Received: from dggpeml500023.china.huawei.com (7.185.36.114) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 26 Jun 2021 15:44:41 +0800 Received: from localhost.localdomain (10.175.101.6) 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; Sat, 26 Jun 2021 15:44:41 +0800 From: Zhang Xiaoxu To: , , , , , Subject: [PATCH 2/2] SUNRPC: Should wake up the privileged task firstly. Date: Sat, 26 Jun 2021 15:50:42 +0800 Message-ID: <20210626075042.805548-3-zhangxiaoxu5@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210626075042.805548-1-zhangxiaoxu5@huawei.com> References: <20210626075042.805548-1-zhangxiaoxu5@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 When find a task from wait queue to wake up, a non-privileged task may be found out, rather than the privileged. This maybe lead a deadlock same as commit dfe1fe75e00e ("NFSv4: Fix deadlock between nfs4_evict_inode() and nfs4_opendata_get_inode()"): Privileged delegreturn task is queued to privileged list because all the slots are assigned. If there has no enough slot to wake up the non-privileged batch tasks(session less than 8 slot), then the privileged delegreturn task maybe lost waked up because the found out task can't get slot since the session is on draining. So we should treate the privileged task as the emergency task, and execute it as for as we can. Reported-by: Hulk Robot Fixes: 5fcdfacc01f3 ("NFSv4: Return delegations synchronously in evict_inode") Cc: stable@vger.kernel.org Signed-off-by: Zhang Xiaoxu --- net/sunrpc/sched.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 37cd09574628..e08ce3b791fd 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -591,6 +591,15 @@ static struct rpc_task *__rpc_find_next_queued_priority(struct rpc_wait_queue *q struct list_head *q; struct rpc_task *task; + /* + * Service the privileged queue. + */ + q = &queue->tasks[RPC_NR_PRIORITY - 1]; + if (queue->maxpriority > RPC_PRIORITY_PRIVILEGED && !list_empty(q)) { + task = list_first_entry(q, struct rpc_task, u.tk_wait.list); + goto out; + } + /* * Service a batch of tasks from a single owner. */ -- 2.25.4