Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754171AbbKXSvI (ORCPT ); Tue, 24 Nov 2015 13:51:08 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:34369 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752190AbbKXSvE (ORCPT ); Tue, 24 Nov 2015 13:51:04 -0500 Message-ID: <5654B195.4050406@lightnvm.io> Date: Tue, 24 Nov 2015 19:51:01 +0100 From: Matias User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Wenwei Tao CC: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [PATCH] lightnvm: remove targets when corresponding nvm device exit References: <1448380988-3988-1-git-send-email-ww.tao0320@gmail.com> In-Reply-To: <1448380988-3988-1-git-send-email-ww.tao0320@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2130 Lines: 65 On 11/24/2015 05:03 PM, Wenwei Tao wrote: > the target should be unreachable when underlying device was gone. > > Signed-off-by: Wenwei Tao > --- > drivers/lightnvm/core.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c > index f659e60..b95c6c4 100644 > --- a/drivers/lightnvm/core.c > +++ b/drivers/lightnvm/core.c > @@ -278,10 +278,18 @@ err: > return ret; > } > > +static void nvm_remove_target(struct nvm_target *t); > + You can move the hole declaration up here. > static void nvm_exit(struct nvm_dev *dev) > { > + struct nvm_target *t, *n; > + > if (dev->ppalist_pool) > dev->ops->destroy_dma_pool(dev->ppalist_pool); > + down_write(&nvm_lock); > + list_for_each_entry_safe(t, n, &dev->online_targets, list) > + nvm_remove_target(t); > + up_write(&nvm_lock); list_for_each_entry_safe should be enough here. Actually, we should properly block any creations of new targets when nvm_exit is called. To prevent new ones to be created while we clean up. Let me know if you want to submit a patch for this. Else I'll just apply this one with the suggested changes. Thanks Tao. > nvm_free(dev); > > pr_info("nvm: successfully unloaded\n"); > @@ -496,13 +504,13 @@ static int __nvm_configure_create(struct nvm_ioctl_create *create) > > static int __nvm_configure_remove(struct nvm_ioctl_remove *remove) > { > - struct nvm_target *t = NULL; > + struct nvm_target *n, *t = NULL; > struct nvm_dev *dev; > int ret = -1; > > down_write(&nvm_lock); > list_for_each_entry(dev, &nvm_devices, devices) > - list_for_each_entry(t, &dev->online_targets, list) { > + list_for_each_entry_safe(t, n, &dev->online_targets, list) { > if (!strcmp(remove->tgtname, t->disk->disk_name)) { > nvm_remove_target(t); > ret = 0; > -- 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/