From patchwork Thu Mar 29 22:05:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10316553 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 CE44D60383 for ; Thu, 29 Mar 2018 22:12:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5FDA285CE for ; Thu, 29 Mar 2018 22:12:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAA97286B4; Thu, 29 Mar 2018 22:12:58 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 1DCD9285CE for ; Thu, 29 Mar 2018 22:12:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752568AbeC2WM4 (ORCPT ); Thu, 29 Mar 2018 18:12:56 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35945 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555AbeC2WHS (ORCPT ); Thu, 29 Mar 2018 18:07:18 -0400 Received: by mail-lf0-f65.google.com with SMTP id z143-v6so10348222lff.3 for ; Thu, 29 Mar 2018 15:07:18 -0700 (PDT) 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=k9/wQrP57sXP4Dmoslw8sFMcT/Vz0gtB4BfsZoHaRWc=; b=esTUjvanOKRIUPlaBbI2yFBkxNPszDCjWgNJY5PtiMZcsTXtT13ZP92OCJObmo3fKm aq745uKUKCYzvjxV6pNAZNxDwpWVNsmkJWcs6CHyGfbeP4aMzwRTXZSlKDAwJyfcdp7l vkvkWPDzSralHv7xqysrDUutvLkKuoI180JH+Wcqw3bnZ7k9TTr+zwLHu550Uufst6Mh QItpxAZekc26XMA3f9DkcfXftUMit50abh+jUFER5Z6H3bAGrLSg446IBP5ewtx4vfOc D9oNkRNZjhvGXk7ilgtAan91nLrF6x224NNkLNP2opBwO3AYhJaubGvs5rJwMPoWsiri 2WAA== 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=k9/wQrP57sXP4Dmoslw8sFMcT/Vz0gtB4BfsZoHaRWc=; b=Us4JQEnqh8hSmYIw2Do6hUWi1XRGs4ka67DiIGGrwOUj+2sC52cVCeKkiCXv1vkXo+ udEnGR/sapUxlG+8c5kaUo2fMy1SFJQt1wLw2AkmUtehPPbXQTFgq/Q6IlLLeRJoqUwh AivD3wRmJV2m3WKPRWlJj+dpc7ZatXPqHMaMbWD4sDZM8KH12GeSvxIqhohRMPLA0II7 BTP+abMX5/2+8CZG8kmsrc0dKrdx9MUdAKrvCCepgg/A9lZuuLrWr+i409zP/iuuc1to dLlzuj9TElFl0WZEhQisYo3dhC80RAdQmeM93TAuyqRWNV/rWyngzX7ZeQQhpZFxpKeR emNg== X-Gm-Message-State: AElRT7EPnptiooAMnlajmAuFkNSpMrbaOGxURSJkHtyi1OS0TAl9Lsxo BteoODXad4ACqGnLcWkOXsXXig== X-Google-Smtp-Source: AIpwx4+Uez9Ir+DXcTolBLdRpugd1vUtsHk2z897piK7X3whbXtuahLJ8MXN4RLUInU2CB8GBaifdw== X-Received: by 2002:a19:be4b:: with SMTP id o72-v6mr6620775lff.20.1522361236665; Thu, 29 Mar 2018 15:07:16 -0700 (PDT) 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 i89-v6sm1365508lfk.12.2018.03.29.15.07.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 15:07:15 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, keith.busch@intel.com, javier@cnexlabs.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 18/37] nvme: lightnvm: add late setup of block size and metadata Date: Fri, 30 Mar 2018 00:05:05 +0200 Message-Id: <20180329220524.30363-19-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180329220524.30363-1-mb@lightnvm.io> References: <20180329220524.30363-1-mb@lightnvm.io> 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 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 Acked-by: Keith Busch --- drivers/lightnvm/core.c | 3 --- drivers/nvme/host/core.c | 2 ++ drivers/nvme/host/lightnvm.c | 8 ++++++++ drivers/nvme/host/nvme.h | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 9704db219866..3eec948d1b7e 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -864,8 +864,6 @@ static int nvm_core_init(struct nvm_dev *dev) geo->ws_seq = id->ws_seq; geo->ws_per_chk = id->ws_per_chk; geo->nr_chks = id->num_chk; - geo->sec_size = id->csecs; - geo->oob_size = id->sos; geo->mccap = id->mccap; geo->sec_per_chk = id->clba; @@ -893,7 +891,6 @@ static int nvm_core_init(struct nvm_dev *dev) if (ret) goto err_fmtype; - blk_queue_logical_block_size(dev->q, geo->sec_size); return 0; err_fmtype: kfree(dev->lun_map); diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 9ee919422669..e7ec2fb5c59a 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1448,6 +1448,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 e38d835b15b5..839c0b96466a 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -812,6 +812,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 c393e4b56f39..aa10842a6709 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -500,12 +500,14 @@ static inline void nvme_mpath_check_last_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) {