From patchwork Mon Jun 30 15:49:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4451531 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 501AF9F358 for ; Mon, 30 Jun 2014 15:51:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7550C201C0 for ; Mon, 30 Jun 2014 15:51:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92FE32021A for ; Mon, 30 Jun 2014 15:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754691AbaF3Pvi (ORCPT ); Mon, 30 Jun 2014 11:51:38 -0400 Received: from mail-qg0-f48.google.com ([209.85.192.48]:57086 "EHLO mail-qg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750897AbaF3Pvi (ORCPT ); Mon, 30 Jun 2014 11:51:38 -0400 Received: by mail-qg0-f48.google.com with SMTP id q108so2126497qgd.21 for ; Mon, 30 Jun 2014 08:51:37 -0700 (PDT) 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 :in-reply-to:references; bh=WOYiB1ATLRhQ2srsQrG+kW4GGqwbTrFNWIdzOEes1W4=; b=GzXiy6fZRRmKsaXeKa4721qKbx6dIL2+23mw+QsVi+LsPUzvY396Gi43ObO5Jvpim8 4mkrqJzq3qV/6+yp2BdED+rO7wUvGt3UeYZphjzC2v4mdp0IemhYSsaTnDxAmd7elgYp 9LHEXiQhGby/uzqGkgtOu+LwfnA+n3ujTOlEkQG2pqCcZAoPfQ2yFgH8dRgukg+MNFxa OLMrjcF4FqiLrmSCogZVxFMwravNrkXtAWxlU8Gdpqq/Qw+xMd08dQ5PTz/p0tXL174V ByxALPlrHOWtCqn4howDvBX+Nze3l4R3ENHwb31ABVRjXRDZHaFLmtzug3vTldvieMXY SO9w== X-Gm-Message-State: ALoCoQnUVlsZ8izei6Te2EOBQXNim+NOUs06q47oGmpWDnMiWh+FM8OJ7JlmvwgMs4NEExa2Hmha X-Received: by 10.140.98.35 with SMTP id n32mr59785476qge.111.1404143497486; Mon, 30 Jun 2014 08:51:37 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id m1sm32584105qaz.27.2014.06.30.08.51.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jun 2014 08:51:36 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH v3 046/114] nfsd: Slight cleanup of find_stateid() Date: Mon, 30 Jun 2014 11:49:15 -0400 Message-Id: <1404143423-24381-47-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1404143423-24381-1-git-send-email-jlayton@primarydata.com> References: <1404143423-24381-1-git-send-email-jlayton@primarydata.com> 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, 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 From: Trond Myklebust In preparation of reference counting. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index f5865a8e3081..54c9631a602c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1660,28 +1660,37 @@ static void gen_confirm(struct nfs4_client *clp) memcpy(clp->cl_confirm.data, verf, sizeof(clp->cl_confirm.data)); } -static struct nfs4_stid *find_stateid(struct nfs4_client *cl, stateid_t *t) +static struct nfs4_stid * +find_stateid_locked(struct nfs4_client *cl, stateid_t *t) { struct nfs4_stid *ret; - spin_lock(&cl->cl_lock); ret = idr_find(&cl->cl_stateids, t->si_opaque.so_id); - spin_unlock(&cl->cl_lock); if (!ret || !ret->sc_type) return NULL; return ret; } +static struct nfs4_stid *find_stateid(struct nfs4_client *cl, stateid_t *t) +{ + struct nfs4_stid *ret; + + spin_lock(&cl->cl_lock); + ret = find_stateid_locked(cl, t); + spin_unlock(&cl->cl_lock); + return ret; +} + static struct nfs4_stid *find_stateid_by_type(struct nfs4_client *cl, stateid_t *t, char typemask) { struct nfs4_stid *s; - s = find_stateid(cl, t); - if (!s) - return NULL; - if (typemask & s->sc_type) - return s; - return NULL; + spin_lock(&cl->cl_lock); + s = find_stateid_locked(cl, t); + if (s != NULL && !(typemask & s->sc_type)) + s = NULL; + spin_unlock(&cl->cl_lock); + return s; } static struct nfs4_client *create_client(struct xdr_netobj name,