From patchwork Tue Oct 3 10:05:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 9982111 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 90CB260365 for ; Tue, 3 Oct 2017 10:08:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DA84201B1 for ; Tue, 3 Oct 2017 10:08:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82AE828885; Tue, 3 Oct 2017 10:08:28 +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 2C2BF201B1 for ; Tue, 3 Oct 2017 10:08:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751835AbdJCKGz (ORCPT ); Tue, 3 Oct 2017 06:06:55 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:51486 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbdJCKGx (ORCPT ); Tue, 3 Oct 2017 06:06:53 -0400 Received: by mail-wm0-f51.google.com with SMTP id f4so7618436wme.0 for ; Tue, 03 Oct 2017 03:06:52 -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=g00hbolk2FfvXZHdRPo/OYcSUYQZ96vHAAFSIC9ZFIE=; b=E7uCN8/kIcu4COrMCGHrVprJqi5WkPuGCDZCdwWKitBuGCUFECGCOjZhgUluNd/Kxf heKKnecnBCSJZCKie1vT360jKCbIHWU81uUJuH4Np/ClddA3x5/MMG+HiW8dQARfkmF6 oQMuChzFOeihnW1VgsIVirLxPgrFprksiPKgMGoTcnHehdWVkD9S2v1R6w/wga7r0JL/ oxdIGsDH0PLnezwCvQ4soctvkksBZl+ltOwG4KJCrzxRZHdg9G2wWvpUnbNFdkT+nEes flOcFQevUvnz57ZgXCUuDb394dzPBFDeHhJQcLu0WNBhRKI4J9wNdtFJ2ih3jJ30NZA9 Zydw== 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=g00hbolk2FfvXZHdRPo/OYcSUYQZ96vHAAFSIC9ZFIE=; b=geRWOBRqKIS0DZeZtF8+f2iu3vXDUrmyPi/uBKF9IU6ZzhIrWLrqhwjjdQdNKDRK6G 9AcTw7fesngtiaaA0XdVxCc87u9R98Cx1efUs+ofnEIksHWotJEtTRs+NQQneeh4KSJN yGxaQ4V/RDJ84nBFZKBaHWDikEHo/+dGKZiHbgA7h3otaJWhLjo8wi1URCdH2b7wDMCU TfDQFrydiTfF5w32E7Db87++1GBCSwW4WQhhO47lp8MFI4XaY1IWibq1s7vn33Db803Z MPfJ4dtaNe4Fe1mzi7lEwZC11FvO0dq5xqbnrTXzO43+KV9xk4aNIW3qYqumK0magcbv ALXQ== X-Gm-Message-State: AMCzsaXZLtToR1MoLLrWKG9bChEbzLROhLYVrAdj0T0z5aWZBet8+pKF pLiTOsnjFZLQOIhNnoggJ3gkJA== X-Google-Smtp-Source: AOwi7QDM3u190VXM1Xs7MoQMyVYH+Cmnhkg41Jnq3FQv0HTXQbzsYba+HCMX0r2NJVpAerr9ZVyQ5Q== X-Received: by 10.80.213.155 with SMTP id v27mr14831529edi.124.1507025211789; Tue, 03 Oct 2017 03:06:51 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 03:06:51 -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 3/9] lightnvm: pblk: free full lines during recovery Date: Tue, 3 Oct 2017 12:05:07 +0200 Message-Id: <1507025113-13351-4-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 When rebuilding the L2P table, any full lines(lines without any valid sectors) will be identified. If these lines are not freed, we risk not being able to allocate the first data line. This patch refactors the part of GC that frees empty lines into a separate function and adds a call to this after the L2P table has been rebuilt. Signed-off-by: Hans Holmberg Reviewed-by: Javier González --- drivers/lightnvm/pblk-gc.c | 32 ++++++++++++++++++++------------ drivers/lightnvm/pblk-init.c | 3 +++ drivers/lightnvm/pblk.h | 1 + 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c index 81efac1..374089f 100644 --- a/drivers/lightnvm/pblk-gc.c +++ b/drivers/lightnvm/pblk-gc.c @@ -330,26 +330,16 @@ static bool pblk_gc_should_run(struct pblk_gc *gc, struct pblk_rl *rl) return ((gc->gc_active) && (nr_blocks_need > nr_blocks_free)); } -/* - * Lines with no valid sectors will be returned to the free list immediately. If - * GC is activated - either because the free block count is under the determined - * threshold, or because it is being forced from user space - only lines with a - * high count of invalid sectors will be recycled. - */ -static void pblk_gc_run(struct pblk *pblk) +void pblk_gc_free_full_lines(struct pblk *pblk) { struct pblk_line_mgmt *l_mg = &pblk->l_mg; - struct pblk_gc *gc = &pblk->gc; struct pblk_line *line; - struct list_head *group_list; - bool run_gc; - int inflight_gc, gc_group = 0, prev_group = 0; do { spin_lock(&l_mg->gc_lock); if (list_empty(&l_mg->gc_full_list)) { spin_unlock(&l_mg->gc_lock); - break; + return; } line = list_first_entry(&l_mg->gc_full_list, @@ -365,6 +355,24 @@ static void pblk_gc_run(struct pblk *pblk) kref_put(&line->ref, pblk_line_put); } while (1); +} + +/* + * Lines with no valid sectors will be returned to the free list immediately. If + * GC is activated - either because the free block count is under the determined + * threshold, or because it is being forced from user space - only lines with a + * high count of invalid sectors will be recycled. + */ +static void pblk_gc_run(struct pblk *pblk) +{ + struct pblk_line_mgmt *l_mg = &pblk->l_mg; + struct pblk_gc *gc = &pblk->gc; + struct pblk_line *line; + struct list_head *group_list; + bool run_gc; + int inflight_gc, gc_group = 0, prev_group = 0; + + pblk_gc_free_full_lines(pblk); run_gc = pblk_gc_should_run(&pblk->gc, &pblk->rl); if (!run_gc || (atomic_read(&gc->inflight_gc) >= PBLK_GC_L_QD)) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index ec7974b..1cc3de4 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -508,6 +508,9 @@ static int pblk_lines_configure(struct pblk *pblk, int flags) } } + /* Free full lines directly as GC has not been started yet */ + pblk_gc_free_full_lines(pblk); + if (!line) { /* Configure next line for user data */ line = pblk_line_get_first_data(pblk); diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index eaf5397..f76583b 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -831,6 +831,7 @@ 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, int *gc_active); int pblk_gc_sysfs_force(struct pblk *pblk, int force);