From patchwork Thu Oct 4 18:45:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10626497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1511315E2 for ; Thu, 4 Oct 2018 18:45:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0F8E28CE4 for ; Thu, 4 Oct 2018 18:45:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1C002954E; Thu, 4 Oct 2018 18:45:01 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 7630828CE4 for ; Thu, 4 Oct 2018 18:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727545AbeJEBjb (ORCPT ); Thu, 4 Oct 2018 21:39:31 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:36831 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727614AbeJEBjb (ORCPT ); Thu, 4 Oct 2018 21:39:31 -0400 Received: by mail-yw1-f67.google.com with SMTP id e201-v6so4205733ywa.3 for ; Thu, 04 Oct 2018 11:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=a2J+FkNvYaoS8vZuHfq59M/E4hjCk6fk1x6YRy/jiz4=; b=DTGRqeDFRHjv2Pou/BzmI3OMhYLp3Z8C/+M2ePC3dtzVoPFyGilITMWWQORDYtWKrE EF90OHhF/PgN3cdXJ6EtS1S25CR1WMI7MXey1RZdNoWghwB6JzvMz2Y3e1XO8smrErwu jkHhw6S5fOy7odK+Cq19+GJa/DqMW5TbIHyLUMhompHDMlrzfHe2TpYY41NXkG7QAKSo rAGuRdlEQelgk5QExrFM9lm6sIzp9M751/kf/Zp0Dx8w2IbUweg0wPRWV9uyqxEd3EIl TcfIxMLG0RyowxQsZM6oWwF8dqOtm5S10bYc2IIj9CSuy+5fRbFu4LxUGVQ3LNkrQ3ED rk9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=a2J+FkNvYaoS8vZuHfq59M/E4hjCk6fk1x6YRy/jiz4=; b=VpbSHbgeMdFimne9omD+mMKItcJTTCtAES4yKIvgbbIvKnp0asQmbLXxsrQq1UtjtJ f8MpPBIlAhOzz4EJ450RZnMMFjsK4r0ZPBSVyRrfOM4GvlXFeic/FnoBf21eIVDp19Zj ocdMz22l1YfS7Inc30AE3kMiwDyRR9riTwi2m0luqAv15CABDojjILP4cRtWqCVMmKLJ t1b3gufgBwzWpDWf6Xhw03GqIRMXsVlviZraPihG/mHf0/g6pC9JhPK/vs7Dj4QgcIdg KFwjWmH9sw4QgzBUUGEOjckvb59QWeNreY8TpYDXG1b0hy3SxqiaxxIPlqNFjSxYWN1h SZUQ== X-Gm-Message-State: ABuFfogoH92GOrMsX52fitx/q11xGQpRjZKCILWBuF2INMDpyf7kzs4G iqBWwthjfDRDXhTPmDPzCFVINPc1 X-Google-Smtp-Source: ACcGV63Zygk49RQbCIW3VPi+i/TodIDlkYPkNfjhnGofsIL4gZMch44G9RgIMxxPkKGP4rAFMibJCg== X-Received: by 2002:a0d:eb82:: with SMTP id u124-v6mr4525797ywe.40.1538678699313; Thu, 04 Oct 2018 11:44:59 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id q11-v6sm2029625ywb.44.2018.10.04.11.44.58 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 04 Oct 2018 11:44:58 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/1] NFSv4.x: fix lock recovery during delegation recall Date: Thu, 4 Oct 2018 14:45:00 -0400 Message-Id: <20181004184500.14403-1-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) 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 From: Olga Kornievskaia 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 --- 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 76d205d..07b8395 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -93,7 +93,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; @@ -108,7 +108,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); @@ -156,7 +156,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);