Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2717886pxv; Sun, 11 Jul 2021 23:41:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrGWk4e1N9RQAn2cMFSu0zpfsPJX1YJN/zVeaUNJ4Udl1uUIECYQ5lM7SyFzOjvqqb5MiM X-Received: by 2002:aa7:dc0c:: with SMTP id b12mr63829757edu.105.1626072095918; Sun, 11 Jul 2021 23:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072095; cv=none; d=google.com; s=arc-20160816; b=usFuEO1Gn6C2sxTvl/v4VHg3Aqwt+ZZtADsOFD7WM5RAW/N+pOeYYxg2tJk/tB60dn TnKCZEK0dkVlCcaXtP2D/DfKdvWS3PVytAf61C6SxFH+9Ar7cToagfpkV884kvRFF0KT J6DbHWnc5YbLwBVx8R26zedlHpCHOHA9CTvH66VJaADvqhwWC18EzCwRtDoO9/ZjLiHD rYWFMRoGkkLEhxQnd75asGKi6NntlJyqYPQqP2tjrcnFqHDqZe10k6CLxOl1Au0qB4WD 6tXTHrHc3Har2RMVmrw740KU98MI+mrHRJx+AHNOJ5BYP7vNLLLDUHkIC4mXRblln0na jEmg== 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=lf+WBX4Xn00ynKVgtzkEKoq+900Z2Edf7izTkZrEkF0=; b=oeDIdBvLYw7kUL1CC3IYXR3aFtGqZ1WJnk3mKe3evuu49rsf3O3zGPKPlAGuUZceZW iROwqEkQqdWokCY66pZyqkWjygpAU/vXCYeSXHrNP23NLUgRH4Q1/DE5NxDwOfUwZz1D e6H/FM5KzWMW+gul7VE3zK2LYd/L9MCVRyBBWMeDP2MfdVUqnURDeETgH1N8jQ6YHWXa IyIRQfvIkVJAfwfrJycpxAfaLukFCJT7O6akZp6bavqmLWJDgGj4NqQ+nwG5c5+HkKzi 0xOIS5KVpqbPp3yijXVBFMRID8OFePFIezyRO3IBP2aXAZq+wqkiFp7CbtElmGOgbYs5 rSGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UdbMZEnW; 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 bi14si16050583ejb.441.2021.07.11.23.41.12; Sun, 11 Jul 2021 23:41:35 -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=UdbMZEnW; 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 S237067AbhGLGmk (ORCPT + 99 others); Mon, 12 Jul 2021 02:42:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:54420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236797AbhGLGeH (ORCPT ); Mon, 12 Jul 2021 02:34:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FA126115A; Mon, 12 Jul 2021 06:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071410; bh=tWmbKHy71o7Kx6rKGktj+eUE7fNRCejxrtQ2YTbOhOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UdbMZEnWmIhnW19L50xzGgvChr9FzSdKgdjmN/3fr1bUGD6foYfw+V99WyddKsV39 qAbLe88XZoKpIyJTedUZeVbhFIdN2JmdwG8okPwpV22GqUie/SWOKzicUZ7cucv9jW GZFf/61xLpXKfe/sAnHH1CMgl0mBY/ujmiIUtmCQ= 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.10 057/593] SUNRPC: Should wake up the privileged task firstly. Date: Mon, 12 Jul 2021 08:03:37 +0200 Message-Id: <20210712060849.377203167@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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 @@ -592,6 +592,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];