From patchwork Tue Oct 3 10:05:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 9982109 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 6BF2A60365 for ; Tue, 3 Oct 2017 10:08:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68892201B1 for ; Tue, 3 Oct 2017 10:08:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D7B52888B; Tue, 3 Oct 2017 10:08:23 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable 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 E7C8D201B1 for ; Tue, 3 Oct 2017 10:08:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750983AbdJCKIJ (ORCPT ); Tue, 3 Oct 2017 06:08:09 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:46138 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751833AbdJCKGz (ORCPT ); Tue, 3 Oct 2017 06:06:55 -0400 Received: by mail-wm0-f48.google.com with SMTP id m72so15604336wmc.1 for ; Tue, 03 Oct 2017 03:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BPjkRHhDrJV0FGPLD+VGHo3kjaCM5aupTNa9FIBiApw=; b=uV4qzs00KeBQYRNF9OEG1TUdwFLjC5u4pO+gQgDIBJNMlkFdk2kUNdhbrYTfMZFmDC mt3/Fjle2mGVTlQu6nA2L5gBo4QhvV/DIyrfFUt+ppZarlkKz8uYvMhDNZXpA7gOqwCf 01rbsjHGbOHInSxvL6mN3YGgFyybGZvR5sf7GNLlFo9yCM+LnpkbGC+q0sXE7PPjePF9 XneqlEVAQqGjEsw4Vs1boWUZy0Bs/7hRBNs0AdYcECMwNSiKSo/WRmLyrnl4OP+xRHH8 b7RMqEHgwCfGxKW621+O+T7P/3rGwdVBcVhY5mSxqJbc+TkScmBiK2wj+nrLMM1k8dBZ 1RUg== 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; bh=BPjkRHhDrJV0FGPLD+VGHo3kjaCM5aupTNa9FIBiApw=; b=nhcF74jLoiyCH/Kia16aVbTj3hfOTdPgl8mpB9AutBQUHpYm7B7g1JPsEmI1N4vatB iNgRGy6RncxXC2RLccT2nR6u4z51NOdt24xJL9GjoeJL4oPexIZAOb9/vCTn5Evr6P4b syBf9+Wntk/y0OWv+TyBb7IAdHaUNdzFJXHeUALpiv6+sWBMZjmrckCd7typE9lz07d9 Rt/b+oE2C7ywwEPwhw+Z8a/qweQ8lpImWpf4yrrOOHPLS3ptZxaqG2xYQLa3Rc4sVt0I bW1IWA9rm3m/iuH0QgHUpbNwxxWHO4MNRt6P6ufGvpaFeCBv2G5ARNgGB91vdbcTcrx5 WdEA== X-Gm-Message-State: AHPjjUhlsWQMFd1wPaIOTHAP0HCOWzgYobpbT6A4t6PEed5MfDwU75Xu HVKgYhBgj9CV1ZDg7AVitejFKg/nIlU= X-Google-Smtp-Source: AOwi7QDSxM2+gdPQpbM7wuWSf3jzPALFY+8WUHNa198XrW1xWNQpvzWFDvvYHCIw6VbZ5WGH1rVSjQ== X-Received: by 10.80.135.29 with SMTP id i29mr23644247edb.31.1507025214709; Tue, 03 Oct 2017 03:06:54 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id e50sm10594908ede.18.2017.10.03.03.06.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 03:06:54 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg , Hans Holmberg Subject: [PATCH 6/9] lightnvm: pblk: shut down gc gracefully during exit Date: Tue, 3 Oct 2017 12:05:10 +0200 Message-Id: <1507025113-13351-7-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507025113-13351-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1507025113-13351-1-git-send-email-hans.ml.holmberg@owltronix.com> 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 Reviewed-by: Javier González --- 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 374089f..f343f90 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) @@ -625,9 +630,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); @@ -635,15 +637,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); }