Received: by 10.223.185.116 with SMTP id b49csp7328881wrg; Thu, 1 Mar 2018 03:53:15 -0800 (PST) X-Google-Smtp-Source: AG47ELsI4X7lpi4C/0b9OcqOh6+xtTDjdskOsZIGcsVbr8FXPwr7JEl4bjYy8sEgUwdbW4CVbQPB X-Received: by 2002:a17:902:8501:: with SMTP id bj1-v6mr1749617plb.110.1519905195430; Thu, 01 Mar 2018 03:53:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519905195; cv=none; d=google.com; s=arc-20160816; b=bLH/jR/5LxfA7TNHWaB4ZD/5o2oaVSCtK1q71xwv4waHDKNm6soiEnOsgF9oJ4eU7s RxkEn+h/7fSo1/Y+v4r251fB1nEmcFslmgUfqaGMOlN8JMTUeemWc5XGUVIPwNHTtETy ttqI8MZb6ypWHiAdM/4kDXjcIi9N4o4UrOWIUQp/wG5O4J0VIHIcUSwgn2XadKZ7cNpa pMPN+9RCiqbx38w8BI4no/IhCJK+Pf4h1Fimm9zmFXF8nSgsHwxiOHlnfY0iyO9+jXop 7ejUMD+myGOcMLebvnF9LSskgYH1g7HvrYDn1brDfyPuE77mdRiwE24fxbVNwnrWR01q jeQQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=26GpOMb10ITJzIn8tM0eSEraG7+X3ZwaB1Y/W+Nt6XI=; b=aqZlFDdvOp29EoiNCh2ScSjf5shHg555einGwzOFrDdr5SW7hXLzVTWNVEaGlbLuT8 QKryY1qcOmbw6+WgopQxLQPKdDLYHgN16B7I2SRkUmgQRIdnWxhUroCPaVx1wyAUZOwK jMmCtpBkv+ix9sP5B81LzU4Cq5fE6uz0ue4hflNF+5DCAMnNR9wiiqcCyGLNeBcEom3+ trQFiO+djAwtbY6NL55i/aaYHvH8aWDyZnoOD29cPq3CtGu4Xue1l6wIcpk/JRi+OXNE gd1dRUWPyc3VXtROXdg038y3sxtvTb0+dYu1rPy0xWuzzRct7Zd0gbouOzt0jlONSMA7 on7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=IJjnlQ6q; 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 k12si2390556pgn.502.2018.03.01.03.53.00; Thu, 01 Mar 2018 03:53:15 -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=IJjnlQ6q; 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 S967889AbeCALvr (ORCPT + 99 others); Thu, 1 Mar 2018 06:51:47 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:41903 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967878AbeCALvo (ORCPT ); Thu, 1 Mar 2018 06:51:44 -0500 Received: by mail-lf0-f68.google.com with SMTP id m69so8384717lfe.8 for ; Thu, 01 Mar 2018 03:51:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=26GpOMb10ITJzIn8tM0eSEraG7+X3ZwaB1Y/W+Nt6XI=; b=IJjnlQ6qsKr8kkLBCAUqsbtxdkKlpJxF/3QAqpa5m/ZopkKiFtrWfPel6PG9k8XT94 06bqS3gwPT3nxulGmulGrmu9h1u6FvATDZayKqF9gmQ2lVkEA5JIYYHsqUDpikbl22Ex BkQwLdd2CtL1YfbSK8Wuq+taAwq1a0+Fgt1BckSRw+itF/1yTFO4zDkgtyekR4OIbNTj 5YN9xmugikeuRwdBqZI8QENOJyO5/qsNObJjCVaRuUJ4UxiGzR+jBysK0uebxTQ4D05r 3lBu/HXVR0pJtG9dblgp2xoOy5m5LcbowW8qAB7L0HfX9Vockxz/sdsjuQcv1N692U5Z rAPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=26GpOMb10ITJzIn8tM0eSEraG7+X3ZwaB1Y/W+Nt6XI=; b=je681CvhrHI0t8cWkVHapJL6DbiFYjNOxonwTaZhxfmJMsdnFSGSS/ll3MXj/QLKOn L2IWEmcBo9fChbkIGlIZer5/D/PkoRoGzLFZHV4D6h23aX2swry4qyU9qsXDWjptJCzQ zJ/rb29bBNDMuHNmEWPlvI0AiW6GVg9cSOnnZKMTlYkxS4Av40a+1tiV3pv9QYDconK7 1amOX58d+16BRVFUY71UcLZNoteAy9fhDR5mEA/7rXDY9Ge+pN+7XmVxdNGWRXzz896g hsPlYeFilw2Zrpu26qUk5JCKfnBWzPJpiqKFoYo56ebK0M32IAnobJnD77pYTmLEBzVj uXBQ== X-Gm-Message-State: APf1xPAXjuA2moG26wEk81QLvtRxyvNC5TlIyf3cC2x7lQxj/C8b0Hkw Iv8J96H9i6TtWbxiISIApyOYnA== X-Received: by 10.46.129.215 with SMTP id s23mr1245979ljg.102.1519905102601; Thu, 01 Mar 2018 03:51:42 -0800 (PST) Received: from [192.168.0.10] (x1-6-a4-08-f5-18-3c-3a.cpe.webspeed.dk. [188.176.29.198]) by smtp.googlemail.com with ESMTPSA id o77sm835851lja.43.2018.03.01.03.51.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 03:51:41 -0800 (PST) Subject: Re: [PATCH 09/15] lightnvm: implement get log report chunk helpers To: Javier Gonzalez Cc: "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-nvme@lists.infradead.org" References: <1519832975-25432-1-git-send-email-javier@cnexlabs.com> <1519832975-25432-10-git-send-email-javier@cnexlabs.com> <4c82d581-d8bf-25fb-26ea-48b26e6de899@lightnvm.io> From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: <3713fd85-5050-b498-ce32-e699444337ba@lightnvm.io> Date: Thu, 1 Mar 2018 12:51:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/01/2018 12:02 PM, Javier Gonzalez wrote: >> On 1 Mar 2018, at 11.40, Matias Bjørling wrote: >> >> On 02/28/2018 04:49 PM, Javier González wrote: >>> The 2.0 spec provides a report chunk log page that can be retrieved >>> using the stangard nvme get log page. This replaces the dedicated >>> get/put bad block table in 1.2. >>> This patch implements the helper functions to allow targets retrieve the >>> chunk metadata using get log page. It makes nvme_get_log_ext available >>> outside of nvme core so that we can use it form lightnvm. >>> Signed-off-by: Javier González >>> --- >>> drivers/lightnvm/core.c | 11 +++++++ >>> drivers/nvme/host/core.c | 6 ++-- >>> drivers/nvme/host/lightnvm.c | 74 ++++++++++++++++++++++++++++++++++++++++++++ >>> drivers/nvme/host/nvme.h | 3 ++ >>> include/linux/lightnvm.h | 24 ++++++++++++++ >>> 5 files changed, 115 insertions(+), 3 deletions(-) >>> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c >>> index ed33e0b11788..4141871f460d 100644 >>> --- a/drivers/lightnvm/core.c >>> +++ b/drivers/lightnvm/core.c >>> @@ -712,6 +712,17 @@ static void nvm_free_rqd_ppalist(struct nvm_tgt_dev *tgt_dev, >>> nvm_dev_dma_free(tgt_dev->parent, rqd->ppa_list, rqd->dma_ppa_list); >>> } >>> +int nvm_get_chunk_meta(struct nvm_tgt_dev *tgt_dev, struct nvm_chk_meta *meta, >>> + struct ppa_addr ppa, int nchks) >>> +{ >>> + struct nvm_dev *dev = tgt_dev->parent; >>> + >>> + nvm_ppa_tgt_to_dev(tgt_dev, &ppa, 1); >>> + >>> + return dev->ops->get_chk_meta(tgt_dev->parent, meta, >>> + (sector_t)ppa.ppa, nchks); >>> +} >>> +EXPORT_SYMBOL(nvm_get_chunk_meta); >>> int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, >>> int nr_ppas, int type) >>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c >>> index 2e9e9f973a75..af642ce6ba69 100644 >>> --- a/drivers/nvme/host/core.c >>> +++ b/drivers/nvme/host/core.c >>> @@ -2127,9 +2127,9 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) >>> return ret; >>> } >>> -static int nvme_get_log_ext(struct nvme_ctrl *ctrl, struct nvme_ns *ns, >>> - u8 log_page, void *log, >>> - size_t size, size_t offset) >>> +int nvme_get_log_ext(struct nvme_ctrl *ctrl, struct nvme_ns *ns, >>> + u8 log_page, void *log, >>> + size_t size, size_t offset) >>> { >>> struct nvme_command c = { }; >>> unsigned long dwlen = size / 4 - 1; >>> diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c >>> index f7135659f918..a1796241040f 100644 >>> --- a/drivers/nvme/host/lightnvm.c >>> +++ b/drivers/nvme/host/lightnvm.c >>> @@ -35,6 +35,10 @@ enum nvme_nvm_admin_opcode { >>> nvme_nvm_admin_set_bb_tbl = 0xf1, >>> }; >>> +enum nvme_nvm_log_page { >>> + NVME_NVM_LOG_REPORT_CHUNK = 0xca, >>> +}; >>> + >>> struct nvme_nvm_ph_rw { >>> __u8 opcode; >>> __u8 flags; >>> @@ -236,6 +240,16 @@ struct nvme_nvm_id20 { >>> __u8 vs[1024]; >>> }; >>> +struct nvme_nvm_chk_meta { >>> + __u8 state; >>> + __u8 type; >>> + __u8 wi; >>> + __u8 rsvd[5]; >>> + __le64 slba; >>> + __le64 cnlb; >>> + __le64 wp; >>> +}; >>> + >>> /* >>> * Check we didn't inadvertently grow the command struct >>> */ >>> @@ -252,6 +266,9 @@ static inline void _nvme_nvm_check_size(void) >>> BUILD_BUG_ON(sizeof(struct nvme_nvm_bb_tbl) != 64); >>> BUILD_BUG_ON(sizeof(struct nvme_nvm_id20_addrf) != 8); >>> BUILD_BUG_ON(sizeof(struct nvme_nvm_id20) != NVME_IDENTIFY_DATA_SIZE); >>> + BUILD_BUG_ON(sizeof(struct nvme_nvm_chk_meta) != 32); >>> + BUILD_BUG_ON(sizeof(struct nvme_nvm_chk_meta) != >>> + sizeof(struct nvm_chk_meta)); >>> } >>> static void nvme_nvm_set_addr_12(struct nvm_addr_format_12 *dst, >>> @@ -555,6 +572,61 @@ static int nvme_nvm_set_bb_tbl(struct nvm_dev *nvmdev, struct ppa_addr *ppas, >>> return ret; >>> } >>> +/* >>> + * Expect the lba in device format >>> + */ >>> +static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev, >>> + struct nvm_chk_meta *meta, >>> + sector_t slba, int nchks) >>> +{ >>> + struct nvm_geo *geo = &ndev->geo; >>> + struct nvme_ns *ns = ndev->q->queuedata; >>> + struct nvme_ctrl *ctrl = ns->ctrl; >>> + struct nvme_nvm_chk_meta *dev_meta = (struct nvme_nvm_chk_meta *)meta; >>> + struct ppa_addr ppa; >>> + size_t left = nchks * sizeof(struct nvme_nvm_chk_meta); >>> + size_t log_pos, offset, len; >>> + int ret, i; >>> + >>> + /* Normalize lba address space to obtain log offset */ >>> + ppa.ppa = slba; >>> + ppa = dev_to_generic_addr(ndev, ppa); >>> + >>> + log_pos = ppa.m.chk; >>> + log_pos += ppa.m.pu * geo->num_chk; >>> + log_pos += ppa.m.grp * geo->num_lun * geo->num_chk; >> >> Why is this done? > > The log page does not map to the lba space. You need to convert it to > get one chunk at a time in the format. > > GRP:PU:CHK > > I can see why taking a lba as argument is better than a ppa, since users > might use the lbas directly, but the conversion needs to be done > somewhere. > Good point. I guess this is clash between the two APIs. Chunk metadata being laid out sequentially, while the address space is sparse. I'm good with the conversion being in the fn.