From patchwork Fri Aug 31 09:59:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10583529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF6A8139B for ; Fri, 31 Aug 2018 09:59:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5F1C2B5B4 for ; Fri, 31 Aug 2018 09:59:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9EFD2B60F; Fri, 31 Aug 2018 09:59:59 +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=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 C287C2B5B4 for ; Fri, 31 Aug 2018 09:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728087AbeHaOGk (ORCPT ); Fri, 31 Aug 2018 10:06:40 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:33171 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbeHaOGk (ORCPT ); Fri, 31 Aug 2018 10:06:40 -0400 Received: by mail-lf1-f67.google.com with SMTP id m26-v6so9530427lfb.0 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=iY454oc/jucfJ1tlaa/zSnwVQXecYuICcODFE/DwGsfmY73ht05Xw2yoHAzVKA6FT2 NCECHtkUwxHBD1ajb/IHqWqC8fPL/Re0/LCPanpvJ8WiuZmeVKv7cHM04K8G5iQLeEb8 PuGTSYNaamKn9wSy/R4bmFljOl4ait6XxtpTQTLytSxBQXGkgfF1MAoj2dhz4OTeavC+ PywYwL5vB5n2Uty9AO+zsXvo4WrWZnkBQfaQ0ozoN7oDxRGz0vnuzgWyWKt0wKsgQhFU 1RbzLBXW4ah+KQYCkPm3YsNLj4wyx+f/KegNfvCIuaeI7346VF7MiWE3oSj/dK38IxtJ VGGQ== X-Gm-Message-State: APzg51CURsAoBdqOb9uOOJr0RPi1DxbYNDAIvI3uA7C+OY6sS2SQSt56 fc9Qucvf/HlQq58uMUlgHTsm5b6/XgbO2g== X-Google-Smtp-Source: ANB0VdbDiC6Evk/4ibVTROpeGQ4yLZ0K2EPYssFcd8xnIUwuzrLaeWmarHEo9iB3UbdS1AS35wVXlg== 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-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 *);