From patchwork Mon May 28 08:58:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10430185 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 C97AE60249 for ; Mon, 28 May 2018 09:06:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC5D328B20 for ; Mon, 28 May 2018 09:06:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B149B28BE2; Mon, 28 May 2018 09:06:33 +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 2213428B20 for ; Mon, 28 May 2018 09:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754167AbeE1I65 (ORCPT ); Mon, 28 May 2018 04:58:57 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35949 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754121AbeE1I6v (ORCPT ); Mon, 28 May 2018 04:58:51 -0400 Received: by mail-wm0-f66.google.com with SMTP id v131-v6so10866060wma.1 for ; Mon, 28 May 2018 01:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j1jR/yf4TRDpRH7GZG8hOJoJU1FY5n4rWM2R2vC+j3w=; b=DExPGJ9HNaZ+Iewe9UIOgdauKekjtVvpZ9tjdWCBHK9Ww+wW0J9bbHi49woDegahkg 5shF8AGXov5BOvZiBuyEc2vw9nc4x4X/A2FBn80FfRVuyMbkv6E8O4GzoPrrwc06aoHk 0g8XZw3O7c/c2DRoqPY6OKrL05bFgdFyNxXso/popwp3Ju8JE1/FjYqYKkMXvfGcuTtp Pao3rxGkewtgGD0pB8xXrFEC4RxtWoS2HghXjBeE/TZzX2gz6NERwVojbc6mYATnY9sP yha3rhPRT1oL9dnAgzk8gIbOyxQ6AbYFNNmTft0ydwFNZsNEhrb49nqDPlJwLLZJOTP4 t7rg== 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=j1jR/yf4TRDpRH7GZG8hOJoJU1FY5n4rWM2R2vC+j3w=; b=kRRZW8bscij6YlS5KiHfCRXsBNr6lZ/mlf3Py48qoohR3V6xkiYAANRgxvAe4ggq2X ZDqp1GKdsHk8G6VzPbnOaPAXLj+3ABlzdK+lveb5E7vf39J+VDFKQU/6aIBifXyvtvcD Sg+HvyOhZI2CwTzgbYUYjkChTl0DWKNJV9+68TJERs/VAXkLZUTYMWZdzHjEXPol8BsI 6cCIbWWdduj/iLodNQPObZxb9v/cfJDeF/lRNZlWePcaq3XNodRCzQ3CIwusf0ubMLkG Lpc2n4bLD42p+1AxBHoSfToJiL9hF4NzZz3h2qlJdBYpsUaCBdtxBfcwlbGKFAN+t+eJ OnxQ== X-Gm-Message-State: ALKqPwdB5aouI/lNuKPCjoSWmrJJJkf9Tzy62J/HMId5Zk+vTeKZZnCc 8BhIs9P7lVE0vramhP4rDDe9nA== X-Google-Smtp-Source: ADUXVKKhew4jovh4tSfZ5Y0gAbQwLFuQnWzdKXpj7d4cJ58aNb3nnWTeeZTyU8OXROwyqReAUtWdSw== X-Received: by 2002:a2e:19cc:: with SMTP id 73-v6mr4881009ljz.35.1527497930580; Mon, 28 May 2018 01:58:50 -0700 (PDT) Received: from Macroninja.cnexlabs.com (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.gmail.com with ESMTPSA id u2-v6sm5777848lji.4.2018.05.28.01.58.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 01:58:49 -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?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 01/20] lightnvm: pblk: fail gracefully on line alloc. failure Date: Mon, 28 May 2018 10:58:22 +0200 Message-Id: <20180528085841.26684-2-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180528085841.26684-1-mb@lightnvm.io> References: <20180528085841.26684-1-mb@lightnvm.io> 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 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 Signed-off-by: Matias Bjørling --- 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]);