From patchwork Wed Jul 11 20:29:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 1185291 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 2699C3FC8F for ; Wed, 11 Jul 2012 20:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754248Ab2GKU37 (ORCPT ); Wed, 11 Jul 2012 16:29:59 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:50255 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752538Ab2GKU36 (ORCPT ); Wed, 11 Jul 2012 16:29:58 -0400 Received: by gglu4 with SMTP id u4so1697031ggl.19 for ; Wed, 11 Jul 2012 13:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=w8V5oOw9QLPDmg4gIIdbtu/b43Q7DzLratPriO2TjI0=; b=tOzOdMDL0euy/qw81GJ0C9rZ+7oUrn43tv73B7z3j4WUsSEzd2wUoP4VZi+5OIMECQ tz90jfqZfs1KP7+qmzKwpKjcNpJh3/POBmrKsbxLRbHMa0nL0z4HsPAvJU4y96j9+F/Q i9bsg+m+uVor5ntZbxk6OB6fSvNINm7JzeZr+pwvl3boXTfbTW/GF0e1lsMzooaV/Vj1 2Rq1nVH1FEibqnNz9jPcmF9gndNGA0/+cafEniRP+NXBWmZY3itLLF9/yQv25dZLgzig QiP2KjVQf/pIMmoiHMDSKHbHsXMiU+10jMjouYmaC/mh9f75xx0YQho3OgctNN2aJXw1 X5tw== Received: by 10.50.160.234 with SMTP id xn10mr15482889igb.61.1342038597839; Wed, 11 Jul 2012 13:29:57 -0700 (PDT) Received: from degas.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net. [99.26.161.222]) by mx.google.com with ESMTPS id pp4sm4847459igb.5.2012.07.11.13.29.56 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Jul 2012 13:29:57 -0700 (PDT) From: Chuck Lever Subject: [PATCH 02/15] NFS: Don't free a state ID the server does not recognize To: trond.myklebust@netapp.com Cc: linux-nfs@vger.kernel.org Date: Wed, 11 Jul 2012 16:29:56 -0400 Message-ID: <20120711202955.3767.78152.stgit@degas.1015granger.net> In-Reply-To: <20120711201718.3767.66867.stgit@degas.1015granger.net> References: <20120711201718.3767.66867.stgit@degas.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The result of a TEST_STATEID operation can indicate a few different things: o If NFS_OK is returned, then the client can continue using the state ID under test, and skip recovery. o RFC 5661 says that if the state ID was revoked, then the client must perform an explicit FREE_STATEID before trying to re-open. o If the server doesn't recognize the state ID at all, then no FREE_STATEID is needed, and the client can immediately continue with open recovery. Let's err on the side of caution: if the server clearly tells us the state ID is unknown, we skip the FREE_STATEID. For any other error, we issue a FREE_STATEID. Sometimes that FREE_STATEID will be unnecessary, but leaving unused state IDs on the server needlessly ties up resources. Signed-off-by: Chuck Lever --- fs/nfs/nfs4proc.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 9a0397c..2986e65 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1764,7 +1764,8 @@ static int nfs41_check_expired_stateid(struct nfs4_state *state, nfs4_stateid *s if (state->flags & flags) { status = nfs41_test_stateid(server, stateid); if (status != NFS_OK) { - nfs41_free_stateid(server, stateid); + if (status != -NFS4ERR_BAD_STATEID) + nfs41_free_stateid(server, stateid); state->flags &= ~flags; } } @@ -4708,7 +4709,9 @@ static int nfs41_check_expired_locks(struct nfs4_state *state) if (lsp->ls_flags & NFS_LOCK_INITIALIZED) { status = nfs41_test_stateid(server, &lsp->ls_stateid); if (status != NFS_OK) { - nfs41_free_stateid(server, &lsp->ls_stateid); + if (status != -NFS4ERR_BAD_STATEID) + nfs41_free_stateid(server, + &lsp->ls_stateid); lsp->ls_flags &= ~NFS_LOCK_INITIALIZED; ret = status; }