From patchwork Wed Oct 3 12:40:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1541331 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 29018E00EA for ; Wed, 3 Oct 2012 12:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754705Ab2JCMkm (ORCPT ); Wed, 3 Oct 2012 08:40:42 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:59236 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754704Ab2JCMkl (ORCPT ); Wed, 3 Oct 2012 08:40:41 -0400 Received: by ggnr5 with SMTP id r5so1927997ggn.19 for ; Wed, 03 Oct 2012 05:40:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=x1KQ55ajarROKWRh84yL9Vzvs+SepKbODoDoTrUCvlQ=; b=Vsei4Syen4FH2xIXmg7r2JvR5EYJeFKIc/Yo/ESM+crivHjDXL1e3V45uLbzEfQJ3y s9ZiJK3vSssAfgbhJ7aCtnFPCYzanYSJMI+Zj0xvIcwNsqkMu6Y0wozA5lXug4jvXGDS o19NbdGPWxlVnC41UiHzEfDFPcOjgDxdHG+VJ4ww2i3hYJKCR/tAZbpHVky19qhXktZb gaAojTKIHSXEhXzE6YEfJI7PfEL1jeVV9fdqAaO2+f4xqV4RCqbH1KzpBbhJ3FVpnFAb lLxMLBP8BU98kWSo0vM7UWaNoie91aNa29Rc6EG073GlGWrXvI4sne/Wf7vBs+67WmSy uC0g== Received: by 10.101.152.39 with SMTP id e39mr508416ano.14.1349268041238; Wed, 03 Oct 2012 05:40:41 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id h17sm3566370ang.21.2012.10.03.05.40.40 (version=SSLv3 cipher=OTHER); Wed, 03 Oct 2012 05:40:40 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 2/3] nfsd: change heuristic for selecting the client_tracking_ops Date: Wed, 3 Oct 2012 08:40:30 -0400 Message-Id: <1349268031-16498-3-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1349268031-16498-1-git-send-email-jlayton@redhat.com> References: <1349268031-16498-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQk//+WdGPkdaWxrAh+dmzYdaVtIISiWizlXRvQi5j+ggwd5mhyHwVSuw9CNKn6zSZ/Z1VjB Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org First, try to use the new usermodehelper upcall. It should succeed or fail quickly, so there's little cost to doing so. If it fails, and the legacy tracking dir exists, use that. If it doesn't exist then fall back to using nfsdcld. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4recover.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 481cb3e..5a74037 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -1068,17 +1068,35 @@ nfsd4_client_tracking_init(struct net *net) int status; struct path path; - if (!client_tracking_ops) { - client_tracking_ops = &nfsd4_cld_tracking_ops; - status = kern_path(nfs4_recoverydir(), LOOKUP_FOLLOW, &path); - if (!status) { - if (S_ISDIR(path.dentry->d_inode->i_mode)) - client_tracking_ops = - &nfsd4_legacy_tracking_ops; - path_put(&path); - } + /* just run the init if it the method is already decided */ + if (client_tracking_ops) + goto do_init; + + /* + * First, try a UMH upcall. It should succeed or fail quickly, so + * there's little harm in trying that first. + */ + client_tracking_ops = &nfsd4_umh_tracking_ops; + status = client_tracking_ops->init(net); + if (!status) + return status; + + /* + * See if the recoverydir exists and is a directory. If it is, + * then use the legacy ops. + */ + client_tracking_ops = &nfsd4_legacy_tracking_ops; + status = kern_path(nfs4_recoverydir(), LOOKUP_FOLLOW, &path); + if (!status) { + status = S_ISDIR(path.dentry->d_inode->i_mode); + path_put(&path); + if (status) + goto do_init; } + /* Finally, try to use nfsdcld */ + client_tracking_ops = &nfsd4_cld_tracking_ops; +do_init: status = client_tracking_ops->init(net); if (status) { printk(KERN_WARNING "NFSD: Unable to initialize client "