From: "Javier González" <javier@javigon.com>
To: Marcin Dziegielewski <marcin.dziegielewski@intel.com>
Cc: "Matias Bjørling" <mb@lightnvm.io>,
"Hans Holmberg" <hans.holmberg@cnexlabs.com>,
linux-block@vger.kernel.org, "Konopko,
Igor J" <igor.j.konopko@intel.com>
Subject: Re: [PATCH] lightnvm: add a lock to prevent before the race condition on pblk remove
Date: Thu, 21 Mar 2019 10:17:55 +0100 [thread overview]
Message-ID: <0673B702-0816-4FB6-B8BB-A08F8369E422@javigon.com> (raw)
In-Reply-To: <1553005484-10584-1-git-send-email-marcin.dziegielewski@intel.com>
[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]
> On 19 Mar 2019, at 15.24, Marcin Dziegielewski <marcin.dziegielewski@intel.com> wrote:
>
> When we trigger nvm target remove during device hot unplug, we
> have a chance to hit general protection fault caused by use of
> nvm_dev which was freed from another (hot unplug) thread (in
> nvm_unregister function).
>
> This patch introduce lock in nvme_ioctl_dev_remove function to
> prevent us before a situation like described above.
>
> Signed-off-by: Marcin Dziegielewski <marcin.dziegielewski@intel.com>
> ---
> drivers/lightnvm/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index 5f82036..84f0b9a 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -1335,11 +1335,13 @@ static long nvm_ioctl_dev_remove(struct file *file, void __user *arg)
> return -EINVAL;
> }
>
> + down_read(&nvm_lock);
> list_for_each_entry(dev, &nvm_devices, devices) {
> ret = nvm_remove_tgt(dev, &remove);
> if (!ret)
> break;
> }
> + up_read(&nvm_lock);
>
> return ret;
> }
> --
> 1.8.3.1
Looks good to me.
Reviewed-by: Javier González <javier@javigon.com>
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-03-21 9:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 14:24 [PATCH] lightnvm: add a lock to prevent before the race condition on pblk remove Marcin Dziegielewski
2019-03-21 9:17 ` Javier González [this message]
2019-03-25 11:05 ` 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=0673B702-0816-4FB6-B8BB-A08F8369E422@javigon.com \
--to=javier@javigon.com \
--cc=hans.holmberg@cnexlabs.com \
--cc=igor.j.konopko@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=marcin.dziegielewski@intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.