From: "Matias Bjørling" <mb@lightnvm.io>
To: Igor Konopko <igor.j.konopko@intel.com>,
javier@javigon.com, hans.holmberg@cnexlabs.com
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH v3 10/10] lightnvm: track inflight target creations
Date: Fri, 5 Apr 2019 15:48:36 +0200 [thread overview]
Message-ID: <cd6e0671-ff0e-dcbe-4aff-18a43432a8b5@lightnvm.io> (raw)
In-Reply-To: <20190327123901.12323-11-igor.j.konopko@intel.com>
On 3/27/19 1:39 PM, Igor Konopko wrote:
> This patch adds a counter, which is responsible for tracking inflight
> target creations.
>
> When creation process is still in progress, target is not yet on
> targets list. This causes a chance for removing whole lightnvm
> subsystem by calling nvm_unregister() in the meantime and finally by
> causing kernel panic inside target init function.
>
> With this patch we are able to track such a scenarios and wait with
> completing nvm_unregister() and freeing memory until target creation
> will be completed.
>
> Signed-off-by: Igor Konopko <igor.j.konopko@intel.com>
> ---
> drivers/lightnvm/core.c | 19 ++++++++++++++++++-
> include/linux/lightnvm.h | 2 ++
> 2 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index e2abe88..62ed662 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -1083,6 +1083,7 @@ static int nvm_core_init(struct nvm_dev *dev)
> INIT_LIST_HEAD(&dev->targets);
> mutex_init(&dev->mlock);
> spin_lock_init(&dev->lock);
> + dev->create_inflight = 0;
>
> ret = nvm_register_map(dev);
> if (ret)
> @@ -1180,6 +1181,11 @@ void nvm_unregister(struct nvm_dev *dev)
> struct nvm_target *t, *tmp;
>
> mutex_lock(&dev->mlock);
> + while (dev->create_inflight > 0) {
> + mutex_unlock(&dev->mlock);
> + io_schedule();
> + mutex_lock(&dev->mlock);
> + }
> list_for_each_entry_safe(t, tmp, &dev->targets, list) {
> if (t->dev->parent != dev)
> continue;
> @@ -1198,6 +1204,7 @@ EXPORT_SYMBOL(nvm_unregister);
> static int __nvm_configure_create(struct nvm_ioctl_create *create)
> {
> struct nvm_dev *dev;
> + int ret;
>
> down_write(&nvm_lock);
> dev = nvm_find_nvm_dev(create->dev);
> @@ -1208,7 +1215,17 @@ static int __nvm_configure_create(struct nvm_ioctl_create *create)
> return -EINVAL;
> }
>
> - return nvm_create_tgt(dev, create);
> + mutex_lock(&dev->mlock);
> + dev->create_inflight++;
> + mutex_unlock(&dev->mlock);
> +
> + ret = nvm_create_tgt(dev, create);
> +
> + mutex_lock(&dev->mlock);
> + dev->create_inflight--;
> + mutex_unlock(&dev->mlock);
> +
> + return ret;
> }
>
> static long nvm_ioctl_info(struct file *file, void __user *arg)
> diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
> index d3b0270..e462d1d 100644
> --- a/include/linux/lightnvm.h
> +++ b/include/linux/lightnvm.h
> @@ -428,6 +428,8 @@ struct nvm_dev {
> char name[DISK_NAME_LEN];
> void *private_data;
>
> + int create_inflight;
> +
> void *rmap;
>
> struct mutex mlock;
>
Hi Igor,
I think this may be better implemented with kref. Such that target
creator can take a reference upon target initialize and release it again
afterwards. Then the one turning of the lights can get to run the final
cleanup routine.
-Matias
next prev parent reply other threads:[~2019-04-05 13:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-27 12:38 [PATCH v3 00/10] lightnvm: next set of improvements for 5.2 Igor Konopko
2019-03-27 12:38 ` [PATCH v3 01/10] lightnvm: pblk: IO path reorganization Igor Konopko
2019-03-27 12:38 ` [PATCH v3 02/10] lightnvm: pblk: simplify partial read path Igor Konopko
2019-03-29 9:12 ` Hans Holmberg
2019-03-30 5:02 ` Heiner Litz
2019-04-01 15:29 ` Igor Konopko
2019-03-27 12:38 ` [PATCH v3 03/10] lightnvm: pblk: propagate errors when reading meta Igor Konopko
2019-03-27 20:25 ` Matias Bjørling
2019-03-27 12:38 ` [PATCH v3 04/10] lightnvm: pblk: recover only written metadata Igor Konopko
2019-03-27 12:38 ` [PATCH v3 05/10] lightnvm: pblk: wait for inflight IOs in recovery Igor Konopko
2019-03-27 12:38 ` [PATCH v3 06/10] lightnvm: pblk: remove internal IO timeout Igor Konopko
2019-03-27 12:38 ` [PATCH v3 07/10] lightnvm: pblk: store multiple copies of smeta Igor Konopko
2019-03-27 12:38 ` [PATCH v3 08/10] lightnvm: pblk: GC error handling Igor Konopko
2019-03-27 12:39 ` [PATCH v3 09/10] lightnvm: pblk: use nvm_rq_to_ppa_list() Igor Konopko
2019-03-27 12:39 ` [PATCH v3 10/10] lightnvm: track inflight target creations Igor Konopko
2019-04-05 13:48 ` Matias Bjørling [this message]
2019-04-03 7:12 ` [PATCH v3 00/10] lightnvm: next set of improvements for 5.2 Hans Holmberg
2019-04-05 6:31 ` Igor Konopko
2019-04-05 13:40 ` Matias Bjørling
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=cd6e0671-ff0e-dcbe-4aff-18a43432a8b5@lightnvm.io \
--to=mb@lightnvm.io \
--cc=hans.holmberg@cnexlabs.com \
--cc=igor.j.konopko@intel.com \
--cc=javier@javigon.com \
--cc=linux-block@vger.kernel.org \
/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