[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 13/16] nvme: factor out namespace setup
From: |
Klaus Birkelund Jensen |
Subject: |
Re: [PATCH 13/16] nvme: factor out namespace setup |
Date: |
Wed, 15 Apr 2020 12:53:22 +0200 |
On Apr 15 12:38, Philippe Mathieu-Daudé wrote:
> On 4/15/20 12:24 PM, Klaus Jensen wrote:
> > From: Klaus Jensen <address@hidden>
> >
> > Signed-off-by: Klaus Jensen <address@hidden>
> > ---
> > hw/block/nvme.c | 47 ++++++++++++++++++++++++++---------------------
> > 1 file changed, 26 insertions(+), 21 deletions(-)
> >
> > diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> > index f0989cbb4335..08f7ae0a48b3 100644
> > --- a/hw/block/nvme.c
> > +++ b/hw/block/nvme.c
> > @@ -1359,13 +1359,35 @@ static int nvme_init_blk(NvmeCtrl *n, Error **errp)
> > return 0;
> > }
> > +static int nvme_init_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error
> > **errp)
> > +{
> > + int64_t bs_size;
> > + NvmeIdNs *id_ns = &ns->id_ns;
> > +
> > + bs_size = blk_getlength(n->conf.blk);
> > + if (bs_size < 0) {
> > + error_setg_errno(errp, -bs_size, "could not get backing file
> > size");
> > + return -1;
> > + }
> > +
> > + n->ns_size = bs_size;
> > +
> > + id_ns->lbaf[0].ds = BDRV_SECTOR_BITS;
> > + id_ns->nsze = cpu_to_le64(nvme_ns_nlbas(n, ns));
> > +
> > + /* no thin provisioning */
> > + id_ns->ncap = id_ns->nsze;
> > + id_ns->nuse = id_ns->ncap;
> > +
> > + return 0;
> > +}
> > +
> > static void nvme_realize(PCIDevice *pci_dev, Error **errp)
> > {
> > NvmeCtrl *n = NVME(pci_dev);
> > NvmeIdCtrl *id = &n->id_ctrl;
> > int i;
> > - int64_t bs_size;
> > uint8_t *pci_conf;
> > if (nvme_check_constraints(n, errp)) {
> > @@ -1374,12 +1396,6 @@ static void nvme_realize(PCIDevice *pci_dev, Error
> > **errp)
> > nvme_init_state(n);
> > - bs_size = blk_getlength(n->conf.blk);
> > - if (bs_size < 0) {
> > - error_setg(errp, "could not get backing file size");
> > - return;
> > - }
> > -
> > if (nvme_init_blk(n, errp)) {
> > return;
> > }
> > @@ -1390,8 +1406,6 @@ static void nvme_realize(PCIDevice *pci_dev, Error
> > **errp)
> > pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS);
> > pcie_endpoint_cap_init(pci_dev, 0x80);
> > - n->ns_size = bs_size / (uint64_t)n->num_namespaces;
>
> I'm not sure this line belong to this patch.
>
It does. It is already there in the middle of the realize function. It
is moved to nvme_init_namespace as
n->ns_size = bs_size;
since only a single namespace can be configured anyway. I will remove
the for-loop that initializes multiple namespaces as well.
[PATCH 12/16] nvme: add namespace helpers, Klaus Jensen, 2020/04/15
[PATCH 14/16] nvme: factor out pci setup, Klaus Jensen, 2020/04/15
[PATCH 15/16] nvme: factor out cmb setup, Klaus Jensen, 2020/04/15
[PATCH 16/16] nvme: factor out controller identify setup, Klaus Jensen, 2020/04/15
Re: [PATCH 00/16] nvme: refactoring and cleanups, no-reply, 2020/04/15