From patchwork Thu Mar 6 05:50:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 3781391 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A4212BF540 for ; Thu, 6 Mar 2014 05:50:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1B0E201CE for ; Thu, 6 Mar 2014 05:50:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B86B9201C7 for ; Thu, 6 Mar 2014 05:50:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750859AbaCFFuN (ORCPT ); Thu, 6 Mar 2014 00:50:13 -0500 Received: from cantor2.suse.de ([195.135.220.15]:46863 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbaCFFuM (ORCPT ); Thu, 6 Mar 2014 00:50:12 -0500 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 06EBFACC4; Thu, 6 Mar 2014 05:50:11 +0000 (UTC) Date: Thu, 6 Mar 2014 16:50:04 +1100 From: NeilBrown To: Trond Myklebust Cc: linux-nfs@vger.kernel.org Subject: Re: [PATCH 4/8] sunrpc/auth: add 'rcu_walk' arg to rpc_lookup_cred. Message-ID: <20140306165004.46c0d59e@notabene.brown> In-Reply-To: References: <20140305025813.27421.23871.stgit@notabene.brown> <20140305030028.27421.14840.stgit@notabene.brown> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; x86_64-suse-linux-gnu) Mime-Version: 1.0 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, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable 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 On Wed, 5 Mar 2014 09:43:03 -0500 Trond Myklebust wrote: > > On Mar 4, 2014, at 22:00, NeilBrown wrote: > > > This arg causes rpc_lookup_cred to set RPCAUTH_LOOKUP_RCU when > > performing the credential lookup. Most callers pass '0', > > except nfs_permission() which passes (mask & MAY_NOT_BLOCK). > > > > Why not just add a function rpc_lookup_cred_rcu() or rpc_lookup_cred_noblock() to cater for that one exception? That certainly makes the patch smaller, and is probably a net win. Thanks. NeilBrown From b805a8f79a5527676b96b9654dd26d1b5bc03691 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 4 Mar 2014 15:28:43 +1100 Subject: [PATCH] sunrpc/auth: add rpc_lookup_cred_nonblock This version of rpc_lookup_cred sets RPCAUTH_LOOKUP_RCU when performing the credential lookup. nfs_permission() uses it in RCU-walk mode. This doesn't speed up nfs_permission yet as it is not yet safe to call nfs_do_access with the returned cred. Signed-off-by: NeilBrown diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 7530acdc5c42..ede873e88acc 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2318,10 +2318,12 @@ force_lookup: goto out_notsup; if (mask & MAY_NOT_BLOCK) - return -ECHILD; - - cred = rpc_lookup_cred(); + cred = rpc_lookup_cred_nonblock(); + else + cred = rpc_lookup_cred(); if (!IS_ERR(cred)) { + if (mask & MAY_NOT_BLOCK) + return -ECHILD; res = nfs_do_access(inode, cred, mask); put_rpccred(cred); } else diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index 3f158ae1d6fd..28ffc8476875 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h @@ -154,6 +154,7 @@ void rpc_destroy_generic_auth(void); void rpc_destroy_authunix(void); struct rpc_cred * rpc_lookup_cred(void); +struct rpc_cred * rpc_lookup_cred_nonblock(void); struct rpc_cred * rpc_lookup_machine_cred(const char *service_name); int rpcauth_register(const struct rpc_authops *); int rpcauth_unregister(const struct rpc_authops *); diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c index ed04869b2d4f..632f6eec8111 100644 --- a/net/sunrpc/auth_generic.c +++ b/net/sunrpc/auth_generic.c @@ -38,6 +38,11 @@ struct rpc_cred *rpc_lookup_cred(void) } EXPORT_SYMBOL_GPL(rpc_lookup_cred); +struct rpc_cred *rpc_lookup_cred_nonblock(void) +{ + return rpcauth_lookupcred(&generic_auth, 1); +} + /* * Public call interface for looking up machine creds. */