From patchwork Fri Oct 13 12:46:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 10004495 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 C52FB60216 for ; Fri, 13 Oct 2017 12:51:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B72B529072 for ; Fri, 13 Oct 2017 12:51:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8EDC29071; Fri, 13 Oct 2017 12:51: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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 4C41C29071 for ; Fri, 13 Oct 2017 12:51:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758341AbdJMMvC (ORCPT ); Fri, 13 Oct 2017 08:51:02 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:47454 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932292AbdJMMrz (ORCPT ); Fri, 13 Oct 2017 08:47:55 -0400 Received: by mail-wm0-f65.google.com with SMTP id t69so21256306wmt.2 for ; Fri, 13 Oct 2017 05:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TSCNDb1J4roTz83tCYP+3F2/uhllcUX7WOQ62TeT6sw=; b=o9nMiUZfGD0NELrai9oGQ3cbc7iHvM/xZdYvljMlYsoMhi7UHzjpvZ31lOJx/znyrJ syNXyFI4MxYIY0GcsjADRd8Xgp4aFJ5oMD20/QRSbcfgcy75WojODgfJ4CwhVulWnPXC +6N2jM/UaDaGMtxTNDWhwiAhx242FucHy9jL8= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=TSCNDb1J4roTz83tCYP+3F2/uhllcUX7WOQ62TeT6sw=; b=p54GU2cEws+kVjICvpivkOX0GrhxDChNzMBuIYu6H/mo+zrYZkxZBLTSGhA5549c2F TTbHrhAStjzuhnhlTE6Yd1Q1B0+eDpkmaNztwTf0xu7tVk20qFrlBhv5+hANfYOVYpRA PVYDtom0CiVaf6k+HCYd+OlLOsEgBbxZjooZu893yts+pMy+gHDEluZB2NoUNCJo8Px+ w2eWp49FnxZT/FkmlTL35nG829zZ/sq5yOr2xW+jl7fW+KcgNHLuSmg9PEgSPdTGhjIG +Y9JUgMVZkSWc9mdiwW7kQ4HIcstuWZYtP6tUbIXGDyJGHH1vwUrUfwCDmSWfsRdqKhp 87Gg== X-Gm-Message-State: AMCzsaXvA3CFQX5/clZ3EEB6mwaV7khr4rc1wp6sWyejW11X5VinaeSC MIDibOymTbhFniKcw0t7+3e10FHK X-Google-Smtp-Source: AOwi7QA0xuL1Z6sIAQfCYIclCRls/kgmPYuV60vgCJOJ7ei72rrbp4xTLo+G2TadqJWNRDdt2+W1vw== X-Received: by 10.80.205.86 with SMTP id d22mr1712910edj.7.1507898874234; Fri, 13 Oct 2017 05:47:54 -0700 (PDT) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id p91sm735012edp.69.2017.10.13.05.47.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:53 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 50/58] lightnvm: pblk: shut down gc gracefully during exit Date: Fri, 13 Oct 2017 14:46:39 +0200 Message-Id: <20171013124647.32668-51-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171013124647.32668-1-m@bjorling.me> References: <20171013124647.32668-1-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Holmberg Shut down the GC workqueues and tasks in the right order. Signed-off-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-gc.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c index 4bac9e1..e00e5a0 100644 --- a/drivers/lightnvm/pblk-gc.c +++ b/drivers/lightnvm/pblk-gc.c @@ -422,10 +422,15 @@ void pblk_gc_kick(struct pblk *pblk) { struct pblk_gc *gc = &pblk->gc; - wake_up_process(gc->gc_ts); pblk_gc_writer_kick(gc); pblk_gc_reader_kick(gc); - mod_timer(&gc->gc_timer, jiffies + msecs_to_jiffies(GC_TIME_MSECS)); + + /* If we're shutting down GC, let's not start it up again */ + if (gc->gc_enabled) { + wake_up_process(gc->gc_ts); + mod_timer(&gc->gc_timer, + jiffies + msecs_to_jiffies(GC_TIME_MSECS)); + } } static void pblk_gc_timer(unsigned long data) @@ -630,9 +635,6 @@ void pblk_gc_exit(struct pblk *pblk) { struct pblk_gc *gc = &pblk->gc; - flush_workqueue(gc->gc_reader_wq); - flush_workqueue(gc->gc_line_reader_wq); - gc->gc_enabled = 0; del_timer_sync(&gc->gc_timer); pblk_gc_stop(pblk, 1); @@ -640,15 +642,17 @@ void pblk_gc_exit(struct pblk *pblk) if (gc->gc_ts) kthread_stop(gc->gc_ts); + if (gc->gc_reader_ts) + kthread_stop(gc->gc_reader_ts); + + flush_workqueue(gc->gc_reader_wq); if (gc->gc_reader_wq) destroy_workqueue(gc->gc_reader_wq); + flush_workqueue(gc->gc_line_reader_wq); if (gc->gc_line_reader_wq) destroy_workqueue(gc->gc_line_reader_wq); if (gc->gc_writer_ts) kthread_stop(gc->gc_writer_ts); - - if (gc->gc_reader_ts) - kthread_stop(gc->gc_reader_ts); }