From patchwork Tue Oct 3 10:05:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 9982123 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 6D7B660365 for ; Tue, 3 Oct 2017 10:09:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B04C27FB0 for ; Tue, 3 Oct 2017 10:09:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FE2528792; Tue, 3 Oct 2017 10:09:36 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, 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 EA9FF27FB0 for ; Tue, 3 Oct 2017 10:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750983AbdJCKJW (ORCPT ); Tue, 3 Oct 2017 06:09:22 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:54739 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755AbdJCKGv (ORCPT ); Tue, 3 Oct 2017 06:06:51 -0400 Received: by mail-wm0-f54.google.com with SMTP id i124so15677942wmf.3 for ; Tue, 03 Oct 2017 03:06:50 -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=30RV3G/lIMdSB6SUkyV+rjnhGvgwgzKfbZBKpBPkNPA=; b=VeQIIyYp5aS3e5k29ur32h4jVftPPTSGeexPuAkAfzovcNh9++2hkV48O3Q+zOn3be Kpt1TqneIvNAdtA9+dWif4wqq28TevXS17+GkPCDZvfHEP5nQ/d5vsy4IBk6qhpiJleQ yGvYA2pRzbGxESXehnbQ+SVYmzAZDhWVKrdLcPngA7bAEwtaS1jXPtTluV+NTDYr1x8r JRCPxCwa9xfggpnXDIRmvRjac3zUsqViHvYWm+KPhGFSzaGEguOJlvC0y4q16pkhRd96 FXzjGL+hkPrXK0nRSRLuGInqjfS7C6xvcUxa5Kt5orXEpt1Rjsw+IEBsNSDfMfCtPc74 QpAg== 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=30RV3G/lIMdSB6SUkyV+rjnhGvgwgzKfbZBKpBPkNPA=; b=W2qFSKBiVdOIoucT+DRdDRf7ROYB1SHJUf2LjOTQV/u8OuIB/q1YqyETA+X8dO5TUw 3keXGtuuKWQwcl4FhXtStxiuiJyNv9r8Aesr8A/8kXGzTHIxTDvFDKszxEsUQou/Cnxa JlE6BG+YRt+UwxA9r59GJX6pBNSbt+U0DlHV0bStOVgs6sLxYbwL0R3eANjUReIC8Jpk QzwwUl3cirfn4jskRQnAz1BtBewZEJRb8++PmRgZB1VSFWOsUJGqc6HN6hoVorOwN9w/ DVNhprErrjZ0Y0w37RFvUqZESD1IT7Vjo/bbH/86xO8Tk0g16jj5fdEY58095sx6A3OD Wgcg== X-Gm-Message-State: AHPjjUi/PB5dg4+zN/Cq2B8oRwf/7H/RegjvAzbol+8R0nxVXZaCXkGV GSltOCIp01I721PEYoBs4wKc9g== X-Google-Smtp-Source: AOwi7QBnfFR2hEOpJroYLXFz+5UX6Pm4SFMhmFDBwLCEdB+0e4pfLVkY3NkhlE6k2dFXsHOjYIFBew== X-Received: by 10.80.149.24 with SMTP id u24mr23746361eda.137.1507025209857; Tue, 03 Oct 2017 03:06:49 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 03:06:49 -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 1/9] lightnvm: pblk: prevent gc kicks when gc is not operational Date: Tue, 3 Oct 2017 12:05:05 +0200 Message-Id: <1507025113-13351-2-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 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 Reviewed-by: Javier González --- 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 0163914..ec7974b 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -928,6 +928,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);