From patchwork Tue Oct 9 11:11:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10632301 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 F06D115E8 for ; Tue, 9 Oct 2018 11:16:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D185C28A5E for ; Tue, 9 Oct 2018 11:16:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5D2A28A6F; Tue, 9 Oct 2018 11:16:35 +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 128BF28A5E for ; Tue, 9 Oct 2018 11:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726636AbeJISbS (ORCPT ); Tue, 9 Oct 2018 14:31:18 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:43276 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726862AbeJISbR (ORCPT ); Tue, 9 Oct 2018 14:31:17 -0400 Received: by mail-pf1-f193.google.com with SMTP id p24-v6so667576pff.10 for ; Tue, 09 Oct 2018 04:14:51 -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=09SNCuKjBv0ENghLQH2mjMFjiTQQS+mH3krte2z34eM=; b=cfZGOv7aIH9yA/d8WRD6kGX+S/JHJx1x7OfdJtsc98aXsOxh0ASwNTHlMmZEwWeFAr V4GAKaiNyRw9+67IjOEGRXjsaZ5pTwegalalgOs0IpTVMG2+4mgvj8rTyLU1PHooTUQY aKxKDnIIeu/pQU6pmwFXmq6uXzQJ/AxVy/C49JehtXJPrycjvzctF0eHPBDpwu5yXtki CBDKQ54n2mIHAESxtO6JGmJ4wgoMjTqh5y7WYj1EiJkiFDd78zqKclH4Qw4bvFs8PSHi iq8M1lEnQwqp6M7MDi3LrU3G+j38F/K/li8OZWvGXTkSONu/dkPNqSXmm0KKMAL+qoB6 2CQg== 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=09SNCuKjBv0ENghLQH2mjMFjiTQQS+mH3krte2z34eM=; b=ipJwE5amsiEwIXJhMcFObT7ng3aX0LRVq4lkDB5cUKlxVpnN+zr9MMDpv0wa56vSdh nkVKVK4J3Quh3gpw5MhVJPDwMxsK8JXtKMpPE+KIf049j1bchF0BFVQBN0hL/SQ5xHRt yFa4cdfRbblsPyKyJAWKnxzDfLlAODq9y+obhzR7+Ax1yePSfeuODTAgX3SdtvZU0+YC QbrKhh56nuHbn2UpHnVSGh8Vc1omLoEOFv+eyoGdZ/C7nUv934CfZ5uDSgdp63+ZIR22 6obDZYH9inUJFZHUVKMf0xX2RDkE2hX0blTNI2lDLwWXJjzuBc6bsajKJjk2iaZS/6MR MDHQ== X-Gm-Message-State: ABuFfoja/d+cn8bGYyiAWmZvlvx+mj06ORrOVcfC7XFzLrUXXXVV9Wgz 0eJyxjMEZTBw2j6WZcvBSed1zA== X-Google-Smtp-Source: ACcGV61+vu23ZqFEmY3d4F/NeyTq0cZqXE9WpVBNSR0kbh9Go7UKOP58DVLvROszrDhVGHUTAj4A+w== X-Received: by 2002:a63:b04f:: with SMTP id z15-v6mr23482859pgo.442.1539083691085; Tue, 09 Oct 2018 04:14:51 -0700 (PDT) Received: from skyninja.hgst.com (rap-us.hgst.com. [199.255.44.250]) by smtp.gmail.com with ESMTPSA id p1-v6sm25342380pff.128.2018.10.09.04.14.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 04:14:49 -0700 (PDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 29/45] lightnvm: pblk: fix mapping issue on failed writes Date: Tue, 9 Oct 2018 13:11:59 +0200 Message-Id: <20181009111215.7653-30-mb@lightnvm.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181009111215.7653-1-mb@lightnvm.io> References: <20181009111215.7653-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: 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 Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-write.c | 12 +----------- include/linux/lightnvm.h | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index 61fe22ccc7a1..9554febee480 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -106,8 +106,6 @@ static void pblk_complete_write(struct pblk *pblk, struct nvm_rq *rqd, /* Map remaining sectors in chunk, starting from ppa */ static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa) { - struct nvm_tgt_dev *dev = pblk->dev; - struct nvm_geo *geo = &dev->geo; struct pblk_line *line; struct ppa_addr map_ppa = *ppa; u64 paddr; @@ -125,15 +123,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_chk(pblk->dev, &map_ppa); } line->w_err_gc->has_write_err = 1; diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index eb7300c20f24..2fdeac1a420d 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -593,6 +593,42 @@ static inline u32 nvm_ppa64_to_ppa32(struct nvm_dev *dev, return ppa32; } +static inline int nvm_next_ppa_in_chk(struct nvm_tgt_dev *dev, + struct ppa_addr *ppa) +{ + struct nvm_geo *geo = &dev->geo; + 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 *);