From patchwork Fri Oct 13 12:46:36 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: 10004523 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 9B77560216 for ; Fri, 13 Oct 2017 12:52:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D8D72902E for ; Fri, 13 Oct 2017 12:52:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8224A2905C; Fri, 13 Oct 2017 12:52:59 +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 30FC82902E for ; Fri, 13 Oct 2017 12:52:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758387AbdJMMwn (ORCPT ); Fri, 13 Oct 2017 08:52:43 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:45161 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932224AbdJMMrw (ORCPT ); Fri, 13 Oct 2017 08:47:52 -0400 Received: by mail-wm0-f65.google.com with SMTP id q124so21263266wmb.0 for ; Fri, 13 Oct 2017 05:47:52 -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=0X4vKfwuoA4g+4O6/vpPoEE8D0nNyAwIhFRyEv1Uxwc=; b=mNt4tIN14QV7/4/NFCrR6KO5HIT0+K80cri7I0pItKCeZpzwSvfErqHQI+PwnlHlHl Cmv11aBSHyj2i3Q2Km+lGkqsAkx3moICFB5GSAhg5s/G11hIX5WNArrthCYugl2Ko82l woHct5Z2IfBDZsIXUBIenpHkn9OW9WJooz9oI= 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=0X4vKfwuoA4g+4O6/vpPoEE8D0nNyAwIhFRyEv1Uxwc=; b=qjw0pUZfkfS9BQqmHn2lMFuGk/nbHK/+MY7yIrH6mzTqIden/AGp8tP87KFV9mrYxU H+YJIlivcP1dTxl4na3P9zFtFqnzIErEW4tTYQV8QB9OyvboH2a6pFdOccTHd5Lyd8jI cDwty8h2F/M7No8XMO87CqtCOtaaTG/cDqvZfoRbGkq9Byfqg/JALcJ3vmIIRXId8d3x MCUT+Rjzsbn/wzQj4Fe+4iZjFIljzwozDJPH1v8XXi3zrYLDMQX5r7EqYrQmckyzCqIs Wos0V1WwRIel53MqBKddTZ8f+SrPdZY9i3kgKlCoTpw9FSiaIXAcbpbx6DTbnTR00D0G /+MA== X-Gm-Message-State: AMCzsaWl9WCJWtxzN2YTvDol0oJeGwqINK7cA/tQrNCLfp0SSj3bUWvT PQ03oB8LGOhAaoHWif0fysVLdw== X-Google-Smtp-Source: AOwi7QC9HguNFpfrUOm/Nci62g/975TXW4+2dMphwgj/0T+fmgEY692PQlWYt28/LoEV35phTbKKwg== X-Received: by 10.80.151.47 with SMTP id c44mr2040043edb.139.1507898871635; Fri, 13 Oct 2017 05:47:51 -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.50 (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 47/58] lightnvm: pblk: free full lines during recovery Date: Fri, 13 Oct 2017 14:46:36 +0200 Message-Id: <20171013124647.32668-48-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 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 Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-gc.c | 48 ++++++++++++++++++++++++++------------------ drivers/lightnvm/pblk-init.c | 3 +++ drivers/lightnvm/pblk.h | 1 + 3 files changed, 32 insertions(+), 20 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,6 +330,33 @@ static bool pblk_gc_should_run(struct pblk_gc *gc, struct pblk_rl *rl) return ((gc->gc_active) && (nr_blocks_need > nr_blocks_free)); } +void pblk_gc_free_full_lines(struct pblk *pblk) +{ + struct pblk_line_mgmt *l_mg = &pblk->l_mg; + struct pblk_line *line; + + do { + spin_lock(&l_mg->gc_lock); + if (list_empty(&l_mg->gc_full_list)) { + spin_unlock(&l_mg->gc_lock); + return; + } + + line = list_first_entry(&l_mg->gc_full_list, + struct pblk_line, list); + + spin_lock(&line->lock); + WARN_ON(line->state != PBLK_LINESTATE_CLOSED); + line->state = PBLK_LINESTATE_GC; + spin_unlock(&line->lock); + + list_del(&line->list); + spin_unlock(&l_mg->gc_lock); + + 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 @@ -345,26 +372,7 @@ static void pblk_gc_run(struct pblk *pblk) 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; - } - - line = list_first_entry(&l_mg->gc_full_list, - struct pblk_line, list); - - spin_lock(&line->lock); - WARN_ON(line->state != PBLK_LINESTATE_CLOSED); - line->state = PBLK_LINESTATE_GC; - spin_unlock(&line->lock); - - list_del(&line->list); - spin_unlock(&l_mg->gc_lock); - - kref_put(&line->ref, pblk_line_put); - } while (1); + 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 27eb430..f08fa20 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 191b1ec..21438d1 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -831,6 +831,7 @@ 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_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);