From patchwork Sat Sep 17 05:13:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9336973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE4266077F for ; Sat, 17 Sep 2016 05:13:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE71F29FBE for ; Sat, 17 Sep 2016 05:13:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C30D929FCF; Sat, 17 Sep 2016 05:13:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F26629FBE for ; Sat, 17 Sep 2016 05:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753826AbcIQFNs (ORCPT ); Sat, 17 Sep 2016 01:13:48 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:35268 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755337AbcIQFNp (ORCPT ); Sat, 17 Sep 2016 01:13:45 -0400 Received: by mail-io0-f195.google.com with SMTP id q92so2389719ioi.2 for ; Fri, 16 Sep 2016 22:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=u7QsKceUlYc87XL0aiQzNZemWcghBtiydh9pflXCmkA=; b=VMBr7kCygB6JnZMHyE5Ae6UpwwYlONtgEm7fNxGLX3WHCMiJzxycBgCsn9qsQrgJ3Z PBtlj+olPzc4kcUyYqo4MNKQFbH4q+AhG8wE+cLpVEuydnRQrYhRuz9G2WXUk8NmTh3+ Ni1tlFEplVwf/y4UPxgCEE/uzpRPtGhP4G2itJELE3rV/4bpWXCinA1pztQZNoWXC0kS /DH0/X92Mev4XxHJmt3q12GeMDEiGhxuqM5keTPWZ8Uv5wwq2NgC3T5WNk2SmyXCbEr0 G+9XTzyVxE/y4mVTUajHy2IC1h1PkkV27oQDAblVmgeLE/t4IAfTi8ZD7Agnj5OfChj6 jQ4Q== 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=u7QsKceUlYc87XL0aiQzNZemWcghBtiydh9pflXCmkA=; b=aw2ZGT74iOjyZtazkB/ZxE0grmOjZCpeIiOmamMGfNVMtHi6TUy9PEAOAVJqDTHHNq +pMJZIy+C05Qj77hCgQcWNqi9+lNsD7r0JOY1AvHW3YuxNewCAR1rhqS0/YM3ppMtoeH g4VZGURsl/IGEQwQyDoxqEPqbITzHYvFMgCzoyWCgJL7YUGWZ0qnU4hJptqOwQayPdFY a6HLevjVWlrasdDLSfCz2FS8rIPZhfbSoAzcesrti/3GfDOG7N5flMcLER/9dPY1XcGo cjjjFxCTf9lbqSMU11YVmQHjf1WtmAiC9twdswPMxNgyFkLKCNbLJ5/ZlmTDs696WC5V 3cWA== X-Gm-Message-State: AE9vXwMmxbue8RfhmzdXdefRmnCRRRaWThYZevWv2rwrpB650woyFLQldZPr2zCyHYKKoQ== X-Received: by 10.107.191.196 with SMTP id p187mr27980928iof.131.1474089224939; Fri, 16 Sep 2016 22:13:44 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id d15sm4993916ioj.19.2016.09.16.22.13.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Sep 2016 22:13:44 -0700 (PDT) From: Trond Myklebust To: anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org, Oleg Drokin Subject: [PATCH v5 10/25] NFSv4.1: Allow revoked stateids to skip the call to TEST_STATEID Date: Sat, 17 Sep 2016 01:13:18 -0400 Message-Id: <1474089213-104014-11-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474089213-104014-10-git-send-email-trond.myklebust@primarydata.com> References: <1474089213-104014-1-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-2-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-3-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-4-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-5-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-6-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-7-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-8-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-9-git-send-email-trond.myklebust@primarydata.com> <1474089213-104014-10-git-send-email-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some cases (e.g. when the SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED sequence flag is set) we may already know that the stateid was revoked and that the only valid operation we can call is FREE_STATEID. In those cases, allow the stateid to carry the information in the type field, so that we skip the redundant call to TEST_STATEID. --- fs/nfs/nfs4proc.c | 32 +++++++++++++++++++++++--------- include/linux/nfs4.h | 1 + 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 97a614370604..3c1b8cb7dd95 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2422,18 +2422,29 @@ static int nfs41_test_and_free_expired_stateid(struct nfs_server *server, { int status; - status = nfs41_test_stateid(server, stateid, cred); + switch (stateid->type) { + default: + break; + case NFS4_INVALID_STATEID_TYPE: + case NFS4_SPECIAL_STATEID_TYPE: + return -NFS4ERR_BAD_STATEID; + case NFS4_REVOKED_STATEID_TYPE: + goto out_free; + } + status = nfs41_test_stateid(server, stateid, cred); switch (status) { case -NFS4ERR_EXPIRED: case -NFS4ERR_ADMIN_REVOKED: case -NFS4ERR_DELEG_REVOKED: - /* Ack the revoked state to the server */ - nfs41_free_stateid(server, stateid, cred); - case -NFS4ERR_BAD_STATEID: + break; + default: return status; } - return NFS_OK; +out_free: + /* Ack the revoked state to the server */ + nfs41_free_stateid(server, stateid, cred); + return -NFS4ERR_EXPIRED; } static void nfs41_check_delegation_stateid(struct nfs4_state *state) @@ -2468,7 +2479,7 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state) rcu_read_unlock(); status = nfs41_test_and_free_expired_stateid(server, &stateid, cred); trace_nfs4_test_delegation_stateid(state, NULL, status); - if (status != NFS_OK) + if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID) nfs_finish_clear_delegation_stateid(state, &stateid); put_rpccred(cred); @@ -2497,7 +2508,7 @@ static int nfs41_check_open_stateid(struct nfs4_state *state) status = nfs41_test_and_free_expired_stateid(server, stateid, cred); trace_nfs4_test_open_stateid(state, NULL, status); - if (status != NFS_OK) { + if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID) { clear_bit(NFS_O_RDONLY_STATE, &state->flags); clear_bit(NFS_O_WRONLY_STATE, &state->flags); clear_bit(NFS_O_RDWR_STATE, &state->flags); @@ -6124,7 +6135,7 @@ out: */ static int nfs41_check_expired_locks(struct nfs4_state *state) { - int status, ret = -NFS4ERR_BAD_STATEID; + int status, ret = NFS_OK; struct nfs4_lock_state *lsp; struct nfs_server *server = NFS_SERVER(state->inode); @@ -6136,9 +6147,12 @@ static int nfs41_check_expired_locks(struct nfs4_state *state) &lsp->ls_stateid, cred); trace_nfs4_test_lock_stateid(state, lsp, status); - if (status != NFS_OK) { + if (status == -NFS4ERR_EXPIRED || + status == -NFS4ERR_BAD_STATEID) clear_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags); + else if (status != NFS_OK) { ret = status; + break; } } }; diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index c6564ada9beb..9094faf0699d 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -67,6 +67,7 @@ struct nfs4_stateid_struct { NFS4_DELEGATION_STATEID_TYPE, NFS4_LAYOUT_STATEID_TYPE, NFS4_PNFS_DS_STATEID_TYPE, + NFS4_REVOKED_STATEID_TYPE, } type; };