From patchwork Fri Oct 13 12:46:15 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: 10004593 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 E0A1860360 for ; Fri, 13 Oct 2017 12:57:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D30652902E for ; Fri, 13 Oct 2017 12:57:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C805F2905E; Fri, 13 Oct 2017 12:57: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 6BB722902E for ; Fri, 13 Oct 2017 12:57:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758505AbdJMM5c (ORCPT ); Fri, 13 Oct 2017 08:57:32 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:53042 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758233AbdJMMrd (ORCPT ); Fri, 13 Oct 2017 08:47:33 -0400 Received: by mail-wm0-f65.google.com with SMTP id k4so21549977wmc.1 for ; Fri, 13 Oct 2017 05:47:32 -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=omP0KbATzWb/1kdsUhTzpE1u7qFvHvt9GpoTSClmTU8=; b=y6EgukMGObUkxybt30Zgubuef4P+aoLCN+ezzSJysBRdPmIVeSW+pOPulpp35ZOvjw FIuGmKCISupvDuvceChrOuqiZP5s7p7GWKt9Fq0EHNhUtV6I+jVqO4GbnGeMug0VA6o6 Kuju4Iqa89tDPJpk4CpTOoqYxc7PzOJl3yjZw= 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=omP0KbATzWb/1kdsUhTzpE1u7qFvHvt9GpoTSClmTU8=; b=jcbfPz7cTO36RuKqKbEW3+xnHANszXp5bBEfuDSxiYCOs1n6eal8I5XlgwnqnuH/gH skEhNGzp/RgLkfcgg6ZM5iPit7gaPufaF4ndWe60McNvZvDtnstoR4lcNytdf4gUCqDK 2Xy1Tf5Hzu/oge3DdDaXJcMvD0WOicU0WAHFUYQUelqjPhhwmDkiPyAooWJPQpYv8yOQ SwLA0MsDQA90R9yWfxd+/Qp9DArU3fV4vk0b/g5VoTvr1UukKDxqoPGKZXxAv/kmqT1z 8jhUbyHc/arJ6r/sQy7F9s22V2WcDhxYqo+qL5mxSxu8MTQWzsZBcsejA2t5bxA4S7Gn /T5A== X-Gm-Message-State: AMCzsaUtrcWRUI0QYjWtrNp4xhsg8xJYuoh+N6bTTGIAOkMUwJaTTz0P NllrtzEZGUNgejCCkSJTAWbZDw== X-Google-Smtp-Source: AOwi7QBn3eDhcJPoD3v6kMXsYB+B8zP/Hj8h2DN5MJ5yuLsQKp1P3SYqWxrDS3qgqwOjjUQnTg9PVw== X-Received: by 10.80.201.12 with SMTP id o12mr1983096edh.98.1507898851960; Fri, 13 Oct 2017 05:47:31 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:30 -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, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 26/58] lightnvm: pblk: refactor read path on GC Date: Fri, 13 Oct 2017 14:46:15 +0200 Message-Id: <20171013124647.32668-27-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: Javier González Simplify the part of the garbage collector where data is read from the line being recycled and moved into an internal queue before being copied to the memory buffer. This allows to get rid of a dedicated function, which introduces an unnecessary dependency on the code. Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-gc.c | 94 +++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 55 deletions(-) diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c index 7ad0cfe..7b103bc 100644 --- a/drivers/lightnvm/pblk-gc.c +++ b/drivers/lightnvm/pblk-gc.c @@ -56,57 +56,6 @@ static void pblk_gc_writer_kick(struct pblk_gc *gc) wake_up_process(gc->gc_writer_ts); } -/* - * Responsible for managing all memory related to a gc request. Also in case of - * failure - */ -static int pblk_gc_move_valid_secs(struct pblk *pblk, struct pblk_gc_rq *gc_rq) -{ - struct nvm_tgt_dev *dev = pblk->dev; - struct nvm_geo *geo = &dev->geo; - struct pblk_gc *gc = &pblk->gc; - struct pblk_line *line = gc_rq->line; - void *data; - int ret = 0; - - data = vmalloc(gc_rq->nr_secs * geo->sec_size); - if (!data) { - ret = -ENOMEM; - goto fail; - } - - gc_rq->data = data; - - /* Read from GC victim block */ - ret = pblk_submit_read_gc(pblk, gc_rq); - if (ret) - goto fail; - - if (!gc_rq->secs_to_gc) - goto fail; - -retry: - spin_lock(&gc->w_lock); - if (gc->w_entries >= PBLK_GC_RQ_QD) { - spin_unlock(&gc->w_lock); - pblk_gc_writer_kick(&pblk->gc); - usleep_range(128, 256); - goto retry; - } - gc->w_entries++; - list_add_tail(&gc_rq->list, &gc->w_list); - spin_unlock(&gc->w_lock); - - pblk_gc_writer_kick(&pblk->gc); - - return 0; - -fail: - pblk_gc_free_gc_rq(gc_rq); - kref_put(&line->ref, pblk_line_put); - return ret; -} - static void pblk_put_line_back(struct pblk *pblk, struct pblk_line *line) { struct pblk_line_mgmt *l_mg = &pblk->l_mg; @@ -130,18 +79,53 @@ static void pblk_gc_line_ws(struct work_struct *work) struct pblk_line_ws *gc_rq_ws = container_of(work, struct pblk_line_ws, ws); struct pblk *pblk = gc_rq_ws->pblk; + struct nvm_tgt_dev *dev = pblk->dev; + struct nvm_geo *geo = &dev->geo; struct pblk_gc *gc = &pblk->gc; struct pblk_line *line = gc_rq_ws->line; struct pblk_gc_rq *gc_rq = gc_rq_ws->priv; + int ret; up(&gc->gc_sem); - if (pblk_gc_move_valid_secs(pblk, gc_rq)) { - pr_err("pblk: could not GC all sectors: line:%d (%d/%d)\n", - line->id, *line->vsc, - gc_rq->nr_secs); + gc_rq->data = vmalloc(gc_rq->nr_secs * geo->sec_size); + if (!gc_rq->data) { + pr_err("pblk: could not GC line:%d (%d/%d)\n", + line->id, *line->vsc, gc_rq->nr_secs); + goto out; } + /* Read from GC victim block */ + ret = pblk_submit_read_gc(pblk, gc_rq); + if (ret) { + pr_err("pblk: failed GC read in line:%d (err:%d)\n", + line->id, ret); + goto out; + } + + if (!gc_rq->secs_to_gc) + goto out; + +retry: + spin_lock(&gc->w_lock); + if (gc->w_entries >= PBLK_GC_RQ_QD) { + spin_unlock(&gc->w_lock); + pblk_gc_writer_kick(&pblk->gc); + usleep_range(128, 256); + goto retry; + } + gc->w_entries++; + list_add_tail(&gc_rq->list, &gc->w_list); + spin_unlock(&gc->w_lock); + + pblk_gc_writer_kick(&pblk->gc); + + kfree(gc_rq_ws); + return; + +out: + pblk_gc_free_gc_rq(gc_rq); + kref_put(&line->ref, pblk_line_put); kfree(gc_rq_ws); }