From patchwork Mon Nov 5 11:41:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10667909 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 F142315A6 for ; Mon, 5 Nov 2018 11:42:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE73829711 for ; Mon, 5 Nov 2018 11:42:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D255529720; Mon, 5 Nov 2018 11:42:07 +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 79D9A29711 for ; Mon, 5 Nov 2018 11:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729019AbeKEVBZ (ORCPT ); Mon, 5 Nov 2018 16:01:25 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:37528 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbeKEVBX (ORCPT ); Mon, 5 Nov 2018 16:01:23 -0500 Received: by mail-it1-f195.google.com with SMTP id j79-v6so138276itb.2 for ; Mon, 05 Nov 2018 03:42:04 -0800 (PST) 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:in-reply-to:references; bh=qCw1dkDLslu/HElVaRw3FdhfQGOps1Ieu66UCGRSzO0=; b=LRcIBwzF8OGzX4fSBdZBIEU9gtjaLxX7Sw1SJMzHumUcNrq1cVhT4VjANjKBxDNKtV XBaeSIeFLZTZ6D+k/DcEaBU88AqfsrcjTdXyivAbufZeYFIDmK5e9TPapYgnJMoKN34F hSkjfgKyaD7Cks9ZxnQjaG8eLtsteMRV+pTFLw4nvnnitzsyDdE7ui+YVNBnZFpqlL1U TGC6/PgReyRgt5G+sv7GBM+Hy935NReAb08LRrm6PKx26FSZLcRxQN7hP2DNRuRUuGtU gHqbU5a1oTqJ7pHxB8A93D/F2V67+SNO9R4gXED0rNXdBojBa09Y3EJ9TRr+TJ/ivE+w xd/w== 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; bh=qCw1dkDLslu/HElVaRw3FdhfQGOps1Ieu66UCGRSzO0=; b=l54L03CqitcNEk2UjgGijPXSYo3jDKzNTC0JfzyA0J42OXb+0T9d1BrHA9X9ZUSGvo nx3OdYBRALXV0aJxFBCXDQDZDKfDb4fo/W+wv0X9b6ESQTFge6eYjYgin2Drda07fmWT urtEnxR83s+DN14p4W2RM9UksQOu8iPRKJv6sVJJGoRcNw7FkEnUeUYn485GmzxkFMFZ t6kv7sZxvA/iNTNzisXwRENUys/WwEGI84lKBVLZw7sqIXvH7T1P1En5QgjAUyocgRIi VneKO2+4qJCSNhwOZGxKPAhTrfEeYAgG3r9z3RvyTXfMKwWZAqFognQRMXf22KeWiqhq LSlA== X-Gm-Message-State: AGRZ1gI9IIOpWKHqiAiZ96CT0jUXwSA/ok/60i7kQtKm9sEf36EynIip tPLX80HQu2su/ohyUS5UA2GyyQ== X-Google-Smtp-Source: AJdET5eJjtZ2Ztd6LkCJAASSZAbLTHJ+DdtbzeUzvyZUvNhyuDYTKZT03yfsoGLzvKrhX2NNzLEHAw== X-Received: by 2002:a05:660c:606:: with SMTP id i6mr6510208itk.110.1541418123848; Mon, 05 Nov 2018 03:42:03 -0800 (PST) Received: from ch-lap-hans.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id 186-v6sm14880824itf.11.2018.11.05.03.42.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 03:42:03 -0800 (PST) From: Hans Holmberg X-Google-Original-From: Hans Holmberg To: Matias Bjorling Cc: Javier Gonzales , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , Hans Holmberg Subject: [PATCH 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas Date: Mon, 5 Nov 2018 12:41:07 +0100 Message-Id: <20181105114113.30932-2-hans.ml.holmberg@cnexlabs.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105114113.30932-1-hans.ml.holmberg@cnexlabs.com> References: <20181105114113.30932-1-hans.ml.holmberg@cnexlabs.com> 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 From: Hans Holmberg Make sure we only look up valid lba addresses on the resubmission path. If an lba is invalidated in the write buffer, that sector will be submitted to disk(as it is already mapped to a ppa), and that write might fail, resulting in a crash when trying to look up the lba in the mapping table (as the lba is marked as invalid). Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-write.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index fa8726493b39..3ddd16f47106 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -148,9 +148,11 @@ static void pblk_prepare_resubmit(struct pblk *pblk, unsigned int sentry, w_ctx = &entry->w_ctx; /* Check if the lba has been overwritten */ - ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba); - if (!pblk_ppa_comp(ppa_l2p, entry->cacheline)) - w_ctx->lba = ADDR_EMPTY; + if (w_ctx->lba != ADDR_EMPTY) { + ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba); + if (!pblk_ppa_comp(ppa_l2p, entry->cacheline)) + w_ctx->lba = ADDR_EMPTY; + } /* Mark up the entry as submittable again */ flags = READ_ONCE(w_ctx->flags);