Received: by 10.223.176.5 with SMTP id f5csp2444631wra; Mon, 5 Feb 2018 04:18:16 -0800 (PST) X-Google-Smtp-Source: AH8x224mEERaP4/6gGvMUCuUNB7KJLGlG5+qQrIeUyTSvwCSW8ezn+NfR8Jbi8DbKRIr0TCndUAd X-Received: by 10.101.75.193 with SMTP id p1mr21907216pgr.63.1517833096244; Mon, 05 Feb 2018 04:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517833096; cv=none; d=google.com; s=arc-20160816; b=KUrU6HaSzMym7hJfG/2b57Ief2Hm1a2zg383yXcjbO04zveDVsv8yN+fe1TDzOfFEk 3HyGGb3P7VRoWcZ6jMOKY6DJ6/yGGlOtyjcl0UPnA5agnwm/8PsYkidxACx8rsjSkE3e uVDLp3Qm86Dt4/dWcRw4xaYcthQvMbOlpLqiwO/HdELbwB4HgufGDf1+3o8FE2sGXxOp Doswdk22W7frpgyKOYdGExLHUh68//HCWJspHKdcjH+op6KWKbzFpLhT8OAwO2VVi2kN qBpg+PdgvTEfZ3EsF0LI3KNXQWdoCLBJh/yf3x4DVctCpyBefzFBXfcWf8Hr39Gmg4k1 67sQ== 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:arc-authentication-results; bh=2uJicQiOHXo0WfYLij1n2cz+zVVCslTe6brmnkwPulw=; b=P6c5uHKifA/Gn3XIJS7bwXCE9d+fnnR44nYsJCSSbKdnaW9iy+Av/ljgqlfdQ1D7rD MfEg2tQ7w+ydNkIizlQfd7ZCDOscL1k3Ay0Ap/1UHpfW4HYJJibWKG0D0fM3XpXL/YzV 72eEhWR3afeIqKcxMOziMT77bIlIddHvxXkzpvG4qESNhJde2J1SGzDF3n57SnOruX4m uGda53RSy4bvmne2S+HnLwOGUvO/j89+Rs9iUDxy4PsPuFR7T0qHo9xzTQSY1hZHFGVm 4/hl8MEGH8t6K/Yk2hRAc7QAnthFzCa/dzCTUrdo0xxplklfnMlvJR04yK49we6VlZqf Qt3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=B/LRlKlQ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d24-v6si6855896plr.243.2018.02.05.04.18.01; Mon, 05 Feb 2018 04:18:16 -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=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=B/LRlKlQ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753092AbeBEMQk (ORCPT + 99 others); Mon, 5 Feb 2018 07:16:40 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:42562 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752867AbeBEMPl (ORCPT ); Mon, 5 Feb 2018 07:15:41 -0500 Received: by mail-lf0-f66.google.com with SMTP id q17so41397397lfa.9 for ; Mon, 05 Feb 2018 04:15:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2uJicQiOHXo0WfYLij1n2cz+zVVCslTe6brmnkwPulw=; b=B/LRlKlQbPH7LALXjZ4xppaCHmxzoLyYRDqMmOdk8x1JnCX7acX8zTBtmEYjkbrHbe EiRTPuMDrVVqvR7l3vqoMh+hAd+W3zJX8mzedNRhX0DXakLG5IfyO1Wz+xOFaNLZjCSm DipR7s3mWANnxx38RIKRRpoyHfE9kpFAqXYti16HhAWHmqb/84SZ8gQgS/bt7skhWGa+ Ahgf8x+8I2DO///7Yc3xRu4ygYC8+vggmaFGhDl1+w9a/25tXtYnb0vwDMha5C0NYz3F sOoe4BQvFauIJ8kzE3eqzqp4RGrRoRzpgQUzXQve0RekKsnxtlc9YGpJIwXT59v1/EVl +pdA== 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:mime-version:content-transfer-encoding; bh=2uJicQiOHXo0WfYLij1n2cz+zVVCslTe6brmnkwPulw=; b=Gv7OXd56C8bwlnwpKR4/l4PQ+2XzgDUtHVDmXSq+hWgtZg4xtbJnBvCgqKgCPsgWcK zm2hgFP42+PUe4e4kqOUOOwntPRuqH4ynGus/gBw2XzQbrhnEXFO7JhOM0RhaqaNwFEV 9cx3xLRQgTTyOD1mUvQgXmr9vjo+FxU882EyMGgyNvF0JH0PhRxOm1YWZhZU72eCYkMe G8FZ+BlBCUp/gpsuHa+AYThWFJIEq0+P7eABJsYzZx1I12jCdRPvmUNGyKQcOZy5/A8r /zkWZ6lDust26ZWkMt8TC7gz+O56vQ5t2oX7JXmAnksL+0w7UwWcOjeUEoPaLvqRkXUV 7xrw== X-Gm-Message-State: AKwxytepEyk2cQpxSzTIFozQAM+GhZRcLeoBqAO7aognRa+eRltNRKv1 MAtfHDUFFEeuu7UAfyFQnJ/AFQ== X-Received: by 10.25.142.15 with SMTP id q15mr31983918lfd.82.1517832939332; Mon, 05 Feb 2018 04:15:39 -0800 (PST) Received: from Macroninja.cnexlabs.com (x1-6-a4-08-f5-18-3c-3a.cpe.webspeed.dk. [188.176.29.198]) by smtp.gmail.com with ESMTPSA id r88sm1784817lje.30.2018.02.05.04.15.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 04:15:38 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, javier@cnexlabs.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 4/4] nvme: lightnvm: add late setup of block size and metadata Date: Mon, 5 Feb 2018 13:15:05 +0100 Message-Id: <20180205121505.27563-5-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180205121505.27563-1-mb@lightnvm.io> References: <20180205121505.27563-1-mb@lightnvm.io> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The nvme driver sets up the size of the nvme namespace in two steps. First it initializes the device with standard logical block and metadata sizes, and then sets the correct logical block and metadata size. Due to the OCSSD 2.0 specification relies on the namespace to expose these sizes for correct initialization, let it be updated appropriately on the LightNVM side as well. Signed-off-by: Matias Bjørling --- drivers/nvme/host/core.c | 2 ++ drivers/nvme/host/lightnvm.c | 8 ++++++++ drivers/nvme/host/nvme.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f837d666cbd4..740ceb28067c 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1379,6 +1379,8 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id) if (ns->noiob) nvme_set_chunk_size(ns); nvme_update_disk_info(disk, ns, id); + if (ns->ndev) + nvme_nvm_update_nvm_info(ns); #ifdef CONFIG_NVME_MULTIPATH if (ns->head->disk) nvme_update_disk_info(ns->head->disk, ns, id); diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index a9c010655ccc..8d4301854811 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -814,6 +814,14 @@ int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg) } } +void nvme_nvm_update_nvm_info(struct nvme_ns *ns) +{ + struct nvm_dev *ndev = ns->ndev; + + ndev->identity.csecs = ndev->geo.sec_size = 1 << ns->lba_shift; + ndev->identity.sos = ndev->geo.oob_size = ns->ms; +} + int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node) { struct request_queue *q = ns->queue; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index ea1aa5283e8e..1ca08f4993ba 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -451,12 +451,14 @@ static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns) #endif /* CONFIG_NVME_MULTIPATH */ #ifdef CONFIG_NVM +void nvme_nvm_update_nvm_info(struct nvme_ns *ns); int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node); void nvme_nvm_unregister(struct nvme_ns *ns); int nvme_nvm_register_sysfs(struct nvme_ns *ns); void nvme_nvm_unregister_sysfs(struct nvme_ns *ns); int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg); #else +static inline void nvme_nvm_update_nvm_info(struct nvme_ns *ns) {}; static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node) { -- 2.11.0