From patchwork Tue Nov 6 13:33:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10670415 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 8AF83175A for ; Tue, 6 Nov 2018 13:33:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 782002A3CE for ; Tue, 6 Nov 2018 13:33:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68E0F2A3D4; Tue, 6 Nov 2018 13:33:45 +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 0D87E2A3CE for ; Tue, 6 Nov 2018 13:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388343AbeKFW65 (ORCPT ); Tue, 6 Nov 2018 17:58:57 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:37502 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388310AbeKFW65 (ORCPT ); Tue, 6 Nov 2018 17:58:57 -0500 Received: by mail-it1-f195.google.com with SMTP id j79-v6so5639738itb.2 for ; Tue, 06 Nov 2018 05:33:40 -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=8hHPwN4g6a4SDExe3kUgDdBPm98FRozlO3nCP6bTp2w=; b=AnWiL5xR37/te7QeJB1ltNOvAsU0SgZe+F7ArNF7uPqRfG9OsJ2MGBPP1lJfUZLX4m tTx+L1PennzTEDPoNpkEHbXIPLHExR4wyobaBLZBoI5kgEDNz7br8850flNeZ7icnqFp nAcASjEscgoxS5N3mWaevjaKg4L8sdEjJ5WMX/hkNmXGJfv5ymOBW5w/60z9dkynXpu7 CMihqHwJz8BjfNdGugwCKS6Th1YvsPNIdYFaIZRXfRmJesYH1w9aEYzlw8PcZyst4lUO xBjHfcjohRr6kRL3U12y6dOP8aux79EHeX/POQPthI02ypE9/oBx+ssQNInOuqYPSXHc x2Vg== 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=8hHPwN4g6a4SDExe3kUgDdBPm98FRozlO3nCP6bTp2w=; b=K5kq6G7VXgwRvGTicHydF+90z0T8TKrNzWVQ+yzYx4Ugx/jwd29FRQjf1bapSWEaTi dP118W9dlT8ftLFr/Z8DokMDmp7nqOjcPamX7BROTzTUoifxd5eXMxolBbQL+ax4JRff v8jHa5JzVSGfeh1IIOdHvmGh5RaiWbB7s0DK6C+KCZBpVKiB6M1yJrgZqrM/D5m2iPEo Ah4g7XLB7iSfX2fOz3m+LsL4BKX6DPaxLiILBa9jM39NQyNx9OnEDWcs0R0gcEa8V1dA uzwIrou8t7s6UNDCv0HOdzjIjL+7uieTAVqrkwj4Uz6n8kNR+pRtmNBsDZ1sYqMyhjnF TDyg== X-Gm-Message-State: AGRZ1gJJV8QxqD9nQgOVgML5t6BVvN3/L29OUHnTyZIMAm6LCwVJnLIv +QXn6QWE65Uo6Mt5AK3nlBr1gg== X-Google-Smtp-Source: AJdET5eYWq7eKNDmFdB7WJOVyQ7blK4eW+6cBgW3zICvRi1HTKsdszuxLbf6A+9hAHyJrDVqKS2qqA== X-Received: by 2002:a02:22ca:: with SMTP id o193-v6mr22163997jao.83.1541511220442; Tue, 06 Nov 2018 05:33:40 -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 u132-v6sm897282itb.21.2018.11.06.05.33.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 05:33:39 -0800 (PST) From: Hans Holmberg To: Matias Bjorling Cc: Javier Gonzales , Sebastien Boisvert , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg Subject: [PATCH v3 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas Date: Tue, 6 Nov 2018 14:33:24 +0100 Message-Id: <20181106133330.26570-2-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106133330.26570-1-hans.ml.holmberg@owltronix.com> References: <20181106133330.26570-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);