From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2814DC43215 for ; Fri, 22 Nov 2019 11:02:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01A3E207FC for ; Fri, 22 Nov 2019 11:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574420542; bh=7SsdGD4WOsJjtaf7MN7dpjjJ99f9eq2oern7oSLinQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZoQtaW1QeyfhMch7z00yL5DAtJQH6NdgbXSL2S5hUGvsScioxbkUju1CNB9tNNPM1 Sxq0Xbarj4dX8qyj4Btu8o5OUsqmg/UunrlogzoGU0ZbWBQULqM+EYof7OqHoj6njh lckKQ3K/4rUVLtFBstZ2pT7nmwUVJomxOiwBhwEM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731288AbfKVLCV (ORCPT ); Fri, 22 Nov 2019 06:02:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:55642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731280AbfKVLCO (ORCPT ); Fri, 22 Nov 2019 06:02:14 -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 B6C522075B; Fri, 22 Nov 2019 11:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574420534; bh=7SsdGD4WOsJjtaf7MN7dpjjJ99f9eq2oern7oSLinQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+9na+/dgDgB3p+lz/aUXVNusPSBVTpBhwPJ8dIW4K3KV5hpbzSPyGiFkXmNA3Ghx 4gcjLEw/YbWNALqejAOZS0YWt9hiVCJcvMSm4yasAMYcNIwuxLP4q/rVYEiolQ9MvF kbCJkQlNTbUWAMe7LAn7+d+Nuxb0N9hTas+uVzD0= 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.19 122/220] NFSv4.x: fix lock recovery during delegation recall Date: Fri, 22 Nov 2019 11:28:07 +0100 Message-Id: <20191122100921.516933784@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100912.732983531@linuxfoundation.org> References: <20191122100912.732983531@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 c5c3394148f72..74ff459b75efa 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -103,7 +103,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; @@ -118,7 +118,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); @@ -165,7 +165,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); 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