From patchwork Mon Jun 30 15:49:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4451461 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 BD49B9F358 for ; Mon, 30 Jun 2014 15:51:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF00520379 for ; Mon, 30 Jun 2014 15:51:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3F38201C0 for ; Mon, 30 Jun 2014 15:51:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754674AbaF3Pv2 (ORCPT ); Mon, 30 Jun 2014 11:51:28 -0400 Received: from mail-qc0-f169.google.com ([209.85.216.169]:49496 "EHLO mail-qc0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750897AbaF3Pv2 (ORCPT ); Mon, 30 Jun 2014 11:51:28 -0400 Received: by mail-qc0-f169.google.com with SMTP id c9so7251938qcz.14 for ; Mon, 30 Jun 2014 08:51:27 -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=kquZiKQ6cgBTXdOgMoiXfdDhOdNBrMpnSBzHOUkKj0A=; b=SyiQCTD4sjlllYi7axx0frUZaeVHNqpt83eFYw4UQTzfTu787okvQXacCASRGMVvwF 0WyP4DMsFVvjI6MdfllyXmgU4blcXPLG2YtMou1KwsGszkPjJWkKPTi+/6n90bNhQ0I0 OvJ5MrIqHvbaK1Ei2sLRgzGglXQcf7ZtWssl80I2ZEzrfj/OLzWKR17zl+RxpwFs1cu1 Asp93Yr4ewRA97OuzjL2HKPcHLUy2FuIaFhVLLAGQw3r0C0ka6sAZ7Z9xbujb66xNB6N LeJ1mKjvJJtBQtDImFf0japtjNJdbpYehx9gxdQPnZb9+kVIKC3FDoVXok+AzY1P8Fbt mFpw== X-Gm-Message-State: ALoCoQmC4n10M42iLuDfxjd0JNiM8fKV9B0W0+nKZ7rh5PcnURP1/jPNVauk9VV6sqJmLKNhsmMC X-Received: by 10.140.40.81 with SMTP id w75mr59018223qgw.112.1404143487653; Mon, 30 Jun 2014 08:51:27 -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.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jun 2014 08:51:26 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH v3 039/114] nfsd: Ensure stateids remain unique until they are freed Date: Mon, 30 Jun 2014 11:49:08 -0400 Message-Id: <1404143423-24381-40-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 Add an extra delegation state to allow the stateid to remain in the idr tree until the last reference has been released. This will be necessary to ensure uniqueness once the client_mutex is removed. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 8 +++++--- fs/nfsd/state.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 0d62692b525b..902e5f54c166 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -596,6 +596,7 @@ static void remove_stid(struct nfs4_stid *s) static void nfs4_free_stid(struct kmem_cache *slab, struct nfs4_stid *s) { + remove_stid(s); if (s->sc_file) put_nfs4_file(s->sc_file); kmem_cache_free(slab, s); @@ -666,7 +667,7 @@ unhash_delegation(struct nfs4_delegation *dp) static void destroy_delegation(struct nfs4_delegation *dp) { - remove_stid(&dp->dl_stid); + dp->dl_stid.sc_type = NFS4_CLOSED_DELEG_STID; nfs4_put_delegation(dp); } @@ -679,7 +680,7 @@ static void unhash_and_destroy_delegation(struct nfs4_delegation *dp) static void destroy_revoked_delegation(struct nfs4_delegation *dp) { list_del_init(&dp->dl_recall_lru); - destroy_delegation(dp); + nfs4_put_delegation(dp); } static void revoke_delegation(struct nfs4_delegation *dp) @@ -854,7 +855,6 @@ static void put_generic_stateid(struct nfs4_ol_stateid *stp) { if (!atomic_dec_and_test(&stp->st_stid.sc_count)) return; - remove_stid(&stp->st_stid); nfs4_free_stid(stateid_slab, &stp->st_stid); } @@ -4029,7 +4029,9 @@ static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid) return nfs_ok; default: printk("unknown stateid type %x\n", s->sc_type); + /* Fallthrough */ case NFS4_CLOSED_STID: + case NFS4_CLOSED_DELEG_STID: return nfserr_bad_stateid; } } diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 722adb4e144b..95d04fae365a 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -81,6 +81,7 @@ struct nfs4_stid { #define NFS4_CLOSED_STID 8 /* For a deleg stateid kept around only to process free_stateid's: */ #define NFS4_REVOKED_DELEG_STID 16 +#define NFS4_CLOSED_DELEG_STID 32 unsigned char sc_type; stateid_t sc_stateid; struct nfs4_client *sc_client;