Received: by 10.192.165.156 with SMTP id m28csp468447imm; Mon, 16 Apr 2018 03:30:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx483dXbrdbgrlJZP+Om5Dzn7vTrW8w7k29UXcX7anapkrT3V4QjChzdOsCyHui3Z8WaT3u0A X-Received: by 2002:a17:902:688c:: with SMTP id i12-v6mr1515180plk.166.1523874656428; Mon, 16 Apr 2018 03:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523874656; cv=none; d=google.com; s=arc-20160816; b=QjrSf8LlZ/SE8qMGauxAWEJW/Y6JEQW7obOzisIqbUc19yBocC285MUGJs4iVrZDCL U3m4i9OaGeVZdFPuJrgklZmChSRyty5cDGXraboXHZEVEFB+W1oyIPCJQMkg8kZ/oUjy agyr3Qv+MvtLcMGIwlm0it9YgqEH4IxLgNpTOEO5igwK9/vic8DKz19duweiq7bhvYqB g/oQjFaLu/kcvieSminAYB/k/xZ6CKuZhjSfnELaq6vnYE2OOt46bn6gmt3jStINRmHY zQtv7qroKfSWVIZZsOBsI+QHjt/LRzg0IHXPeyYva55v4Ft+UiKH4ZKZijTeyKwjMqce qDhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=wPX+Oeo7QznPTnBlDl64nb1VXltpdo4ox2EYiqu95Dk=; b=UPMtGiCYHUTwG4k8ASRMYl9HhPkLs+HVWtRWYK7PG2I3thOyOxzS5U2Je1yAe6RXC3 WpOPxDkshfLBYdOS7Mz2/3GivFHNSb8Ysise0DVqrbDV8+/Wzo+psKpu8FcJRSkNhNeB i8wPTFd5t0ZyzHNQskZd8wRd//GSXbw4ukYpXIRUeq/l5Iye/yi8BnpBcNPqrdj47d7u TQ6XxK/I3lRDSUlwHILtpwla80UEZD4qYmJdB2K9q/9FUpcres/XVMNOT6XZ5cGKqUSZ e3fsYUkxmTdbTVRTfOnpjXfkwbcUyC/yLJetx0Jtex9ucuIQLnWNkWQ7/zAohzt/i9mu EUcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=msqfoyY1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4-v6si3034067pln.468.2018.04.16.03.30.42; Mon, 16 Apr 2018 03:30:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=msqfoyY1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754672AbeDPK22 (ORCPT + 99 others); Mon, 16 Apr 2018 06:28:28 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35576 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752831AbeDPKZm (ORCPT ); Mon, 16 Apr 2018 06:25:42 -0400 Received: by mail-wr0-f193.google.com with SMTP id w3so7805357wrg.2 for ; Mon, 16 Apr 2018 03:25:42 -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=msqfoyY1EOCGCdLqXS/Z4n238kns7nOFiqBclh7kGM7R30rmk/WABYYcCZlhte6OQp YV8ZW5Vhas+8t//Or2Mp4kxmLanm6nhT2hqcjqyPlzqkFfUGL0KSRG5DRjEfdn4Z1QJ8 FXBhRNaQxy3Yz2Yxz8yHkGoM2813+DAHW3s/ZkPU/Epg10j0YXqJDTeAW+5TXVhs9z23 ghJaynokMRFaqXmA1+ZHW7nDg1NIQ/7J+YEnfJ2NYJrrzlqy0qjXKaSbda0n1+x90pKH pklxU2uBc0xLw+r4r00tKXBv8JAxIBuN+W6eWjUTqiKx/p9JkwT2au+4J0b5Q7m2e3nc MNRg== 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=XwC7T1E7cOQ/1PoCoU2n7Xb3HKyUp4E59SDfJayEDEOzm0Q8G21OMkaXBEPs18D+zx dsWfddlfz/sl1CTZQRw5BmbWJRxxIenZ8sjcrSpwTyvqd4Ta+RwGAV8RZgeG0KGX7xXZ /EEV1G8oeC3sMeuFuYJ8+T4zwH6NRSVob8d6UR89ACrdiknMW5dgNHUfqOCM+QfdbbVX lgaOe2Ok0hkSmdtXdi09um2ytZr71gxqrtez6u4+LHtZOj1AdTGZV5If8breMjEx+8NC 6/TVmbE2KCaxnZ3Vm1zf+B/K+MNermWO4Zg+fhMH/ic927C51L8KQTTk5dlNKgKYmnTq bNvw== X-Gm-Message-State: ALQs6tDwwzTP+nZN9nB0mNwMV+ussF02aWZdfX9ZsrI1yfpokk+NGqKV yYOFh4fewOYmZuqcDJp3FQTFng== X-Received: by 10.80.215.138 with SMTP id w10mr31912657edi.10.1523874341566; Mon, 16 Apr 2018 03:25:41 -0700 (PDT) Received: from uhalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id q11sm4250074edj.2.2018.04.16.03.25.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Apr 2018 03:25:41 -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, 16 Apr 2018 12:25:22 +0200 Message-Id: <1523874332-6272-2-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523874332-6272-1-git-send-email-javier@cnexlabs.com> References: <1523874332-6272-1-git-send-email-javier@cnexlabs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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]); -- 2.7.4