From patchwork Fri Oct 13 12:46:37 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: 10004519 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 E2A8F60216 for ; Fri, 13 Oct 2017 12:52:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D415729071 for ; Fri, 13 Oct 2017 12:52:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6E1929074; Fri, 13 Oct 2017 12:52: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.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 4008529074 for ; Fri, 13 Oct 2017 12:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758457AbdJMMwV (ORCPT ); Fri, 13 Oct 2017 08:52:21 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:47448 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932248AbdJMMrx (ORCPT ); Fri, 13 Oct 2017 08:47:53 -0400 Received: by mail-wm0-f68.google.com with SMTP id t69so21256092wmt.2 for ; Fri, 13 Oct 2017 05:47:53 -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=h/DU8Fo6/0QzsCyI+Lc1QUF37PH0GL9aF5iHzgq6cTc=; b=PXiHIle+eZAJUtvD2BEi7xoXVL6wg38zuduRUEllFfGEv58Hu65pZU9FZYPpzb38eI phWfZgzp+mbi0MIFsf8qrkpwit0ulNPyD14RklOV4S7HFzyL7NwebaSn7SwFXbYQRNyJ oIeX1qSp7+ckHkUfHy3tpPRtoxJN6rbMuCwkc= 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=h/DU8Fo6/0QzsCyI+Lc1QUF37PH0GL9aF5iHzgq6cTc=; b=uW3DRvf9+5ESksxhaEmrPsLdq6MgAHEkn1US5DwT9GFdEvyAZEYL6/u88pgUOLUsgk tv0Er2N8DWFAIRY8tgAyWtWMChTPmYn5SUDD5lSSNHfRD3YAdFMOmfngCqifmkyGwu6X 0R/JJfGkkG/AgigNnVagzqlI8m5S+kzgZXeSkfcC7kXJt4HtSGBQ7M22OpQdZZKxeWNm P+aMgUxtJ2GPTxGoQLky2XX+hw0Ho9CytJU2E+/D88xtGyeFkYpFCY/Xj41t2yk3ICuW HqOA70m5tx37hNkTyUuAFDDNglrc1CIkQ7uSpXFXNBqNbf6Dmcezk+Ify/H7p1bLubIK p2lA== X-Gm-Message-State: AMCzsaWYyHpPnvIzgO/ndvBCAibpVox5DS7+hpb8NPXPP0Y5gdgrfCIq Cu+AuRAZZWsPY8u5viIDKcSh4Q== X-Google-Smtp-Source: AOwi7QCUEz4Ss0pwIwaTl85yckJPFKm6r2PeXDrvKMJNTsdw9hyQr20DX1dWKPx6JIQ02sm8XrGqcQ== X-Received: by 10.80.131.230 with SMTP id 93mr2023531edi.12.1507898872526; Fri, 13 Oct 2017 05:47:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:51 -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 48/58] lightnvm: pblk: start gc if needed during init Date: Fri, 13 Oct 2017 14:46:37 +0200 Message-Id: <20171013124647.32668-49-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 Start GC if needed, directly after init, as we might need to garbage collect in order to make room for user writes. Create a helper function that allows to kick GC without exposing the internals of the GC/rate-limiter interaction. Signed-off-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-gc.c | 5 +++++ drivers/lightnvm/pblk-init.c | 4 ++++ drivers/lightnvm/pblk-rl.c | 2 +- drivers/lightnvm/pblk.h | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c index 374089f..4bac9e1 100644 --- a/drivers/lightnvm/pblk-gc.c +++ b/drivers/lightnvm/pblk-gc.c @@ -510,6 +510,11 @@ void pblk_gc_should_stop(struct pblk *pblk) pblk_gc_stop(pblk, 0); } +void pblk_gc_should_kick(struct pblk *pblk) +{ + pblk_rl_update_rates(&pblk->rl); +} + void pblk_gc_sysfs_state_show(struct pblk *pblk, int *gc_enabled, int *gc_active) { diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index f08fa20..ad9f014 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -1025,6 +1025,10 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, pblk->rwb.nr_entries); wake_up_process(pblk->writer_ts); + + /* Check if we need to start GC */ + pblk_gc_should_kick(pblk); + return pblk; fail_stop_writer: diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c index 0896439..739f855 100644 --- a/drivers/lightnvm/pblk-rl.c +++ b/drivers/lightnvm/pblk-rl.c @@ -96,7 +96,7 @@ unsigned long pblk_rl_nr_free_blks(struct pblk_rl *rl) * * Only the total number of free blocks is used to configure the rate limiter. */ -static void pblk_rl_update_rates(struct pblk_rl *rl) +void pblk_rl_update_rates(struct pblk_rl *rl) { struct pblk *pblk = container_of(rl, struct pblk, rl); unsigned long free_blocks = pblk_rl_nr_free_blks(rl); diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 21438d1..29ba7ec 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -830,6 +830,7 @@ int pblk_gc_init(struct pblk *pblk); void pblk_gc_exit(struct pblk *pblk); void pblk_gc_should_start(struct pblk *pblk); void pblk_gc_should_stop(struct pblk *pblk); +void pblk_gc_should_kick(struct pblk *pblk); void pblk_gc_kick(struct pblk *pblk); void pblk_gc_free_full_lines(struct pblk *pblk); void pblk_gc_sysfs_state_show(struct pblk *pblk, int *gc_enabled, @@ -841,6 +842,7 @@ int pblk_gc_sysfs_force(struct pblk *pblk, int force); */ void pblk_rl_init(struct pblk_rl *rl, int budget); void pblk_rl_free(struct pblk_rl *rl); +void pblk_rl_update_rates(struct pblk_rl *rl); int pblk_rl_high_thrs(struct pblk_rl *rl); int pblk_rl_low_thrs(struct pblk_rl *rl); unsigned long pblk_rl_nr_free_blks(struct pblk_rl *rl);