From patchwork Thu Nov 10 11:26:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9420931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A5FA36022E for ; Thu, 10 Nov 2016 11:27:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9576D294BA for ; Thu, 10 Nov 2016 11:27:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89655295D3; Thu, 10 Nov 2016 11:27:47 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 07A6B294BA for ; Thu, 10 Nov 2016 11:27:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755205AbcKJL1q (ORCPT ); Thu, 10 Nov 2016 06:27:46 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:32799 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754760AbcKJL1p (ORCPT ); Thu, 10 Nov 2016 06:27:45 -0500 Received: by mail-wm0-f68.google.com with SMTP id u144so2492913wmu.0 for ; Thu, 10 Nov 2016 03:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iNmfgfMfKAVXkkAJSov4J8YZSGP0L1qZOIel/of5WUw=; b=J3ygs7IdUjBasZBGk5KGgXQwsxzFJzBpX1y3dLmMMWgKtXADr6q/jTnvcj4W0JeCtV mprnM/REBU1V0S2tqWYUsYFvQ6p2dQvkCSLMbv9/X2KPafQfFPxTsZ1iz+F1WY7b5Ogy bystqXHYYqocz0fjdS/vwZ4KBXoGZ75ZWQBdc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iNmfgfMfKAVXkkAJSov4J8YZSGP0L1qZOIel/of5WUw=; b=N2rlpSM3XB9mFXRgtgu5YLGz4xrQqyoYlZKFbPHPKsqI6z+LjcglYLkvtUY3CcwkBh JUQ1S3N2O6Z96BDHiU8RybemVn2q2Gg95SyGCY51OooPDuTsLdhnAkwX0mPmkQTlJOM9 7fuSoZnzMqDc+q0LcotcIWEMfBNJq0mrwy4ZfCIGip1tYRaTAW6Ml/EOEJy+stkDZr2K JgZPlBVOH4OsYympeepaYC02DokYt9phId3He58t8zPDh+0XdpSGLiVxa/81FLdcZ7Q7 i1SkJVCr74YM+OvdA+ayEKh6cWiyG5FXkKUQsotMpOFOjw4uzJBZRoLOoDBqed4zAtBR 3cpg== X-Gm-Message-State: ABUngvfthTFZQEPBJ1URGg7aiEp2AwKSL5Jy+NLvM9G23u8RzqmApekSnz5YmzF7DsgzOg== X-Received: by 10.28.134.74 with SMTP id i71mr24651812wmd.100.1478777236773; Thu, 10 Nov 2016 03:27:16 -0800 (PST) Received: from Macroninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id 71sm12405134wmo.7.2016.11.10.03.27.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Nov 2016 03:27:16 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: keith.busch@intel.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] lightnvm: invalid offset calculation for lba_shift Date: Thu, 10 Nov 2016 12:26:57 +0100 Message-Id: <1478777217-11514-1-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 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 The ns->lba_shift assumes its value to be the logarithmic of the LA size. A previous patch duplicated the lba_shift calculation into lightnvm. It prematurely also subtracted a 512byte shift, which commonly is applied per-command. The 512byte shift being subtracted twice led to data loss when restoring the logical to physical mapping table from device and when issuing I/O commands using rrpc. Fix offset by removing the 512byte shift subtraction when calculating lba_shift. Fixes: b0b4e09c1ae7 "lightnvm: control life of nvm_dev in driver" Reported-by: Javier González Signed-off-by: Matias Bjørling --- drivers/nvme/host/lightnvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index f5e3011..5daf2f4 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -612,7 +612,7 @@ int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node, ret = nvm_register(dev); - ns->lba_shift = ilog2(dev->sec_size) - 9; + ns->lba_shift = ilog2(dev->sec_size); if (sysfs_create_group(&dev->dev.kobj, attrs)) pr_warn("%s: failed to create sysfs group for identification\n",