From: Igor Konopko <igor.j.konopko@intel.com>
To: "Hans Holmberg" <hans.ml.holmberg@owltronix.com>,
"Javier González" <javier@javigon.com>,
"Matias Bjorling" <mb@lightnvm.io>
Cc: Hans Holmberg <hans.holmberg@cnexlabs.com>,
linux-block@vger.kernel.org,
Klaus Jensen <klaus.jensen@cnexlabs.com>
Subject: Re: [PATCH 12/13] lightnvm: pblk: close opened chunks
Date: Mon, 4 Mar 2019 13:56:36 +0100 [thread overview]
Message-ID: <3ec010fb-b49e-a3ce-a816-c1d193b53036@intel.com> (raw)
In-Reply-To: <CANr-nt1kkQ1H4TgF9-3yR-_S+-HkNwEnGu_t5Z607jAV30cpqw@mail.gmail.com>
On 04.03.2019 11:05, Hans Holmberg wrote:
> On Mon, Mar 4, 2019 at 9:46 AM Javier González <javier@javigon.com> wrote:
>>
>>> On 27 Feb 2019, at 18.14, Igor Konopko <igor.j.konopko@intel.com> wrote:
>>>
>>> When we creating pblk instance with factory
>>> flag, there is a possibility that some chunks
>>> are in open state, which does not allow to
>>> issue erase request to them directly. Such a
>>> chunk should be filled with some empty data in
>>> order to achieve close state. Without that we
>>> are risking that some erase operation will be
>>> rejected by the drive due to inproper chunk
>>> state.
>>>
>>> This patch implements closing chunk logic in pblk
>>> for that case, when creating instance with factory
>>> flag in order to fix that issue
>>>
>>> Signed-off-by: Igor Konopko <igor.j.konopko@intel.com>
>>> ---
>>> drivers/lightnvm/pblk-core.c | 114 +++++++++++++++++++++++++++++++++++
>>> drivers/lightnvm/pblk-init.c | 14 ++++-
>>> drivers/lightnvm/pblk.h | 2 +
>>> 3 files changed, 128 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
>>> index fa4dc05608ff..d3c45393f093 100644
>>> --- a/drivers/lightnvm/pblk-core.c
>>> +++ b/drivers/lightnvm/pblk-core.c
>>> @@ -161,6 +161,120 @@ struct nvm_chk_meta *pblk_chunk_get_off(struct pblk *pblk,
>>> return meta + ch_off + lun_off + chk_off;
>>> }
>>>
>>> +static void pblk_close_chunk(struct pblk *pblk, struct ppa_addr ppa, int count)
>>> +{
>>> + struct nvm_tgt_dev *dev = pblk->dev;
>>> + struct nvm_geo *geo = &dev->geo;
>>> + struct bio *bio;
>>> + struct ppa_addr *ppa_list;
>>> + struct nvm_rq rqd;
>>> + void *meta_list, *data;
>>> + dma_addr_t dma_meta_list, dma_ppa_list;
>>> + int i, rq_ppas, rq_len, ret;
>>> +
>>> + meta_list = nvm_dev_dma_alloc(dev->parent, GFP_KERNEL, &dma_meta_list);
>>> + if (!meta_list)
>>> + return;
>>> +
>>> + ppa_list = meta_list + pblk_dma_meta_size(pblk);
>>> + dma_ppa_list = dma_meta_list + pblk_dma_meta_size(pblk);
>>> +
>>> + rq_ppas = pblk_calc_secs(pblk, count, 0, false);
>>> + if (!rq_ppas)
>>> + rq_ppas = pblk->min_write_pgs;
>>> + rq_len = rq_ppas * geo->csecs;
>>> +
>>> + data = kzalloc(rq_len, GFP_KERNEL);
>>> + if (!data)
>>> + goto free_meta_list;
>>> +
>>> + memset(&rqd, 0, sizeof(struct nvm_rq));
>>> + rqd.opcode = NVM_OP_PWRITE;
>>> + rqd.nr_ppas = rq_ppas;
>>> + rqd.meta_list = meta_list;
>>> + rqd.ppa_list = ppa_list;
>>> + rqd.dma_ppa_list = dma_ppa_list;
>>> + rqd.dma_meta_list = dma_meta_list;
>>> +
>>> +next_rq:
>>> + bio = bio_map_kern(dev->q, data, rq_len, GFP_KERNEL);
>>> + if (IS_ERR(bio))
>>> + goto out_next;
>>> +
>>> + bio->bi_iter.bi_sector = 0; /* artificial bio */
>>> + bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
>>> +
>>> + rqd.bio = bio;
>>> + for (i = 0; i < rqd.nr_ppas; i++) {
>>> + rqd.ppa_list[i] = ppa;
>>> + rqd.ppa_list[i].m.sec += i;
>>> + pblk_get_meta(pblk, meta_list, i)->lba =
>>> + cpu_to_le64(ADDR_EMPTY);
>>> + }
>>> +
>>> + ret = nvm_submit_io_sync(dev, &rqd);
>>> + if (ret) {
>>> + bio_put(bio);
>>> + goto out_next;
>>> + }
>>> +
>>> + if (rqd.error)
>>> + goto free_data;
>>> +
>>> +out_next:
>>> + count -= rqd.nr_ppas;
>>> + ppa.m.sec += rqd.nr_ppas;
>>> + if (count > 0)
>>> + goto next_rq;
>>> +
>>> +free_data:
>>> + kfree(data);
>>> +free_meta_list:
>>> + nvm_dev_dma_free(dev->parent, meta_list, dma_meta_list);
>>> +}
>>> +
>>> +void pblk_close_opened_chunks(struct pblk *pblk, struct nvm_chk_meta *meta)
>>> +{
>>> + struct nvm_tgt_dev *dev = pblk->dev;
>>> + struct nvm_geo *geo = &dev->geo;
>>> + struct nvm_chk_meta *chunk_meta;
>>> + struct ppa_addr ppa;
>>> + int i, j, k, count;
>>> +
>>> + for (i = 0; i < geo->num_chk; i++) {
>>> + for (j = 0; j < geo->num_lun; j++) {
>>> + for (k = 0; k < geo->num_ch; k++) {
>>> + ppa.ppa = 0;
>>> + ppa.m.grp = k;
>>> + ppa.m.pu = j;
>>> + ppa.m.chk = i;
>>> +
>>> + chunk_meta = pblk_chunk_get_off(pblk,
>>> + meta, ppa);
>>> + if (chunk_meta->state == NVM_CHK_ST_OPEN) {
>>> + ppa.m.sec = chunk_meta->wp;
>>> + count = geo->clba - chunk_meta->wp;
>>> + pblk_close_chunk(pblk, ppa, count);
>>> + }
>>> + }
>>> + }
>>> + }
>>> +}
>>> +
>>> +bool pblk_are_opened_chunks(struct pblk *pblk, struct nvm_chk_meta *meta)
>>> +{
>>> + struct nvm_tgt_dev *dev = pblk->dev;
>>> + struct nvm_geo *geo = &dev->geo;
>>> + int i;
>>> +
>>> + for (i = 0; i < geo->all_luns; i++) {
>>> + if (meta[i].state == NVM_CHK_ST_OPEN)
>>> + return true;
>>> + }
>>> +
>>> + return false;
>>> +}
>>> +
>>> void __pblk_map_invalidate(struct pblk *pblk, struct pblk_line *line,
>>> u64 paddr)
>>> {
>>> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
>>> index 9913a4514eb6..83abe6960b46 100644
>>> --- a/drivers/lightnvm/pblk-init.c
>>> +++ b/drivers/lightnvm/pblk-init.c
>>> @@ -1028,13 +1028,14 @@ static int pblk_line_meta_init(struct pblk *pblk)
>>> return 0;
>>> }
>>>
>>> -static int pblk_lines_init(struct pblk *pblk)
>>> +static int pblk_lines_init(struct pblk *pblk, bool factory_init)
>>> {
>>> struct pblk_line_mgmt *l_mg = &pblk->l_mg;
>>> struct pblk_line *line;
>>> void *chunk_meta;
>>> int nr_free_chks = 0;
>>> int i, ret;
>>> + bool retry = false;
>>>
>>> ret = pblk_line_meta_init(pblk);
>>> if (ret)
>>> @@ -1048,12 +1049,21 @@ static int pblk_lines_init(struct pblk *pblk)
>>> if (ret)
>>> goto fail_free_meta;
>>>
>>> +get_chunk_meta:
>>> chunk_meta = pblk_get_chunk_meta(pblk);
>>> if (IS_ERR(chunk_meta)) {
>>> ret = PTR_ERR(chunk_meta);
>>> goto fail_free_luns;
>>> }
>>>
>>> + if (factory_init && !retry &&
>>> + pblk_are_opened_chunks(pblk, chunk_meta)) {
>>> + pblk_close_opened_chunks(pblk, chunk_meta);
>>> + retry = true;
>>> + vfree(chunk_meta);
>>> + goto get_chunk_meta;
>>> + }
>>> +
>>> pblk->lines = kcalloc(l_mg->nr_lines, sizeof(struct pblk_line),
>>> GFP_KERNEL);
>>> if (!pblk->lines) {
>>> @@ -1244,7 +1254,7 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
>>> goto fail;
>>> }
>>>
>>> - ret = pblk_lines_init(pblk);
>>> + ret = pblk_lines_init(pblk, flags & NVM_TARGET_FACTORY);
>>> if (ret) {
>>> pblk_err(pblk, "could not initialize lines\n");
>>> goto fail_free_core;
>>> diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
>>> index b266563508e6..b248642c4dfb 100644
>>> --- a/drivers/lightnvm/pblk.h
>>> +++ b/drivers/lightnvm/pblk.h
>>> @@ -793,6 +793,8 @@ struct nvm_chk_meta *pblk_get_chunk_meta(struct pblk *pblk);
>>> struct nvm_chk_meta *pblk_chunk_get_off(struct pblk *pblk,
>>> struct nvm_chk_meta *lp,
>>> struct ppa_addr ppa);
>>> +void pblk_close_opened_chunks(struct pblk *pblk, struct nvm_chk_meta *_meta);
>>> +bool pblk_are_opened_chunks(struct pblk *pblk, struct nvm_chk_meta *_meta);
>>> void pblk_log_write_err(struct pblk *pblk, struct nvm_rq *rqd);
>>> void pblk_log_read_err(struct pblk *pblk, struct nvm_rq *rqd);
>>> int pblk_submit_io(struct pblk *pblk, struct nvm_rq *rqd);
>>> --
>>> 2.17.1
>>
>> I know that the OCSSD 2.0 spec does not allow to transition from open to
>> free, but to me this is a spec bug as there is no underlying issue in
>> reading an open block. Note that all controllers I know support this,
>> and the upcoming Denali spec. fixes this too.
>
> + Klaus whom I discussed this with.
> Yeah, i think that "early reset" is a nice feature. It would be nice
> to extend the OCSSD spec with a new capabilities bit indicating if
> this is indeed supported or not.
> Matias: what do you think?
>
>>
>> Besides, the factory flag is intended to start a pblk instance
>> immediately, without having to pay the price of padding any past device
>> state. If you still want to do this, I think this belongs in a user space tool.
>>
>
> Hear, hear!
>
> Serially padding any open chunks during -f create call would be
> terrible user experience.
> Lets say that padding a chunk takes one second, we would, in a
> worst-case scenario in an example disk, be stuck in a syscall for
> 1*64*1000 seconds ~ 17 hours.
>
You are both right - this can be time consuming. So we can drop the
"padding" part and let user do that.
What about changing this patch to at least print some warning on dmesg
when we have some open chunks in such a case?
> A tool, like dm-zoned's dmzadm would be the right approach, see
> Documentation/device-mapper/dm-zoned.txt
> All new pblk instances would then have to be pre-formatted with "pblkadm"
>
> A new physical storage format containing a superblock would also be a good idea.
>
> / Hans
>
next prev parent reply other threads:[~2019-03-04 12:56 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-27 17:14 [PATCH 00/13] lightnvm: bugfixes and improvements Igor Konopko
2019-02-27 17:14 ` [PATCH 01/13] lightnvm: pblk: Line reference fix in GC Igor Konopko
2019-03-01 12:20 ` Hans Holmberg
2019-03-04 7:18 ` Javier González
2019-03-04 12:40 ` Matias Bjørling
2019-02-27 17:14 ` [PATCH 02/13] lightnvm: pblk: Gracefully handle GC data malloc fail Igor Konopko
2019-02-28 17:08 ` Javier González
2019-03-01 12:50 ` Hans Holmberg
2019-03-04 12:38 ` Igor Konopko
2019-02-27 17:14 ` [PATCH 03/13] lightnvm: pblk: Fix put line back behaviour Igor Konopko
2019-03-01 13:27 ` Hans Holmberg
2019-03-04 7:22 ` Javier González
2019-02-27 17:14 ` [PATCH 04/13] lightnvm: pblk: Rollback in gc read Igor Konopko
2019-03-04 7:38 ` Javier González
2019-03-04 8:44 ` Hans Holmberg
2019-03-04 12:39 ` Igor Konopko
2019-03-04 12:42 ` Hans Holmberg
2019-03-04 12:49 ` Matias Bjørling
2019-02-27 17:14 ` [PATCH 05/13] lightnvm: pblk: Count all read errors in stats Igor Konopko
2019-03-04 7:42 ` Javier González
2019-03-04 9:02 ` Hans Holmberg
2019-03-04 9:23 ` Javier González
2019-03-04 11:41 ` Hans Holmberg
2019-03-04 11:45 ` Javier González
2019-03-04 12:42 ` Igor Konopko
2019-03-04 12:48 ` Hans Holmberg
2019-02-27 17:14 ` [PATCH 06/13] lightnvm: pblk: Ensure that erase is chunk aligned Igor Konopko
2019-03-04 7:48 ` Javier González
2019-03-04 9:05 ` Hans Holmberg
2019-03-04 9:11 ` Javier González
2019-03-04 11:43 ` Hans Holmberg
2019-03-04 12:44 ` Igor Konopko
2019-03-04 12:57 ` Hans Holmberg
2019-03-04 13:00 ` Matias Bjørling
2019-03-05 8:20 ` Hans Holmberg
2019-03-05 8:26 ` Igor Konopko
2019-03-05 8:40 ` Hans Holmberg
[not found] ` <61b7e62a-d229-95b1-2572-336ab1bd67cb@intel.com>
2019-03-05 8:55 ` Hans Holmberg
2019-02-27 17:14 ` [PATCH 07/13] lightnvm: pblk: Cleanly fail when there is not enough memory Igor Konopko
2019-03-04 7:53 ` Javier González
2019-03-04 9:24 ` Hans Holmberg
2019-03-04 12:46 ` Igor Konopko
2019-02-27 17:14 ` [PATCH 08/13] lightnvm: pblk: Set proper read stutus in bio Igor Konopko
2019-03-04 8:03 ` Javier González
2019-03-04 9:35 ` Hans Holmberg
2019-03-04 9:48 ` Javier González
2019-03-04 12:14 ` Hans Holmberg
2019-03-04 12:51 ` Igor Konopko
2019-03-04 13:08 ` Matias Bjørling
2019-03-04 13:45 ` Javier González
2019-03-04 15:12 ` Matias Bjørling
2019-03-05 6:43 ` Javier González
2019-03-04 13:04 ` Matias Bjørling
2019-03-04 13:21 ` Javier González
2019-02-27 17:14 ` [PATCH 09/13] lightnvm: pblk: Kick writer for flush requests Igor Konopko
2019-03-04 8:08 ` Javier González
2019-03-04 9:39 ` Hans Holmberg
2019-03-04 12:52 ` Igor Konopko
2019-02-27 17:14 ` [PATCH 10/13] lightnvm: pblk: Reduce L2P DRAM footprint Igor Konopko
2019-03-04 8:17 ` Javier González
2019-03-04 9:29 ` Hans Holmberg
2019-03-04 13:11 ` Matias Bjørling
2019-02-27 17:14 ` [PATCH 11/13] lightnvm: pblk: Remove unused smeta_ssec field Igor Konopko
2019-03-04 8:21 ` Javier González
2019-03-04 9:40 ` Hans Holmberg
2019-02-27 17:14 ` [PATCH 12/13] lightnvm: pblk: close opened chunks Igor Konopko
2019-03-04 8:27 ` Javier González
2019-03-04 10:05 ` Hans Holmberg
2019-03-04 12:56 ` Igor Konopko [this message]
2019-03-04 13:03 ` Hans Holmberg
2019-03-04 13:19 ` Matias Bjørling
2019-03-04 13:48 ` Javier González
2019-03-04 13:18 ` Matias Bjørling
2019-03-04 13:47 ` Javier González
2019-02-27 17:14 ` [PATCH 13/13] lightnvm: Inherit mdts from the parent nvme device Igor Konopko
2019-03-04 9:05 ` Javier González
2019-03-04 11:30 ` Hans Holmberg
2019-03-04 11:44 ` Javier González
2019-03-04 12:22 ` Hans Holmberg
2019-03-04 13:04 ` Igor Konopko
2019-03-04 13:16 ` Hans Holmberg
2019-03-04 14:06 ` Javier González
2019-03-04 13:19 ` Javier González
2019-03-04 13:25 ` Matias Bjørling
2019-03-04 13:44 ` Javier González
2019-03-04 14:24 ` Hans Holmberg
2019-03-04 14:27 ` Javier González
2019-03-04 14:58 ` Matias Bjørling
2019-02-28 16:36 ` [PATCH 00/13] lightnvm: bugfixes and improvements Matias Bjørling
2019-02-28 17:15 ` Javier González
2019-03-01 10:23 ` Hans Holmberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ec010fb-b49e-a3ce-a816-c1d193b53036@intel.com \
--to=igor.j.konopko@intel.com \
--cc=hans.holmberg@cnexlabs.com \
--cc=hans.ml.holmberg@owltronix.com \
--cc=javier@javigon.com \
--cc=klaus.jensen@cnexlabs.com \
--cc=linux-block@vger.kernel.org \
--cc=mb@lightnvm.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox