Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2705113pxv; Sun, 11 Jul 2021 23:17:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVr5qjmb6sLEe/kpIPmkSEoOqgS4RJog0UN6g8v9aNYmXDabKlgRRqLjpgwmrnzN6Qw8aQ X-Received: by 2002:a05:6602:17ce:: with SMTP id z14mr17808387iox.73.1626070633165; Sun, 11 Jul 2021 23:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626070633; cv=none; d=google.com; s=arc-20160816; b=yVsP+m8mY7GQ22OV/EojVR+ysMeFiNYhfZ02WnmEtxMDdYQXco3WpdqMVLO1lhMUQx PO4QBbt7O9cnMiXeO8v4y5wNPcWLNdyRDHIVIDjwqUIP4cpsDwOZyb5EIg4RILOVf31j tIogCSCfReEU0PBrQm/4MJrLwfg3nx0slj5BnS+emWlLz58Xo4HiVUuRqI30imh+q9tR OGvz//92BEOpOwtfT7xyW6w0KU3R8HS8Ndk2TRKBUHGzsZQlDEUZv6PJ9/HTTicB68oY iL+2fBgB/UvKUd/csGgF/cIkvJtAahdMq6Ha3FOFkoV1OhNwQLTF14xOD5f49J3ei+AO /T1A== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZDR+IPaWzy4zIizsE6pkMuqD/L6fFKirYm6SDhKA42U=; b=Sv9QBwxI0LlFh50uwO+83WuAad8NKTqk9bLLdRo+bJg8UAz4hiL9XuVj7dG74s/pyi S7+/4wBDF+JaxAnGnuuR2PX/WVwacLraee7VJaDZ45T5DhZIixXZOh3yUp54MQu0xiJy PzW2pQP8boVXC9T4sdUR9U70T7BqfgnMxcJgabL2btdVuKlmYTHe3neBtV3nxBTm8QsV IKTYbr7Gjugpsk6Jl+2OjOD2EzznaHQFrfQCXukcoEU3MDgFKTkKymAnzud+h6xkSKvd UJyCscnhGH0AKR3VnwEq0Y29g6js8jIANZsc1q6otpzlWcICC2A+Ph+TDMvcotSQkMtO Fqrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Yshz9cFr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si15803702ioo.61.2021.07.11.23.17.01; Sun, 11 Jul 2021 23:17:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Yshz9cFr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233661AbhGLGSy (ORCPT + 99 others); Mon, 12 Jul 2021 02:18:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:37142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233638AbhGLGSh (ORCPT ); Mon, 12 Jul 2021 02:18:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 48842610A6; Mon, 12 Jul 2021 06:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626070548; bh=TBTmTryKrZ8po2TfPn+5uUsi0jl0S0DH+njtcRD7EOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yshz9cFryC2/Nb/NpLltncZrZsuP79T4MtVU9shgEIFMVfX4Xn46+FrMLoaWpXzwn gWXGFVDdAhMYyJzlLq81a0hMPVb5tnDi3qsmFXq4gtZfeIWSKQ4oOgNthGFbtvrO4a 7O2qp736J05ajho0hjeo6PG6fXhv19pu4GuoJTIo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zhang Xiaoxu , Trond Myklebust Subject: [PATCH 5.4 038/348] SUNRPC: Should wake up the privileged task firstly. Date: Mon, 12 Jul 2021 08:07:02 +0200 Message-Id: <20210712060706.033127800@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Xiaoxu commit 5483b904bf336948826594610af4c9bbb0d9e3aa upstream. 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 Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/sched.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -614,6 +614,15 @@ static struct rpc_task *__rpc_find_next_ 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. */ q = &queue->tasks[queue->priority];