Re: [PATCH RFC 3/3] lightnvm: fix media mgr registration
From: Wenwei Tao
Date: Fri Dec 04 2015 - 03:40:46 EST
2015-12-02 20:16 GMT+08:00 Matias BjÃrling <m@xxxxxxxxxxx>:
> The ppa pool can be used at media manager registration.
> Therefore the ppa pool should be allocated before registering.
>
> If a media manager can't be found, this should not lead to the
> device being unallocated. A media manager can be registered later, that
> can manage a device. Only warn if a media manager fails initialization.
>
> Additionally, protect against the media managed being registered or
> deregistered while looping through available media managers. This was
> reported by Wenwei Tao.
>
> Signed-off-by: Matias BjÃrling <m@xxxxxxxxxxx>
> ---
> drivers/lightnvm/core.c | 79 ++++++++++++++++++++++++-------------------------
> 1 file changed, 39 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index 4601cf1..f4d5291 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -97,15 +97,47 @@ static struct nvmm_type *nvm_find_mgr_type(const char *name)
> return NULL;
> }
>
> +struct nvmm_type *nvm_init_mgr(struct nvm_dev *dev)
> +{
> + struct nvmm_type *mt;
> + int ret;
> +
> + lockdep_assert_held(&nvm_lock);
> +
> + list_for_each_entry(mt, &nvm_mgrs, list) {
> + ret = mt->register_mgr(dev);
> + if (ret < 0) {
> + pr_err("nvm: media mgr failed to init (%d) on dev %s\n",
> + ret, dev->name);
> + return NULL; /* initialization failed */
Do we just return or continue to try next media manager ? In my commit
commit d0a712ceb83ebaea32d520825ee7b997f59b168f
Author: Wenwei Tao <ww.tao0320@xxxxxxxxx>
Date: Sat Nov 28 16:49:28 2015 +0100
lightnvm: missing nvm_lock acquire
I use the second solution.
> + } else if (ret > 0)
> + return mt;
> + }
> +
> + return NULL;
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/