From patchwork Fri Oct 2 11:18:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 7314781 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DFA3A9F1B9 for ; Fri, 2 Oct 2015 11:19:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1470920876 for ; Fri, 2 Oct 2015 11:19:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B06D62088B for ; Fri, 2 Oct 2015 11:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752068AbbJBLTL (ORCPT ); Fri, 2 Oct 2015 07:19:11 -0400 Received: from mail-qg0-f50.google.com ([209.85.192.50]:35893 "EHLO mail-qg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752287AbbJBLTG (ORCPT ); Fri, 2 Oct 2015 07:19:06 -0400 Received: by qgx61 with SMTP id 61so91441280qgx.3 for ; Fri, 02 Oct 2015 04:19:05 -0700 (PDT) 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; bh=JDoHuqs7UGTqId2CuwYPFIwxHd6SQoPZrPuSzIVlsAU=; b=l3KYlpL1T/Qf4rk6WVAW5VmJlG0TVUIcFfXsll4HKJAnQHM1/pviivdmbp17ZjRuCS vgV4TLCDcuDW9nvJer7723m1/qi5vtiZ63lMOaQ+el0cZQD0QDIJz3k8ZOkjzTcPgljD APDDW2nwZlX18agx6xHbwodY3UN/H0CXlHTKtiVOmMKO/Bwa72VS5VjAd//TrPsdhctG jD+UZnhPal5YPyWEEBT9mk8nPOKc8reo3BUR4WneNhN1L4m+/E4/ncJ5fpdk0iLirRel 9wgIMnu/I5JB6yfM0gMyJ3ujRtqbq6BHCjeAMXlNSjrjCzYXS9jZKH4K47aD6oFjpy6R iYEQ== X-Gm-Message-State: ALoCoQnHALia37iQbDse4ZM+sjbAr5b4cnY9Og/FHCUvjfc4l37EwsuoPzqwQTTuiPEsZCkYh3I6 X-Received: by 10.140.98.213 with SMTP id o79mr18156299qge.19.1443784745277; Fri, 02 Oct 2015 04:19:05 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:6079::d5a]) by smtp.googlemail.com with ESMTPSA id 52sm273877qgz.17.2015.10.02.04.19.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 04:19:04 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org, Anna Schumaker Subject: [RFC PATCH] nfs4: clear delegation from open states when returning delegation voluntarily Date: Fri, 2 Oct 2015 07:18:59 -0400 Message-Id: <1443784739-8565-1-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 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 When the client goes to return a delegation, it should always update any nfs4_state currently set up to use that delegation stateid to instead use the open stateid. It already does do this in some cases, particularly in the state recovery code, but not currently when the delegation is voluntarily returned (e.g. in advance of a RENAME). This causes the client to try to continue using the delegation stateid after the DELEGRETURN, e.g. in LAYOUTGET. This patch fixes this by ensuring to set the nfs4_state back to using the open stateid in nfs_delegation_claim_opens. That said, this code is quite difficult to follow and it's not 100% clear to me why the delegreturn handling and the state recovery code are squashed together like this. So, consider this an RFC patch and please let me know if there's a better way to fix this. Signed-off-by: Jeff Layton --- fs/nfs/delegation.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index be806ead7f4d..aba906c50e8e 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -147,6 +147,10 @@ again: if (!err && read_seqcount_retry(&sp->so_reclaim_seqcount, seq)) err = -EAGAIN; mutex_unlock(&sp->so_delegreturn_mutex); + write_seqlock(&state->seqlock); + nfs4_stateid_copy(&state->stateid, &state->open_stateid); + write_sequnlock(&state->seqlock); + clear_bit(NFS_DELEGATED_STATE, &state->flags); put_nfs_open_context(ctx); if (err != 0) return err;