From patchwork Fri Oct 13 12:46:34 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: 10004529 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 41BC360216 for ; Fri, 13 Oct 2017 12:53:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31DC328FD1 for ; Fri, 13 Oct 2017 12:53:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26BBF29002; Fri, 13 Oct 2017 12:53:17 +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=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 A57E529057 for ; Fri, 13 Oct 2017 12:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758582AbdJMMw7 (ORCPT ); Fri, 13 Oct 2017 08:52:59 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55024 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932089AbdJMMrv (ORCPT ); Fri, 13 Oct 2017 08:47:51 -0400 Received: by mail-wm0-f66.google.com with SMTP id i124so21518541wmf.3 for ; Fri, 13 Oct 2017 05:47:50 -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=qlJtlIcninerBtw6syv8ln06OE2JQnUkelPsg0g9ncs=; b=pZLGYw981FWX+rj6xRFTxLanzSLiELOm5pMnAFC4JPggSqggsNpgKQa26lMKBeWzH4 mnv9rt5sZvYPWa/Ku1xSklgct1V8cKguAkUDAat3hgEcCM7UWYoM5M13BHrid527Tpsj gsDG3n9XVTeo9fp3CWfLRr5JulzNKgO6hJCkE= 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=qlJtlIcninerBtw6syv8ln06OE2JQnUkelPsg0g9ncs=; b=ujv5hAEh2dr2D7tsJuOSdAMbuNY9cj7DNLfbKqHk6tmuv7D9hHnrgl45dMTFUtCROr cbBHtD1ypOASxgkxogFsTLiwriwioJx+0SVGHHBv+EILweVZeFqPSHqv64cETaKEGtVT m87GMH6ICK2/gZ4hqM1nqBYrHPYjgi13FEJe+ri6INz0GPyA5rcqsmyrBlIia5kQnk+G KQOzfqvnOZrB7mNC/QfVOy7R+YZuRUN2PgAVy7C7EI6JM3CiTshlVJUkJ9s0ODZdp6m3 IlUHupYEc7kDDnUQwxl48wiaa2Gb5mdEd2BQ6QwYO+DG8s2Km+lyRogjR3TJD373f+0h iqUQ== X-Gm-Message-State: AMCzsaWjeUhlSmX+xzvQ38Etw28K3Wl0zdrmpbl7idufr4iTkrQXhIMV u85rnw7nQwYq50G01LSlcTyejA== X-Google-Smtp-Source: AOwi7QDBX4IiNW3LDxAyiswBWcrdqTJ8hanFUjoRlHuTlD1CP/BmAYDMNVzPhLKN4yvBaCkAlpPS/A== X-Received: by 10.80.195.4 with SMTP id a4mr2040855edb.142.1507898869882; Fri, 13 Oct 2017 05:47:49 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:49 -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 45/58] lightnvm: pblk: prevent gc kicks when gc is not operational Date: Fri, 13 Oct 2017 14:46:34 +0200 Message-Id: <20171013124647.32668-46-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 GC can be kicked after it has been shut down when closing the last line during exit, resulting in accesses to freed structures. Make sure that GC is not triggered while it is not operational. Also make sure that GC won't be re-activated during exit when running on another processor by using timer_del_sync. Signed-off-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-gc.c | 9 +++++---- drivers/lightnvm/pblk-init.c | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c index 7b103bc..81efac1 100644 --- a/drivers/lightnvm/pblk-gc.c +++ b/drivers/lightnvm/pblk-gc.c @@ -478,10 +478,10 @@ void pblk_gc_should_start(struct pblk *pblk) { struct pblk_gc *gc = &pblk->gc; - if (gc->gc_enabled && !gc->gc_active) + if (gc->gc_enabled && !gc->gc_active) { pblk_gc_start(pblk); - - pblk_gc_kick(pblk); + pblk_gc_kick(pblk); + } } /* @@ -620,7 +620,8 @@ void pblk_gc_exit(struct pblk *pblk) flush_workqueue(gc->gc_reader_wq); flush_workqueue(gc->gc_line_reader_wq); - del_timer(&gc->gc_timer); + gc->gc_enabled = 0; + del_timer_sync(&gc->gc_timer); pblk_gc_stop(pblk, 1); if (gc->gc_ts) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 2e59973..27eb430 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -931,6 +931,7 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, pblk->dev = dev; pblk->disk = tdisk; pblk->state = PBLK_STATE_RUNNING; + pblk->gc.gc_enabled = 0; spin_lock_init(&pblk->trans_lock); spin_lock_init(&pblk->lock);