From patchwork Wed Mar 5 18:30:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 3778371 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 F3965BF540 for ; Wed, 5 Mar 2014 18:30:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F0B320219 for ; Wed, 5 Mar 2014 18:30:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C95B2020F for ; Wed, 5 Mar 2014 18:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755283AbaCESaT (ORCPT ); Wed, 5 Mar 2014 13:30:19 -0500 Received: from mail-ie0-f178.google.com ([209.85.223.178]:41975 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752970AbaCESaS (ORCPT ); Wed, 5 Mar 2014 13:30:18 -0500 Received: by mail-ie0-f178.google.com with SMTP id lx4so1503021iec.9 for ; Wed, 05 Mar 2014 10:30:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QbUkDFSgAtI2Z2xbm1AWgl/w0z+AjP5zaUtt0A2imi0=; b=jmP7hl1kWNKVGHx4Ja9+t9myHksvm0e5vmPTfRjJpRnnuGOl8eKGWgYgjkqifPg+cK TE1oJrjCR6Cw/3wwZK8NQgfEfFIC3x86W3Ge4UfXLRkclwY0NJwsJlMtlk9rO279R95l e2NwLrmOXdrL2yAMweHvLU7HZmOigeDE0TiZnxTM1EDvPndX3kPZPGBXPQZjZbRmoimg 3zCauopYQWDzdb4XF48CNGnCqtgggyrgzT0I0nkckDIvDSnQls1XW8lsF68W58qHIyQK Y4i/agR9haffAYE8Av2ghZ4L4OUW1+ZeQ56UbfKwXauOreDb2v8cU8OHvEMJYcP/I6im SZXw== X-Gm-Message-State: ALoCoQl7rNXLwmKikwb6xxRFWsU4gVVi9751Ez10070NCHuuwPd7+3Wpbpb9qTgRVQ0AWcptDjRb X-Received: by 10.42.226.8 with SMTP id iu8mr5895052icb.7.1394044217927; Wed, 05 Mar 2014 10:30:17 -0800 (PST) Received: from leira.trondhjem.org (c-98-209-19-95.hsd1.mi.comcast.net. [98.209.19.95]) by mx.google.com with ESMTPSA id gd5sm15729716igd.5.2014.03.05.10.30.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Mar 2014 10:30:17 -0800 (PST) From: Trond Myklebust To: Andy Adamson Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 2/4] NFSv4: Fix the return value of nfs4_select_rw_stateid Date: Wed, 5 Mar 2014 13:30:09 -0500 Message-Id: <1394044211-22302-3-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1394044211-22302-2-git-send-email-trond.myklebust@primarydata.com> References: <1394028452-15956-1-git-send-email-trond.myklebust@primarydata.com> <1394044211-22302-1-git-send-email-trond.myklebust@primarydata.com> <1394044211-22302-2-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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 In commit 5521abfdcf4d6 (NFSv4: Resend the READ/WRITE RPC call if a stateid change causes an error), we overloaded the return value of nfs4_select_rw_stateid() to cause it to return -EWOULDBLOCK if an RPC call is outstanding that would cause the NFSv4 lock or open stateid to change. That is all redundant when we actually copy the stateid used in the read/write RPC call that failed, and check that against the current stateid. It is doubly so, when we consider that in the NFSv4.1 case, we also set the stateid's seqid to the special value '0', which means 'match the current valid stateid'. Reported-by: Andy Adamson Link: http://lkml.kernel.org/r/1393954269-3974-1-git-send-email-andros@netapp.com Signed-off-by: Trond Myklebust --- fs/nfs/nfs4state.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index e1a47217c05e..0deb32105ccf 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -974,9 +974,6 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst, else if (lsp != NULL && test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) != 0) { nfs4_stateid_copy(dst, &lsp->ls_stateid); ret = 0; - smp_rmb(); - if (!list_empty(&lsp->ls_seqid.list)) - ret = -EWOULDBLOCK; } spin_unlock(&state->state_lock); nfs4_put_lock_state(lsp); @@ -984,10 +981,9 @@ out: return ret; } -static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) +static void nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) { const nfs4_stateid *src; - int ret; int seq; do { @@ -996,12 +992,7 @@ static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) if (test_bit(NFS_OPEN_STATE, &state->flags)) src = &state->open_stateid; nfs4_stateid_copy(dst, src); - ret = 0; - smp_rmb(); - if (!list_empty(&state->owner->so_seqid.list)) - ret = -EWOULDBLOCK; } while (read_seqretry(&state->seqlock, seq)); - return ret; } /* @@ -1026,7 +1017,8 @@ int nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state, * choose to use. */ goto out; - ret = nfs4_copy_open_stateid(dst, state); + nfs4_copy_open_stateid(dst, state); + ret = 0; out: if (nfs_server_capable(state->inode, NFS_CAP_STATEID_NFSV41)) dst->seqid = 0;