From patchwork Thu May 3 18:57:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 10378989 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 310F460159 for ; Thu, 3 May 2018 18:58:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EE392924F for ; Thu, 3 May 2018 18:58:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1382929254; Thu, 3 May 2018 18:58:50 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 8BFFB2924F for ; Thu, 3 May 2018 18:58:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751412AbeECS6r (ORCPT ); Thu, 3 May 2018 14:58:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:44776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751178AbeECS6J (ORCPT ); Thu, 3 May 2018 14:58:09 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 4424321784; Thu, 3 May 2018 18:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1525373888; bh=liWuXekvE5dagVNfdFKmhxRbLn8HIurrhRC6FDf85+k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LL+0sLThZi35nv96L0o869YMwdX+L/1HiZtwQv1jrQ3SKOJfj68r9KaTp94doA9Lm aRYEi/Bz77CUV8fNyYPe6aXAlPUVIFDH7dsVrCzoLOoTBn59rjRUqCRnyBCjX4H2s+ K3hWYObtLzo8NGkWcUCZbP4LEJu0RLIJ8nxCwlLI= From: Jeff Layton To: devel@lists.nfs-ganesha.org, ceph-devel@vger.kernel.org Subject: [nfs-ganesha RFC PATCH v2 06/13] SAL: add recovery operation to maybe start a grace period Date: Thu, 3 May 2018 14:57:56 -0400 Message-Id: <20180503185803.25417-7-jlayton@kernel.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180503185803.25417-1-jlayton@kernel.org> References: <20180503185803.25417-1-jlayton@kernel.org> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff Layton Add a new maybe_start_grace operation that will check to see if a sibling has requested a grace period and start one if so. Call this function from the reaper thread. Note that we only enforce the grace period and do not reload the recovery db. All of the current node's state is still intact, so we don't need to initiate any reclaim; only enforce the grace period until the other node's reclaim is complete. Change-Id: I85f54907efb220510af0b87baa1798d3f1d7a041 Signed-off-by: Jeff Layton --- src/MainNFSD/nfs_reaper_thread.c | 3 +++ src/SAL/nfs4_recovery.c | 15 +++++++++++++++ src/include/sal_functions.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/src/MainNFSD/nfs_reaper_thread.c b/src/MainNFSD/nfs_reaper_thread.c index 918a3b7f4256..07ef670810fd 100644 --- a/src/MainNFSD/nfs_reaper_thread.c +++ b/src/MainNFSD/nfs_reaper_thread.c @@ -203,6 +203,9 @@ static void reaper_run(struct fridgethr_context *ctx) SetNameFunction("reaper"); + /* see if we need to start a grace period */ + nfs_maybe_start_grace(); + /* * Try to lift the grace period, unless we're shutting down. * Ordinarily, we'd take the mutex to check this, but this is just a diff --git a/src/SAL/nfs4_recovery.c b/src/SAL/nfs4_recovery.c index 120819e621c9..cc4f7cf9facf 100644 --- a/src/SAL/nfs4_recovery.c +++ b/src/SAL/nfs4_recovery.c @@ -198,6 +198,21 @@ bool nfs_in_grace(void) return atomic_fetch_time_t(¤t_grace); } +/** + * @brief Enter the grace period if another node in the cluster needs it + * + * Singleton servers generally won't use this operation. Clustered servers + * call this function to check whether another node might need a grace period. + */ +void nfs_maybe_start_grace(void) +{ + if (recovery_backend->maybe_start_grace) { + if (nfs_in_grace()) + return; + recovery_backend->maybe_start_grace(); + } +} + void nfs_try_lift_grace(void) { bool in_grace = true; diff --git a/src/include/sal_functions.h b/src/include/sal_functions.h index 7e30e51eeabf..2829f574c8e7 100644 --- a/src/include/sal_functions.h +++ b/src/include/sal_functions.h @@ -976,6 +976,7 @@ void blocked_lock_polling(struct fridgethr_context *ctx); void nfs_start_grace(nfs_grace_start_t *gsp); bool nfs_in_grace(void); bool simple_try_lift_grace(void); +void nfs_maybe_start_grace(void); void nfs_try_lift_grace(void); void nfs4_add_clid(nfs_client_id_t *); void nfs4_rm_clid(nfs_client_id_t *); @@ -1023,6 +1024,7 @@ struct nfs4_recovery_backend { void (*add_clid)(nfs_client_id_t *); void (*rm_clid)(nfs_client_id_t *); void (*add_revoke_fh)(nfs_client_id_t *, nfs_fh4 *); + void (*maybe_start_grace)(void); bool (*try_lift_grace)(void); };