From patchwork Mon Apr 30 09:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Javier_Gonz=C3=A1lez?= X-Patchwork-Id: 10371203 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 EEB966032A for ; Mon, 30 Apr 2018 09:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFB2C289FC for ; Mon, 30 Apr 2018 09:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2B6328A2A; Mon, 30 Apr 2018 09:15: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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 78E1D289FC for ; Mon, 30 Apr 2018 09:15:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753172AbeD3JPd (ORCPT ); Mon, 30 Apr 2018 05:15:33 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52787 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753583AbeD3JKS (ORCPT ); Mon, 30 Apr 2018 05:10:18 -0400 Received: by mail-wm0-f68.google.com with SMTP id m70so11539719wma.2 for ; Mon, 30 Apr 2018 02:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=javigon-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wPX+Oeo7QznPTnBlDl64nb1VXltpdo4ox2EYiqu95Dk=; b=LhbUvzPXAyTRwyPor82mMOB2h7IKAmLIamSQ/HU7nZoRl3THYjXsjFX/EKFCYdsQUR bH0YsmHhTgP5nv1hAqpEg8yR/GlXaKjMAtofPsqWmGoYAKgO1OqRatDa0u6t7bWswPjF /fuM4yUHJh9GZPV1X0hOtdl/Mq/EYFo132T7CWYIbmoRAWSJY7+d6QoLaJq7kKRzBg4c gl6fTSmYrgjqK9wFXGcfavguvHzpiewdWO8iwH6PgWSfTQPdYlFJyqF8faDx8Nq49ltk aUM7YvuDyVYLBv/gh6NZMW8b6ZHpTmjevQBVLNIfHvfWJRyyEVPO8GWscAFvdxLjCeAO w89w== 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=wPX+Oeo7QznPTnBlDl64nb1VXltpdo4ox2EYiqu95Dk=; b=ZjfrmVBU/wrK+2zBPJO/TsJlDyR1XO1+zzLpXM+R47Hc5c0DBf+1awiG1SRqnloKTH P51itiCYh5WULS3p4yLEc7UzV0niLYqBFacZKLTe9Rb8HePWUghIGApduFwcG2ier9MD umVpCRPaHVZcQhPHZpkmPaubNGqCP4JeaBH1mmJw6q0gyTyCQSvsUmOWQP+DmSESI+Hv AKEt41IZIRTJRAM7Kub49+WG5NigWu644Ahit+barfS7xg3EXkN62ALlayRn6c48Swcd 3a5xuO8LZRpJse0HY1fbr9zgGGlMQJOf/InsBu2EljKjfvwGhP5zlNHjV7tApxjgHyR4 5CMQ== X-Gm-Message-State: ALQs6tCXpRb3gjif5PbTvYm9n8Qlbc+izLPGJnf3wGWBPrPc0wnBs7YB If/ljomB44Nbt53hirjHGFuyeYGb X-Google-Smtp-Source: AB8JxZqY2rFxqzOBaBDdV1vSdTqEPV1TEsuggstQGRIGS+ZI2tbKZTrow4DLq5+NtwVl9Bh9Z/1Nqg== X-Received: by 2002:a50:d09c:: with SMTP id v28-v6mr15672859edd.137.1525079417531; Mon, 30 Apr 2018 02:10:17 -0700 (PDT) Received: from uhalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id b56-v6sm2108638edd.85.2018.04.30.02.10.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Apr 2018 02:10:17 -0700 (PDT) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 01/11] lightnvm: pblk: fail gracefully on line alloc. failure Date: Mon, 30 Apr 2018 11:09:59 +0200 Message-Id: <1525079409-6588-2-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525079409-6588-1-git-send-email-javier@cnexlabs.com> References: <1525079409-6588-1-git-send-email-javier@cnexlabs.com> 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 In the event of a line failing to allocate, fail gracefully and stop the pipeline to avoid more write failing in the same place. Signed-off-by: Javier González --- drivers/lightnvm/pblk-init.c | 5 +++++ drivers/lightnvm/pblk-map.c | 33 ++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 91a5bc2556a3..dee64f91227d 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -1047,6 +1047,11 @@ static int pblk_lines_init(struct pblk *pblk) nr_free_chks += pblk_setup_line_meta(pblk, line, chunk_meta, i); } + if (!nr_free_chks) { + pr_err("pblk: too many bad blocks prevent for sane instance\n"); + return -EINTR; + } + pblk_set_provision(pblk, nr_free_chks); kfree(chunk_meta); diff --git a/drivers/lightnvm/pblk-map.c b/drivers/lightnvm/pblk-map.c index 20dbaa89c9df..953ca31dda68 100644 --- a/drivers/lightnvm/pblk-map.c +++ b/drivers/lightnvm/pblk-map.c @@ -18,11 +18,11 @@ #include "pblk.h" -static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry, - struct ppa_addr *ppa_list, - unsigned long *lun_bitmap, - struct pblk_sec_meta *meta_list, - unsigned int valid_secs) +static int pblk_map_page_data(struct pblk *pblk, unsigned int sentry, + struct ppa_addr *ppa_list, + unsigned long *lun_bitmap, + struct pblk_sec_meta *meta_list, + unsigned int valid_secs) { struct pblk_line *line = pblk_line_get_data(pblk); struct pblk_emeta *emeta; @@ -35,8 +35,14 @@ static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry, if (pblk_line_is_full(line)) { struct pblk_line *prev_line = line; + /* If we cannot allocate a new line, make sure to store metadata + * on current line and then fail + */ line = pblk_line_replace_data(pblk); pblk_line_close_meta(pblk, prev_line); + + if (!line) + return -EINTR; } emeta = line->emeta; @@ -74,6 +80,7 @@ static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry, } pblk_down_rq(pblk, ppa_list, nr_secs, lun_bitmap); + return 0; } void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry, @@ -87,8 +94,12 @@ void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry, for (i = off; i < rqd->nr_ppas; i += min) { map_secs = (i + min > valid_secs) ? (valid_secs % min) : min; - pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i], - lun_bitmap, &meta_list[i], map_secs); + if (pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i], + lun_bitmap, &meta_list[i], map_secs)) { + bio_put(rqd->bio); + pblk_free_rqd(pblk, rqd, PBLK_WRITE); + pblk_pipeline_stop(pblk); + } } } @@ -108,8 +119,12 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd, for (i = 0; i < rqd->nr_ppas; i += min) { map_secs = (i + min > valid_secs) ? (valid_secs % min) : min; - pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i], - lun_bitmap, &meta_list[i], map_secs); + if (pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i], + lun_bitmap, &meta_list[i], map_secs)) { + bio_put(rqd->bio); + pblk_free_rqd(pblk, rqd, PBLK_WRITE); + pblk_pipeline_stop(pblk); + } erase_lun = pblk_ppa_to_pos(geo, rqd->ppa_list[i]);