From patchwork Thu Apr 18 13:24:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 10907287 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 AE17913B5 for ; Thu, 18 Apr 2019 13:24:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 949A228CFD for ; Thu, 18 Apr 2019 13:24:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92D2428C13; Thu, 18 Apr 2019 13:24:04 +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=-7.9 required=2.0 tests=BAYES_00,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 3F3C528CFD for ; Thu, 18 Apr 2019 13:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388263AbfDRNYD (ORCPT ); Thu, 18 Apr 2019 09:24:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56110 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733192AbfDRNYD (ORCPT ); Thu, 18 Apr 2019 09:24:03 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 325843088296; Thu, 18 Apr 2019 13:24:03 +0000 (UTC) Received: from coeurl.usersys.redhat.com (ovpn-121-236.rdu2.redhat.com [10.10.121.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 457F35D707; Thu, 18 Apr 2019 13:24:01 +0000 (UTC) Received: by coeurl.usersys.redhat.com (Postfix, from userid 1000) id C495820F52; Thu, 18 Apr 2019 09:24:00 -0400 (EDT) From: Scott Mayhew To: bfields@fieldses.org, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: CB_RECALL can race with FREE_STATEID Date: Thu, 18 Apr 2019 09:24:00 -0400 Message-Id: <20190418132400.24161-1-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 18 Apr 2019 13:24:03 +0000 (UTC) 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 While trying to track down some issues involving large numbers of delegations being recalled/revoked, I caught the server setting SEQ4_STATUS_CB_PATH_DOWN while the client was actively responding to CB_RECALLs. It turns out that the client had already done a TEST_STATEID and FREE_STATEID for a delegation being recalled by the time it received the CB_RECALL. Signed-off-by: Scott Mayhew --- fs/nfsd/nfs4state.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 6a45fb00c5fc..e88e429133a8 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3958,6 +3958,14 @@ static int nfsd4_cb_recall_done(struct nfsd4_callback *cb, rpc_delay(task, 2 * HZ); return 0; } + /* + * Race: client may have done a FREE_STATEID before + * receiving the CB_RECALL. + */ + if (dp->dl_stid.sc_type == NFS4_REVOKED_DELEG_STID && + refcount_read(&dp->dl_stid.sc_count) == 1 && + list_empty(&dp->dl_recall_lru)) + return 1; /*FALLTHRU*/ default: return -1;