From patchwork Mon Feb 5 12:15: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: 10200203 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 C576A601A1 for ; Mon, 5 Feb 2018 12:16:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B72B3286B3 for ; Mon, 5 Feb 2018 12:16:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABDEF286CA; Mon, 5 Feb 2018 12:16:36 +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 3263A286B3 for ; Mon, 5 Feb 2018 12:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753074AbeBEMQf (ORCPT ); Mon, 5 Feb 2018 07:16:35 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:38521 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752877AbeBEMPl (ORCPT ); Mon, 5 Feb 2018 07:15:41 -0500 Received: by mail-lf0-f68.google.com with SMTP id g72so41381762lfg.5 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=qIgTOMfLfZBy199er+T6nsXvzjiwa1RPaa2v4Jz9kyAFk4+Kz1N2wjxgNCIF3SSLI0 Z6DeGv48bJtS5o7uh/lTWlrbM+jogUPsRMy1n/dgR6tGFuOYwr6mRZyucRWXQ31annZk 426efQEc0fKT0qiI9ecyyRnNoYD3kyX4BCWd7rPoh/UYwOd7573DEHR52UkD3BbVMKNf 9OSBoKdQjX+V8F4ql26QAvezWCjbuYqZpKHOm82QYT9szvy53Y+T8+xIBf949GuNaTgU RvKci3UOErRDuH1DTwCocvziYjysMVBQsyF2AJzUQiPSFqeDWmCI4/+LFWs9JbL/bEPi Y6mw== X-Gm-Message-State: AKwxyteoVXBxQQpyxEBTWI9Ds/MeXNO2m7izwPLD2j8ay9GX3JgvLK25 58Q4NFTfctxKNOY8DeZwH7sR3dkZ X-Google-Smtp-Source: AH8x224GBuBcAVSgK9Ok+T4lkro3CDhbU/o4bMdfbatqjWBP5Kpr96IWePOAHd0NVoZHML+1SSQfkQ== 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 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 --- 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) {