Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp14448pja; Fri, 22 Nov 2019 02:49:38 -0800 (PST) X-Google-Smtp-Source: APXvYqx7+0OfVpiR2wNEfRNyhjWD5/gSlhZaWEo/WR3XDrrZpeAttBBIsiR3/kF8A1TjnPmJ3FqQ X-Received: by 2002:a17:906:d9c4:: with SMTP id qk4mr20721301ejb.214.1574419778370; Fri, 22 Nov 2019 02:49:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574419778; cv=none; d=google.com; s=arc-20160816; b=wyBqk39rhsORkJVvf7QadOQPcUwGl18YoT7JqEofpWoEwh29jBwIMgBgdh8PRFpl7w MevCFYkd49LhjmZmGZm6qGfLHQXNzcPGjuNeAEVR8F68Fi3Hdv+gYI2AQ2TtGMubR/8I 5PhbglH5Y3Hdpq6Uu+XREFkP8lIEO3388A7CA4qChP5yzVtv4VZWlbp0CmiD3+PkBZLm jKFdALaylMMklXdZ3PeBPCVwck72jMCpwQTRDbb25q93gA3gvVjR0Gn+nrMxdo0dS6v8 QXlWeIClWvM0j3o4jM2GYgkod0H7d4Dm3GCoAnKwsZSORxWgbQImXrviHRbKSkylkzv+ fxBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x+CK57EWfu+h8A95EOkCaRgxzMnkvoUdEt4hLdWKt7k=; b=bp9Zs+Fs+hs8zMi0bJOCfGquaOYie0Ct+DOmIQEIpyrJrgWHr8UxjK2oVIVfvb1I/T meRSB/yNQ66tKfxj9PSoavPwITAX14anRaRj236eGF4F9jQa2+L1ACsyRJQdWcFREpqn F8EEFWKcYEURh39GxM/j0W8eC3Jj5MHrRw72LMhX5WF8gXTeTrZiXUtxydXUPY5DXscr xEb+f1QpHVHIqxSnpAs69I6cc2q/xC8tianBVXXqzXy2RhiHx0KjdvoOwEbNwT4NiIgc sOatFjaUxDVvnTkyqXCWcPlvv+nTjYRuOZI80ttFBM/BRxjDlcKPr2w2pYYqE2ZWQz9Z l9jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tU4V1d5g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si3873072ejw.281.2019.11.22.02.49.13; Fri, 22 Nov 2019 02:49:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tU4V1d5g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729809AbfKVKrs (ORCPT + 99 others); Fri, 22 Nov 2019 05:47:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:55892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727642AbfKVKrq (ORCPT ); Fri, 22 Nov 2019 05:47:46 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D08B620637; Fri, 22 Nov 2019 10:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574419665; bh=NKBfqAv6RndEcqs2ia5kpL1lCcer34AuTvHEDkQdefc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tU4V1d5gLVBP7EAL/PX5vZ3HONtc01dljn/j6QhyY/dzgyahB5GSa6UL2qzWz3ScU DZPn9gcHDZeGX+g6SW4XGZd2YDDLqms1OjIxhnQ3TovYEqHIJp290Doszl+hS4wRRv f5P6PtCdtZXc0t0hMyU9YGgci+HDW8XQeHQ9czu4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Olga Kornievskaia , Trond Myklebust , Sasha Levin Subject: [PATCH 4.9 190/222] NFSv4.x: fix lock recovery during delegation recall Date: Fri, 22 Nov 2019 11:28:50 +0100 Message-Id: <20191122100916.019304202@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100830.874290814@linuxfoundation.org> References: <20191122100830.874290814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Olga Kornievskaia [ Upstream commit 44f411c353bf6d98d5a34f8f1b8605d43b2e50b8 ] Running "./nfstest_delegation --runtest recall26" uncovers that client doesn't recover the lock when we have an appending open, where the initial open got a write delegation. Instead of checking for the passed in open context against the file lock's open context. Check that the state is the same. Signed-off-by: Olga Kornievskaia Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/delegation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 46afd7cdcc378..9a8830a0f31f9 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -101,7 +101,7 @@ int nfs4_check_delegation(struct inode *inode, fmode_t flags) return nfs4_do_check_delegation(inode, flags, false); } -static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid) +static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_stateid *stateid) { struct inode *inode = state->inode; struct file_lock *fl; @@ -116,7 +116,7 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_ spin_lock(&flctx->flc_lock); restart: list_for_each_entry(fl, list, fl_list) { - if (nfs_file_open_context(fl->fl_file) != ctx) + if (nfs_file_open_context(fl->fl_file)->state != state) continue; spin_unlock(&flctx->flc_lock); status = nfs4_lock_delegation_recall(fl, state, stateid); @@ -163,7 +163,7 @@ static int nfs_delegation_claim_opens(struct inode *inode, seq = raw_seqcount_begin(&sp->so_reclaim_seqcount); err = nfs4_open_delegation_recall(ctx, state, stateid, type); if (!err) - err = nfs_delegation_claim_locks(ctx, state, stateid); + err = nfs_delegation_claim_locks(state, stateid); if (!err && read_seqcount_retry(&sp->so_reclaim_seqcount, seq)) err = -EAGAIN; mutex_unlock(&sp->so_delegreturn_mutex); -- 2.20.1