From patchwork Fri Oct 26 19:06:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 1653261 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F29D7DFAF2 for ; Fri, 26 Oct 2012 19:06:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758971Ab2JZTGx (ORCPT ); Fri, 26 Oct 2012 15:06:53 -0400 Received: from mx2.netapp.com ([216.240.18.37]:30504 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759012Ab2JZTGw (ORCPT ); Fri, 26 Oct 2012 15:06:52 -0400 X-IronPort-AV: E=Sophos;i="4.80,654,1344236400"; d="scan'208";a="704303187" Received: from smtp2.corp.netapp.com ([10.57.159.114]) by mx2-out.netapp.com with ESMTP; 26 Oct 2012 12:06:50 -0700 Received: from vpn2ntap-401265.hq.netapp.com (vpn2ntap-401265.hq.netapp.com [10.55.68.85]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id q9QJ6lnq026777; Fri, 26 Oct 2012 12:06:49 -0700 (PDT) From: Weston Andros Adamson To: Trond.Myklebust@netapp.com Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson Subject: [PATCH 2/2] SUNRPC: add WARN_ON_ONCE for potential deadlock Date: Fri, 26 Oct 2012 15:06:47 -0400 Message-Id: <1351278407-13804-2-git-send-email-dros@netapp.com> X-Mailer: git-send-email 1.7.9.6 (Apple Git-31.1) In-Reply-To: <1351278407-13804-1-git-send-email-dros@netapp.com> References: <1351278407-13804-1-git-send-email-dros@netapp.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org rpc_shutdown_client should never be called from a workqueue context. If it is, it could deadlock looping forever trying to kill tasks that are assigned to the same kworker thread (and will never run rpc_exit_task). Signed-off-by: Weston Andros Adamson --- net/sunrpc/clnt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index cdc7564..d2737c2 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -607,6 +607,12 @@ EXPORT_SYMBOL_GPL(rpc_killall_tasks); */ void rpc_shutdown_client(struct rpc_clnt *clnt) { + /* + * To avoid deadlock, never call rpc_shutdown_client from a + * workqueue context! + */ + WARN_ON_ONCE(current->flags & PF_WQ_WORKER); + dprintk_rcu("RPC: shutting down %s client for %s\n", clnt->cl_protname, rcu_dereference(clnt->cl_xprt)->servername);