[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 02/15] hw/block/nvme: Report actual LBA data shift in LBAF
From: |
Klaus Jensen |
Subject: |
Re: [PATCH v3 02/15] hw/block/nvme: Report actual LBA data shift in LBAF |
Date: |
Tue, 15 Sep 2020 09:34:21 +0200 |
On Sep 14 07:14, Dmitry Fomichev wrote:
> Calculate the data shift value to report based on the set value of
> logical_block_size device property.
>
> In the process, use a local variable to calculate the LBA format
> index instead of the hardcoded value 0. This makes the code more
> readable and it will make it easier to add support for multiple LBA
> formats in the future.
>
> Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
> ---
> hw/block/nvme.c | 4 +++-
> hw/block/nvme.h | 11 +++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 3a90d80694..1cfc136042 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -2203,6 +2203,7 @@ static void nvme_init_namespace(NvmeCtrl *n,
> NvmeNamespace *ns, Error **errp)
> {
> int64_t bs_size;
> NvmeIdNs *id_ns = &ns->id_ns;
> + int lba_index;
>
> bs_size = blk_getlength(n->conf.blk);
> if (bs_size < 0) {
> @@ -2212,7 +2213,8 @@ static void nvme_init_namespace(NvmeCtrl *n,
> NvmeNamespace *ns, Error **errp)
>
> n->ns_size = bs_size;
>
> - id_ns->lbaf[0].ds = BDRV_SECTOR_BITS;
> + lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);
> + id_ns->lbaf[lba_index].ds = nvme_ilog2(n->conf.logical_block_size);
Instead of defining a new function, we can directly use clz32().
31 - clz32(n->conf.logical_block_size)
signature.asc
Description: PGP signature
- [PATCH v3 00/15] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set, Dmitry Fomichev, 2020/09/13
- [PATCH v3 01/15] hw/block/nvme: Define 64 bit cqe.result, Dmitry Fomichev, 2020/09/13
- Re: [PATCH v3 01/15] hw/block/nvme: Define 64 bit cqe.result, Klaus Jensen, 2020/09/15
- RE: [PATCH v3 01/15] hw/block/nvme: Define 64 bit cqe.result, Dmitry Fomichev, 2020/09/15
- Re: [PATCH v3 01/15] hw/block/nvme: Define 64 bit cqe.result, Klaus Jensen, 2020/09/15
- RE: [PATCH v3 01/15] hw/block/nvme: Define 64 bit cqe.result, Dmitry Fomichev, 2020/09/15
- Re: [PATCH v3 01/15] hw/block/nvme: Define 64 bit cqe.result, Klaus Jensen, 2020/09/15
- Re: [PATCH v3 01/15] hw/block/nvme: Define 64 bit cqe.result, Keith Busch, 2020/09/18
[PATCH v3 02/15] hw/block/nvme: Report actual LBA data shift in LBAF, Dmitry Fomichev, 2020/09/13
- Re: [PATCH v3 02/15] hw/block/nvme: Report actual LBA data shift in LBAF,
Klaus Jensen <=
[PATCH v3 03/15] hw/block/nvme: Add Commands Supported and Effects log, Dmitry Fomichev, 2020/09/13
[PATCH v3 04/15] hw/block/nvme: Introduce the Namespace Types definitions, Dmitry Fomichev, 2020/09/13
[PATCH v3 05/15] hw/block/nvme: Define trace events related to NS Types, Dmitry Fomichev, 2020/09/13
[PATCH v3 06/15] hw/block/nvme: Add support for Namespace Types, Dmitry Fomichev, 2020/09/13
[PATCH v3 07/15] hw/block/nvme: Add support for active/inactive namespaces, Dmitry Fomichev, 2020/09/13
[PATCH v3 08/15] hw/block/nvme: Make Zoned NS Command Set definitions, Dmitry Fomichev, 2020/09/13