Received: by 10.192.165.148 with SMTP id m20csp3553933imm; Mon, 30 Apr 2018 02:11:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpPxqAGBb968OkjEdAdx2HL8C6W5FcfNOVS7KvD/uufKe5U9jO6l9/C94AzrJmJMf4i/3tA X-Received: by 2002:a63:5f0d:: with SMTP id t13-v6mr9607900pgb.145.1525079493062; Mon, 30 Apr 2018 02:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525079493; cv=none; d=google.com; s=arc-20160816; b=k6zxd+3JVnqUT+xK2CbLlyTZaYN7diLyItSYQsHsGS5GcvLFSczdBhwKGwCZf2AiFk f95mSPJkDdQLFhBnWzWVIzeQyQguJqjNnWkD2+VG7NWIgM8qZPtYb+HlKrawRDjX4KgT lmUePZP/Z5R7WdTCa1B+WqlVBaSSWE+Mgfd93K7N7yP2QtqxjYOjWBQwqdraRlGKVg9t VvQGHuR9MVGLKVGQiByxakL+PM7xnWpL620EeJLLEtZ51+8aPfWy8eGxX0r48r4uqMJg DjB3uzEBVqkh3bnNMA3cEWpyVZmkr33nklHcmeiRu6YO35R8RXBtAY51hmRK7qbeNWMT IKqA== 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=Ll4UhF3eAB58iC694TUW1Xa5gNByBnKYcJP4EqC7zWuTc2j+DwOtpVP/lf2sK1VG/3 p5Q2oSKadgP+xo83lQiTmyWuZ+jsQkcfVbKphrjXbl8vPBEsj3f2o/fZ1YFcUBVLYkk+ y0Nz2xI868T+NhdvrMKSxY61vqHZ/MokAdB9nMeCgQcPGe+INRC/GFtu2x9KdgWf/IV8 d46cUV+iqplTX7bdIG1Go7dhPea27QwwV1fnCNwCeHIOiVmnqaZNXyDS+1nR5XX61OAL ywwT7HAnnXbztohD/1XFsWU8CyfT6IQDoSsLjWxKnZtLBciezdqB0mOtxbvWL3cKgNwd LGMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=LhbUvzPX; 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 x2-v6si4926812pgc.495.2018.04.30.02.11.19; Mon, 30 Apr 2018 02:11:33 -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=LhbUvzPX; 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 S1753794AbeD3JKY (ORCPT + 99 others); Mon, 30 Apr 2018 05:10:24 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:51352 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753029AbeD3JKS (ORCPT ); Mon, 30 Apr 2018 05:10:18 -0400 Received: by mail-wm0-f68.google.com with SMTP id j4so11904801wme.1 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=ihEjXLbWKaG9MSlASP4lOpvt1WJmTumRuXJ5Hcksb9FYAWwEfOmx9Yd8TFa52DehMB 9KOFg23U+iVrYnmwxiXDNNkDODLTslbIqGOU+XDrS0ubhF2r9A4WMp2nX4jB5IZm9ull lg0AmEVexxGVV2vi51qyZdHByJ4cJbl2I4gnV+g96ilClLQmF4AGy5KehkFJJIzaNS3H Rl6gPBkROoq9FPDVzMHg1BiR8+5/tCLflLyu+6ooM5A9xx483m8KdS3Ow0uDb27lxD/5 UUXPVhlmh6CxkT3+5cAbO8LAM0xVy5kkbuVvKcJ2RwwMcnqG1xayQpLcd+Lv81gTU16F Xeyw== X-Gm-Message-State: ALQs6tDhzhdkOPmzWe1wpyaJn9iXeTXQ2bw3walgNBeBiAEIPf1v+D0j 3loSEdpMn0jHQ/jL+OIyjKzm+w== 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 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