Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3761087pxv; Mon, 19 Jul 2021 08:09:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRjZlXy5bjfP8ni4ZpZICO3Crldl/THABX71zsDJhFrS1awT7425gq11NX7YtrInNZ97z0 X-Received: by 2002:a05:6602:2f09:: with SMTP id q9mr12674184iow.196.1626707363953; Mon, 19 Jul 2021 08:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707363; cv=none; d=google.com; s=arc-20160816; b=QEdBl1ja2ZVA/DPbUsDuVq5pLljfvj+2whffbS4+iofaMkFyQTjXk0nfCLAu7ws82T 0u1qkAjh4LhzQGCrzYbs//Ut4TFJiE4ba/NFJm//L1Bd7b+HHJR6sRz13dMKDIMn4aVz F0vsU1XYJyLVwHyWz93MDxNdCfCZJoEv8x+MvG8oRnLrf7V7Kq2i+Uof1juE1OiqwzSf r1z77GcRTQ8oqG6JLFY3q4+dSP1yoZdbxNqEhc5pOMUhJKxHkqklaWN7er5jWQHveRY9 ndK1J6B5N1NUcs/XDAoSQ6jzC05skJe8fMc04GyGhkqvNqCx3UjJf29q5J/v+dD+iIiZ WoIw== 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=mTWLC8zgS3khM3DQBfQdKs4W9xygQicj8eLHT7a7Cds=; b=DUC91lQ6BtoQfe2QS256t1I3znpCGMVBkxzsEFIsvjxzmxOAViNnAO082i2umQdOLY Q/83EExT0IwxqKabCig7WD62ra76ccsJqq1o73GToNl4/bXUSS03PThHP9logzYUFaPI I5FprTRirVy8JIa8HgvsPJryI4r5aVjdXqdaMBpRCZf0TMT/P28NrHBJrS9PkDBzl9tv kR0fKeMX6X4ybNaCJzk+GQ0NVIL/RmNw300mivW3xQb1tSFxq74Q2Z+1ZT56u9iaTyri 1UrumRlfeHkjRbDFRdX32FFKNnkXgC3rSUsHml35OE1C/zSU/FMfCN9MpWDplbUtB8Bo 48Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yZb79QMq; 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 d187si22240671iog.56.2021.07.19.08.09.12; Mon, 19 Jul 2021 08:09:23 -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=yZb79QMq; 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 S241610AbhGSO0r (ORCPT + 99 others); Mon, 19 Jul 2021 10:26:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:55982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243887AbhGSOYe (ORCPT ); Mon, 19 Jul 2021 10:24:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B4AE61353; Mon, 19 Jul 2021 15:04:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707064; bh=W4ByK9wkQG1cSVbGIN/eHosYp9Dpk8vAUElkANoImus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yZb79QMqEzim6WpX6cPNIzk8n+zpYScgsTeuyrFp3tO041bH80DvqaUX420Kpn4ZN NX9iB2IaxJ0KV407RCfqbkcuJ6l4XdOSwH9qUCOevdQNdpj9pQbI17hR3wzcSxUY2Z xpJFnUFUjAgxkB/EAgwUdLNHKjJ5IuIitNexUlGM= 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 4.9 017/245] SUNRPC: Should wake up the privileged task firstly. Date: Mon, 19 Jul 2021 16:49:19 +0200 Message-Id: <20210719144940.952986757@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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 @@ -487,6 +487,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];