Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp398254imm; Fri, 31 Aug 2018 03:33:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYaVe4CE+O4Ebfy9ad8oOJUE3KuZWQpBmxEkB5eJeD9pXzmlNQblPLpygKBYJgK437fZ183 X-Received: by 2002:a17:902:8a97:: with SMTP id p23-v6mr14573159plo.21.1535711593744; Fri, 31 Aug 2018 03:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535711593; cv=none; d=google.com; s=arc-20160816; b=odj83p+Cx7wYBQCYxC9ZX6lBdVClrhmrhn+ArMvdUMrlU8WAm4VMTarQ4TqbGiB+th 4HDbUnE4OyQL4I7MY0V5XBwdoWdWT6ccY7DvN9CdUTlZrqZt/Gaisa5jndzoKVMJzpGb s+J71XDc2nFFubbZSYs+e6RKS4fa94AyBnyyjuyQrW/0/37WUsERLo+q3jV+tOQQgBIY yYXxU4dnW7I9sYmekzUW83A5jaoQrllLXRko/oNp6RSt/j1XuxB7Ec0pst0ts/tEe+Zl M3lkchTxSv1ivXlUwXWpbmhlQbfpDClctLkx++Z5RKeJO3WaF+XdBK3tduJLRDM1TQLR pl1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Q+D9DpoUgHvS8lAMSAmBdr3zYbRMcOr6gx52NImDcVY=; b=yhm80bU7KAwjYRl6qJ4LAfc1jKHwh7j+0Ez3/+xRZUodramzoqz1mVk5laB0P7YRxB iJXzUK4GC2Ww1SxClKiuUdrRJg64ophzDYlxMtE3+eXNjq1UbIwRTpAnde/QpjWzr7bd sBhVoVruwVt6rTC3dSk7CpBcyq8I2Z3F4I13BK/b6TsnsEWNr4Ejv99ak/6iqnuGsZLo nU6Vb9NAPoKVNBbsmRxaN6nDjjDJBQiYEL5l8+q65Tap7QtaZjzHIHBSRmfJIGARiao+ GxGBDKNE/VoPaVLqSWjv2VByTukj0+u9sLiI03pWDQfk8szTVN6tvhT/ooe9BeKlkGqj s/nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=dsFLGXCt; 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 z7-v6si2214258pgf.173.2018.08.31.03.32.58; Fri, 31 Aug 2018 03:33:13 -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=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=dsFLGXCt; 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 S1728148AbeHaOGk (ORCPT + 99 others); Fri, 31 Aug 2018 10:06:40 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:39277 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727871AbeHaOGk (ORCPT ); Fri, 31 Aug 2018 10:06:40 -0400 Received: by mail-lf1-f65.google.com with SMTP id j201-v6so9520174lfg.6 for ; Fri, 31 Aug 2018 02:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Q+D9DpoUgHvS8lAMSAmBdr3zYbRMcOr6gx52NImDcVY=; b=dsFLGXCtW9tMcZowWquUtli6OkNWNyJC0s+RMPzTo0xf/UeCyt1aIr0PF0Ufa653Zs TEOJhyc3BTWyzXvjbF93gYsgYDD8XbdIp0kR8+0x2aSoxivOEi6ZQFZ4/mDYho4bDl2I K/CeoAxpqWSnIfLNSN8k/iu8la3sa4RvrxgMOAQssdTqIA8LZ44chgz0ZHiKLXzIxGAz ZW5MvbPyEt2lWd3N1hhk0Ksh4mAxrAFuHa0sk9PaMcXtfNEzJpOqfW8EwEqt1z3PMttn y75tdU3dvB+/jDhAPMf7t1HzFiClB2rV6CBBQVU2v9AvgwchqJHdLt/2Y3gyGzJAkyk2 UhyQ== 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; bh=Q+D9DpoUgHvS8lAMSAmBdr3zYbRMcOr6gx52NImDcVY=; b=tAaeo8BSf+m2GOjY5UIZgHLegR1E0JVsWHdIyYkHiz1rVo5FohKGAwdKibZoE+pogT 8Qfl2ua39udyTXDx/h296Lv+jzDQOOrhZW4YlfplY4bjavKPkSPNy/zbbln67nI1/WqB VmBz5QDxWt+HzoeFrMUbxS/Nz0T7YUYFPsmq0ODZnwjUkTTki+PzB1BRdZaF3I6SS2D9 8iaCylJRW8O0hOd1orv5h4BeceLCypOM1Fa1oUcbWtYaFriQoXnfRSnJ7g6tsPhirMHY gordXTna8/phCiiptbbD8gKs30CzmKjWpye21MTAJ59g9zep0uFrvhqBEJTAwiLoF4jd Lu0Q== X-Gm-Message-State: APzg51Bte4jnuEfDwZO5hmDL0B+8/KziNBvv4aUiR3gyS5C/Ot2K6JpP 2ZERD1kDU8BzGADw4NqhEP/Xyw== X-Received: by 2002:a19:f83:: with SMTP id 3-v6mr9782204lfp.131.1535709595909; Fri, 31 Aug 2018 02:59:55 -0700 (PDT) Received: from titan.bredbandsbolaget.se (c-adb2e655.03-91-6d6c6d4.bbcust.telenor.se. [85.230.178.173]) by smtp.gmail.com with ESMTPSA id l141-v6sm1764715lfg.55.2018.08.31.02.59.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Aug 2018 02:59:55 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg Subject: [PATCH V2] lightnvm: pblk: fix mapping issue on failed writes Date: Fri, 31 Aug 2018 11:59:29 +0200 Message-Id: <1535709570-8923-1-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Holmberg On 1.2-devices, the mapping-out of remaning sectors in the failed-write's block can result in an infinite loop, stalling the write pipeline, fix this. Fixes: 6a3abf5beef6 ("lightnvm: pblk: rework write error recovery path") Signed-off-by: Hans Holmberg --- Changes in V2: Moved the helper function pblk_next_ppa_in_blk to lightnvm core Renamed variable done->last in the helper function drivers/lightnvm/pblk-write.c | 10 +--------- include/linux/lightnvm.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index 5e6df65d392c..922506d2d0a6 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -125,15 +125,7 @@ static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa) if (!test_and_set_bit(paddr, line->invalid_bitmap)) le32_add_cpu(line->vsc, -1); - if (geo->version == NVM_OCSSD_SPEC_12) { - map_ppa.ppa++; - if (map_ppa.g.pg == geo->num_pg) - done = 1; - } else { - map_ppa.m.sec++; - if (map_ppa.m.sec == geo->clba) - done = 1; - } + done = nvm_next_ppa_in_blk(geo, &map_ppa); } line->w_err_gc->has_write_err = 1; diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 09f65c6c6676..2a6cbfe1d1b4 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -593,6 +593,40 @@ static inline u32 nvm_ppa64_to_ppa32(struct nvm_dev *dev, return ppa32; } +static inline int nvm_next_ppa_in_blk(struct nvm_geo *geo, struct ppa_addr *ppa) +{ + int last = 0; + + if (geo->version == NVM_OCSSD_SPEC_12) { + int sec = ppa->g.sec; + + sec++; + if (sec == geo->ws_min) { + int pg = ppa->g.pg; + + sec = 0; + pg++; + if (pg == geo->num_pg) { + int pl = ppa->g.pl; + + pg = 0; + pl++; + if (pl == geo->num_pln) + last = 1; + + ppa->g.pl = pl; + } + ppa->g.pg = pg; + } + ppa->g.sec = sec; + } else { + ppa->m.sec++; + if (ppa->m.sec == geo->clba) + last = 1; + } + + return last; +} typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *); typedef sector_t (nvm_tgt_capacity_fn)(void *); -- 2.7.4