From patchwork Mon Oct 1 11:51:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1531071 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id AF36A3FE1C for ; Mon, 1 Oct 2012 11:51:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752268Ab2JALvs (ORCPT ); Mon, 1 Oct 2012 07:51:48 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:57466 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752221Ab2JALvs (ORCPT ); Mon, 1 Oct 2012 07:51:48 -0400 Received: by ggnr5 with SMTP id r5so1332440ggn.19 for ; Mon, 01 Oct 2012 04:51:47 -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=NoZW55j4S9uiJ5xr7zF6ApheMjsEqtwiJoJUDqqe6Q4=; b=ZYPn6V5yIy3zxo9gF6zyKgRG3++rcejb1YIo2XY5aYP4fN1kT3JZBKQMJcVME08dD/ nbqqJb3IR0gEYR5uZL7p4mSjhJ51utTl0P0Kj2Ml3ipsCCY4vMTgYKzXQ1MwErPvsXGz DKOY8kOsf8uCgle764GF8R6Db9knm/SxO8CQYaZqzZLJhvCgLdtrErY4pZIpkzHHpBKh HNWih0hInonWJXMTYeh6Kxl471eHUVJdgugOXronM98+dliZLHaLycF8YORVkUN87zFe sSfRpqYaa/2T4nrLCV+VlP5RqkVkJuzwlqBnyuOS3IQczh59WDGYYAndUJwlSdKG4ek1 Hm3Q== Received: by 10.236.193.71 with SMTP id j47mr14539012yhn.79.1349092307753; Mon, 01 Oct 2012 04:51:47 -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 v8sm25257786yhi.15.2012.10.01.04.51.46 (version=SSLv3 cipher=OTHER); Mon, 01 Oct 2012 04:51:47 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, bharrosh@panasas.com, steved@redhat.com, skinsbursky@parallels.com Subject: [PATCH 2/2] nfsd: change algorithm for selecting the client_tracking_ops Date: Mon, 1 Oct 2012 07:51:38 -0400 Message-Id: <1349092298-23872-3-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1349092298-23872-1-git-send-email-jlayton@redhat.com> References: <1349092298-23872-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQl8ZO7vUdjPgo3wNOlbwkMr9CDDgXNxMulPS55Ml0sX/ip9JguFcZYXaQvSdF04UTI1J//P Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the legacy tracking dir exists, use that. Next try the usermodehelper upcall. It should succeed or fail quickly, so trying it first should be harmless. If that fails, 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 d8e07d5..3584313 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -1067,17 +1067,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; + + /* + * 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; } + /* + * Next, 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; + + /* 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 "