From patchwork Wed Oct 24 14:30:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1638691 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 46CDEDF2AB for ; Wed, 24 Oct 2012 14:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934938Ab2JXOac (ORCPT ); Wed, 24 Oct 2012 10:30:32 -0400 Received: from mail-vc0-f174.google.com ([209.85.220.174]:45968 "EHLO mail-vc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934873Ab2JXOaa (ORCPT ); Wed, 24 Oct 2012 10:30:30 -0400 Received: by mail-vc0-f174.google.com with SMTP id fk26so598690vcb.19 for ; Wed, 24 Oct 2012 07:30:30 -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=bnRz5xsjxlP7WRfz+EWlljS1+EG/C871HoORib07FmA=; b=Kkv67Ey7+ZS7KDCM5eMM0kTUSgMTnKgfi2eYn2SmE0HkjNAJgQUNAPsi0yGwmBNNd2 OZFt6PXY58tL7syIv0G1wbPtTcLaB8x5I1axnSrbh4KfmtyKceWYRPaJCirxDfI+lEhW W2wi/MiS6QMulHGuT0u06KAcdZ4ZdOBbbYMOUnP8rUObePaIY/etpAcpRbUe0MXThc2I +rQYm5h09wR8vh4+WpcqoWP2IxDDtqA99bqZYo4fLQd+mouGM5uu8PEEF3/T18SpeiuB lWJLGgoJ4xvsftmqpf4NsU6UDyA64yZLxMnZDQ7j9XlsXV6xceCkc4iJ6NKH6ikCF5gp y2kA== Received: by 10.58.74.196 with SMTP id w4mr29123869vev.7.1351089029363; Wed, 24 Oct 2012 07:30:29 -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 dp6sm15387737vec.11.2012.10.24.07.30.28 (version=SSLv3 cipher=OTHER); Wed, 24 Oct 2012 07:30:28 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 2/4] nfsd: change heuristic for selecting the client_tracking_ops Date: Wed, 24 Oct 2012 10:30:16 -0400 Message-Id: <1351089018-24551-3-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1351089018-24551-1-git-send-email-jlayton@redhat.com> References: <1351089018-24551-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQlSof9dnKbLlRXtorhyKqSGswATohPm76nk733u3sLtO+1XN58QEkKr7/xy1basK+aa2GLn 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 46e4081..aa165fd 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -1063,17 +1063,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 "