Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3629956imu; Mon, 28 Jan 2019 08:07:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN5/20wA5o+XV89fcWJ/BYkqV4vKhdnN/XiMB0ZVPrgqCbHdEgZgaRuWdL3QjEgOM17eGUmQ X-Received: by 2002:a62:5b44:: with SMTP id p65mr22187441pfb.47.1548691630441; Mon, 28 Jan 2019 08:07:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691630; cv=none; d=google.com; s=arc-20160816; b=wTvDGTh+HqDzJByCamFs1Scsnl8y8o//eJXpXkKZRW25efA64yH36EtJQALCPTwjQD bF1cvASETWZl6bp2s/8AAf+4zE+sl/v7wIChFjeOMCfFT/UmzHzMdPWnT/zr4aUxXbmP K6Z6qNOb/OUXIlyozPDteYnlCo5kraTeUj2Mn03YKHlIQ62qrrptjiExM8E0lxea/v+z FDKFMThkqkLS6obuFSszXw0boSNWP9mnyDnmsPu+jgtIH9jzcdXCDppA3LLdsBgym7bS HLWu5GcWVsj8CYiCOoY0eVjOcnnmZEexiAO6BGikt10/EtRoYw6jz9Nqf1Ipj3zR9g1B cXag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uzSkIj+qwfeBU9top34xnvE9wxyTOii7pV9JVQie0Cw=; b=fQfVI9GCsMPdXPkQ3oFqHxNb6NU86vdASaIhYnNtNbzYRZJh1rYg0Qddv2fivLalDL S2rGN4o7iHdvqtGdR4C9txahSTtbBOkk8PWXK/Vevzq7Duq6B3GqOip2f16gglcnqzBU dce3uDbK2R5IsmfQJv3VUpVOc3zgJrlfhgYFAHkCnvFN/wNP+NgmA6KFI8BhRfoEBoi4 6NfOEghTCZnoki10d7NPzjEekono2XKAddhyyDD0SNyhHGKO4ZCWdL/Q4Brjz52lY/GZ 2ynPe7xSZSf20+eBQc4SLtuzBKIlK7uMwBcbKoc//nl+LskSJu4lR+XSuWOV+qWHcWr4 mqjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uJkT0lPq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si8068917pgh.505.2019.01.28.08.06.55; Mon, 28 Jan 2019 08:07:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uJkT0lPq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731931AbfA1QGA (ORCPT + 99 others); Mon, 28 Jan 2019 11:06:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:53644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731428AbfA1QFz (ORCPT ); Mon, 28 Jan 2019 11:05:55 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B6A6A2147A; Mon, 28 Jan 2019 16:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691554; bh=+FFnbIwCVDM4EzW0SOOkVepLIL3Hqi0vdNuDwfwCKHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uJkT0lPqgHWcFyfzuV6xOh3vNcghg5Cx1kRDmdWhg1717htUjklb2R4ja5gFvcgeQ zNNUhhZ91WqmovUK4inClEmPJty/IWRViJAtmFgCsYJVfYsANbyPUKTlzcGwOL+0R/ 58gdA/zrwZo2BM2YG//fo5Mh2+eGEosvzku+ktE4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans Holmberg , =?UTF-8?q?Matias=20Bj=C3=B8rling?= , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 139/258] lightnvm: pblk: fix resubmission of overwritten write err lbas Date: Mon, 28 Jan 2019 10:57:25 -0500 Message-Id: <20190128155924.51521-139-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Holmberg [ Upstream commit c12fa401ac8c94a74aff68bb5736b3f1dc695fa8 ] 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 Reviewed-by: Javier González Signed-off-by: Matias Bjørling Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- 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 879227d584e7..c3e038d4b22e 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -158,9 +158,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); -- 2.19.1