From patchwork Fri Jun 1 13:04:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10443303 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 4D38A602BC for ; Fri, 1 Jun 2018 13:04:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E880289AE for ; Fri, 1 Jun 2018 13:04:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3309A28D7B; Fri, 1 Jun 2018 13:04:52 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham 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 1A88A289AE for ; Fri, 1 Jun 2018 13:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751293AbeFANEs (ORCPT ); Fri, 1 Jun 2018 09:04:48 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:44121 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751707AbeFANEp (ORCPT ); Fri, 1 Jun 2018 09:04:45 -0400 Received: by mail-lf0-f42.google.com with SMTP id 36-v6so12791518lfr.11 for ; Fri, 01 Jun 2018 06:04:45 -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=ggPfcrTVT+cKCtb0w65ZOqFyg697cwAUsZ9hasjoJO/luTV3O65rmNPksMvo6zSiKz AnEDMQb/DG3O87OjdA3rneBNG+vO/tq6emT4or2lL2xqjtHQUNg57reOEJJWbV81OHNK NV5ZGEq2QK0CyVg5ZXAHZcOfOGXZ7pd3Y3NRmYkUDRU4g2OKDDbJKUr7jQFyZihOGoBS 20ktwcw78zBg2mz2ZC3huJjY+2zPYMztArQVxApuUGwjpNlp/92tsQrPRusGL7rvqTYX LYjDcrc3+dq81Mngb+KWvNyBj1h6hD0yv04HYNx92z5iUncBMr4sp7yXsd3f2iRgJBby TyoA== 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=BF44EfJfsgkHcgMZtcileC5ewkpR4CKkQJ8gSC2CQ/ybWZi2KPMYQcFcd1y+MOhD4N Kbrg/VtJGb+CzxA169tZamAC0NSSIuoRzQJMLQJg3Fwn3c/RyUAMdnw0VOrKSmNWDkFv EanxRtbcNeb6DCPaj4j/qxZIJGr7Qe+CB+5voZc4zgVdvODlq81nobCRH6G/JwNi3Ozd tIvuQHxtK/r5p4/eLMeWt/S3Ptzu0TWEhaPB1Q+P1PneWGbrdEF15geFJXOs7YEi7hVe n2AlfrTRvq4SSkmMTrLYRo+sqsLmRac2jSynelhPX4wnW/J5yWNOhW7faDUrxvuFoH+5 Uf8A== X-Gm-Message-State: ALKqPwcOZD/iKvw9kn/nj8sMt31KQKzXO22wMpKhyHUOcMHkLc0mX1+6 3f9AOs+3bzF7kU0K/SNdcVykWA== X-Google-Smtp-Source: ADUXVKK/MiHnK1yfhkE7RM2y4Kp/96G0a2whTzGCdDDx9yd4FYL+B2udoK/RXWIkgYWBJFvrrVZa0Q== X-Received: by 2002:a2e:9cd8:: with SMTP id g24-v6mr8464473ljj.141.1527858284307; Fri, 01 Jun 2018 06:04:44 -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 g5-v6sm303161lje.21.2018.06.01.06.04.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 06:04:43 -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, javier@cnexlabs.com, igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 01/18] lightnvm: pblk: fail gracefully on line alloc. failure Date: Fri, 1 Jun 2018 15:04:15 +0200 Message-Id: <20180601130432.30866-2-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180601130432.30866-1-mb@lightnvm.io> References: <20180601130432.30866-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]);