From patchwork Mon Nov 5 12:26:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10668117 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 6CDAB1751 for ; Mon, 5 Nov 2018 12:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E41E294D0 for ; Mon, 5 Nov 2018 12:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52188294D9; Mon, 5 Nov 2018 12:26:48 +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 014BA294D0 for ; Mon, 5 Nov 2018 12:26:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729438AbeKEVqQ (ORCPT ); Mon, 5 Nov 2018 16:46:16 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:38763 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728970AbeKEVqP (ORCPT ); Mon, 5 Nov 2018 16:46:15 -0500 Received: by mail-ed1-f66.google.com with SMTP id a2-v6so2729671edi.5 for ; Mon, 05 Nov 2018 04:26:44 -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=aYpv+KMDP/i822XuAPfSWo4UcCeaEVbMte2++xZ1ARE=; b=p/isB/ZHmM9OQxSnxxS1ej9Mp6k0hjsDL/Tud1uZ9nyX8JMCUZpm/vXugixU0PMXTi DbHFlGQO4/MNFp6T1+OvYojsslJKZoSpBCm9y3Z0etdGlYesWL029b19ooeAyJw7WGKt TkSH7GXo023B4WxdaxqhO2+QLTPNqEoBlLn/MUVkUTpZxRP+qMnKETsfDLT+6WJgFTRa Khvou/FQFvwBG/h1CPoPkPlJW8SjAIwms0JhDZ8LwwvKA/hvJ60seth0TRjgavVLrnw+ driQEnCo/zJlUlg7OjT5rMiMvsueJ1fs95TKSbhhenuWpu6/D8rqKM1dSOQPcc9ON71A ccVQ== 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=aYpv+KMDP/i822XuAPfSWo4UcCeaEVbMte2++xZ1ARE=; b=K6PWJNM3CIXY3ph9UN4r6LeihW4i3w1WDSgRle8grlUb45hf+b15MVfhwLUFzUDZ8n SkqlYsQEwC64arBWSUY4xezPSm3wc4rxsHMdom/nXlFJu4Fo+3ljfLLVxTSCRa93lZfT ykrIF4L3uANox0sPCfTP9A1bzfGZ/Tm1l2YKyis4ah4E5ace9MA6xlW+N8U1rpVXBONW LVsURvJLfVULOedFkyKmNf+Ugi/NeaTpECKZWPHbQ1kVdkwzLHEE0LiWjbk/cdHCRKpt 9OWuJNRD5gJb4NywtAqeACdXiemr8eWpyOqwwT6MDgU9AX4bHQOtYRjWgs6bmQK5YvFg oQtw== X-Gm-Message-State: AGRZ1gI1vD/7jViwSViAk9ja2C8jg1bjvdkazwmpQsB2XI54Ng/o9LBa +JF+pG9L4gCEtSwqPxoFbJ5xHA== X-Google-Smtp-Source: AJdET5fKGtnX4gSVPfJFPe0zFSTaXMMEsPVuKSeqk18G5as0jvaeQ+Pc/GxW+WPwoJ3avwN1WiMuXQ== X-Received: by 2002:a17:906:c7c9:: with SMTP id dc9-v6mr13584726ejb.232.1541420803901; Mon, 05 Nov 2018 04:26:43 -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 9-v6sm7046056ejw.46.2018.11.05.04.26.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 04:26:43 -0800 (PST) From: Hans Holmberg To: Matias Bjorling Cc: Javier Gonzales , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg Subject: [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas Date: Mon, 5 Nov 2018 13:26:04 +0100 Message-Id: <20181105122610.1555-2-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105122610.1555-1-hans.ml.holmberg@owltronix.com> References: <20181105122610.1555-1-hans.ml.holmberg@owltronix.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 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);