From patchwork Wed Nov 13 14:08:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 3178321 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 66C089F43F for ; Wed, 13 Nov 2013 14:09:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 36A6420630 for ; Wed, 13 Nov 2013 14:09:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BF4A20627 for ; Wed, 13 Nov 2013 14:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759179Ab3KMOId (ORCPT ); Wed, 13 Nov 2013 09:08:33 -0500 Received: from mail-qa0-f51.google.com ([209.85.216.51]:35523 "EHLO mail-qa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759153Ab3KMOIa (ORCPT ); Wed, 13 Nov 2013 09:08:30 -0500 Received: by mail-qa0-f51.google.com with SMTP id hu16so460503qab.3 for ; Wed, 13 Nov 2013 06:08:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=NoxsKhVqZ3X5H3RzJwzwDbtIP4JGkHFKpd9H0S5QSkg=; b=MnqcAkoU5NAijNO+0ihU+JRO4H4Cw5LiULvsSGekSQsx8hYfrNiENNy2QGrqLJeLJm gZVmO3AvnRZtOzxSS0ixdDiTSFfSz7Pxbt8xXViq1H3V3FiclhxN0Qzl+l2tWJ9+13ml kUEPEdaeRvs66l0TcnEHa+fMDDnjC4h4YM7FFXebtdDJUqMWFt16wcTIaGs7rfrEnYKw JuoVTX9W16QRQTk7+hu+M1m9NBbl0wG9UT4lqvQE+u65Dx0dOXURdDiWcoHmS3Tr0I35 YCO9h4nI0/J8IwAkOO9o/MF9k6wnGa3O+cxjCtBupk4hMjod4Ml2V/ukNbSpn0tWjavg 25lA== X-Gm-Message-State: ALoCoQmiyznJKMUp6QU4BtZtPoHYPiLqJYG75D28Jd9TFFag6CDJGGcj86x0+GYAifiNep9bJUvY X-Received: by 10.224.88.193 with SMTP id b1mr68614755qam.81.1384351709095; Wed, 13 Nov 2013 06:08:29 -0800 (PST) Received: from salusa.poochiereds.net (cpe-107-015-124-230.nc.res.rr.com. [107.15.124.230]) by mx.google.com with ESMTPSA id x10sm82586992qas.5.2013.11.13.06.08.27 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2013 06:08:28 -0800 (PST) From: Jeff Layton To: trond.myklebust@netapp.com Cc: linux-nfs@vger.kernel.org, chuck.lever@oracle.com, dros@netapp.com Subject: [PATCH v2] nfs: don't retry detect_trunking with RPC_AUTH_UNIX more than once Date: Wed, 13 Nov 2013 09:08:21 -0500 Message-Id: <1384351701-29572-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, when we try to mount and get back NFS4ERR_CLID_IN_USE or NFS4ERR_WRONGSEC, we create a new rpc_clnt and then try the call again. There is no guarantee that doing so will work however, so we can end up retrying the call in an infinite loop. Worse yet, we create the new client using rpc_clone_client_set_auth, which creates the new client as a child of the old one. Thus, we can end up with a *very* long lineage of rpc_clnts. When we go to put all of the references to them, we can end up with a long call chain that can smash the stack as each rpc_free_client() call can recurse back into itself. This patch fixes this by simply ensuring that the SETCLIENTID call will only be retried in this situation if the last attempt did not use RPC_AUTH_UNIX. Note too that with this change, we don't need the (i > 2) check in the -EACCES case since we now have a more reliable test as to whether we should reattempt. Cc: stable@vger.kernel.org # v3.10+ Cc: Chuck Lever Tested-by/Acked-by: Weston Andros Adamson Signed-off-by: Jeff Layton --- fs/nfs/nfs4state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index c8e729d..6f04706 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2093,10 +2093,15 @@ again: nfs4_root_machine_cred(clp); goto again; } - if (i > 2) + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) break; case -NFS4ERR_CLID_INUSE: case -NFS4ERR_WRONGSEC: + /* No point in retrying if we already used RPC_AUTH_UNIX */ + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) { + status = -EPERM; + break; + } clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_UNIX); if (IS_ERR(clnt)) { status = PTR_ERR(clnt);