Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755549AbbLDIkn (ORCPT ); Fri, 4 Dec 2015 03:40:43 -0500 Received: from mail-ig0-f174.google.com ([209.85.213.174]:38651 "EHLO mail-ig0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755372AbbLDIkl convert rfc822-to-8bit (ORCPT ); Fri, 4 Dec 2015 03:40:41 -0500 MIME-Version: 1.0 In-Reply-To: <1449058583-27940-3-git-send-email-m@bjorling.me> References: <1449058583-27940-1-git-send-email-m@bjorling.me> <1449058583-27940-3-git-send-email-m@bjorling.me> Date: Fri, 4 Dec 2015 16:40:41 +0800 Message-ID: Subject: Re: [PATCH RFC 3/3] lightnvm: fix media mgr registration From: Wenwei Tao To: =?UTF-8?Q?Matias_Bj=C3=B8rling?= Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2208 Lines: 64 2015-12-02 20:16 GMT+08:00 Matias Bjørling : > 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 > --- > 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 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/