Received: by 10.223.176.5 with SMTP id f5csp443214wra; Fri, 9 Feb 2018 01:29:49 -0800 (PST) X-Google-Smtp-Source: AH8x2262VxMi4AWclGX9beVM+aAN8z2LBTtviSb4kdcz5XpD/odxtcA6NXt2r4OaFesSa/oRfCiV X-Received: by 2002:a17:902:8a89:: with SMTP id p9-v6mr1910399plo.397.1518168589510; Fri, 09 Feb 2018 01:29:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518168589; cv=none; d=google.com; s=arc-20160816; b=CTaGh16Gd53XP8AAN2M1fOTROM8QWRG9jw5b+BAFuXaKms9LCec+rPmCHCC2gaAADC +hC1ZeAkVpFEJxFUXYthofSo7GbTpL93xhfMwD6AHKM5AQ/tIlStC9ptQ+RGAI6b/Bhv 9UXwRwR1MNcFmt4Nm/o9WAOVm4CjgkdBzuDVX7F88M5ZzEGmAQ1lsJs8Gyr/HYcnXU1A zuHMMJnULtPKckVdnaE7tPhDjp/0bgIZ4bqSbgxEaoaD2bcc0NjKwA3Yo28m3KKLc8iY rXo6vAtRFVciESR5Uely0Q9YwbbeNnUat2vf+PS/XfcsY6qXSIfR0bj6LHM1hztFAtyk vNIw== 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=U97oILC8DTeweFvsB4C8Vow5dEPcux4uoCzJxFBRrwo=; b=IpH3jPx5nO+EbjmGgK0bs4R2RbnKOD7dc8a+T4BU2BwI+VYLkQOPN0chVSwsbPe8in xnZJW/o/RaT47QNwPjezGVnNT+R4jjDe0kfu9nIiLERc+DFnDXaXA3y+0AJl/MWkuU1n bL8nTcD/SxA7FSU82qVHEz5fZG7Oum0HRVMvhphNqrUeCfO+0IjswBrbRl93Gd6am3d2 XOm2eOK+w8u5dQuUOop4kWfYYO7R718luYR3D4JnCGXTORX68vDaeXjFgLu5J3n9r2EZ MvHDHZ4PAT2DeIX064XR4p2vTfWczsoyawzkH5QNsLLurIWft+9YIalJ/3tWQKhOiFch Q1Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=JrFuQWDt; 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 r7si1159671pgu.447.2018.02.09.01.29.32; Fri, 09 Feb 2018 01:29:49 -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=JrFuQWDt; 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 S1752690AbeBIJ2M (ORCPT + 99 others); Fri, 9 Feb 2018 04:28:12 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:36840 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752626AbeBIJ1s (ORCPT ); Fri, 9 Feb 2018 04:27:48 -0500 Received: by mail-lf0-f67.google.com with SMTP id t79so10319719lfe.3 for ; Fri, 09 Feb 2018 01:27:47 -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=U97oILC8DTeweFvsB4C8Vow5dEPcux4uoCzJxFBRrwo=; b=JrFuQWDtOvHgRTIlKcRBNQvl9o8PCctijJV5OmW6E2t314DE98ynsYGQeQHhjnFRoG wupVU1yL2ggVceRDyX+B/nEXkNEzhs5U8XHfYbDJ33i8Eqm5Svlu1KCSUc+EE7bDjIBy STafQRJsx23Ef4diwXRuIIvuwSCe5sQSV0KXKA45P6rGcV/qH2XnEhBzK69vBgIe5yUw 7eKdSYm1WP/2LfcE6usojnNj4kCrHdU3aoKvw6oJCpz5dXPVTjUUfCfBlUzeKBXu/p8O c9QNlu9OO/iQdrLaJpOizpqZkqzkob7le/aKQyKIMYGD88zPmwwSi66gjDRhUgZt7hWt m7YQ== 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=U97oILC8DTeweFvsB4C8Vow5dEPcux4uoCzJxFBRrwo=; b=Lug0unH+K+N2/MURaVJ+5985CMly+VkDp4TI6wXMv8hOUbt0Y0f+zXkTHHEMHENsjX SZQ7KzCx9IRG7iKckNwMFNNYlpFMkAefaAgYPr8UAEnlNla+5Y+12yykrffFXksg+Aq6 5Qq/oOa/pVASq8S/8U+nI5YDocd1SouCq/D5b+D8wFb+xO7BdPWlHBNdpeCoc9mh9ylX 1kIwGa3rqCnIRo2SzzuXyUz/UnhxB23Rc4TPywhUw6BKdPs+kAJRzcChruaNgsGsNAlU FHcAb4hvORD4Kz7HJQ3ONcuq5W65+KPHcQlx4ffLBILvf+VuAWAAg9l39DtmTOO5+HIV ClAw== X-Gm-Message-State: APf1xPDsWE3OF0fAiC9i3K3i7ZYRv5CrCriHPjBdeYYrs/8UjdMLMt1K +bP4gVR/VR3Ara7ne1yJtBK8FQ== X-Received: by 10.46.20.8 with SMTP id u8mr1551261ljd.12.1518168467138; Fri, 09 Feb 2018 01:27:47 -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 t23sm343963ljd.67.2018.02.09.01.27.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 01:27:46 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, javier@cnexlabs.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH V2 4/4] nvme: lightnvm: add late setup of block size and metadata Date: Fri, 9 Feb 2018 10:27:19 +0100 Message-Id: <20180209092719.10679-5-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180209092719.10679-1-mb@lightnvm.io> References: <20180209092719.10679-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 8b243af8a949..a19e85f0cbae 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