linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matias Bjørling" <mb@lightnvm.io>
To: "Javier González" <jg@lightnvm.io>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Javier González" <javier@cnexlabs.com>,
	"Matias Bjørling" <matias@cnexlabs.com>
Subject: Re: [PATCH 1/4] lightnvm: double-clear of dev->lun_map on target init error
Date: Tue, 11 Apr 2017 12:41:21 +0200	[thread overview]
Message-ID: <64c22c5c-9fd0-ffcf-5762-bef15489ee1b@lightnvm.io> (raw)
In-Reply-To: <1491589874-26818-1-git-send-email-javier@cnexlabs.com>

On 04/07/2017 08:31 PM, Javier González wrote:
> The dev->lun_map bits are cleared twice if an target init error occurs.
> First in the target clean routine, and then next in the nvm_tgt_create
> error function. Make sure that it is only cleared once by extending
> nvm_remove_tgt_devi() with a clear bit, such that clearing of bits can
> ignored when cleaning up a successful initialized target.
>
> Signed-off-by: Javier González <javier@cnexlabs.com>
> Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
> ---
>  drivers/lightnvm/core.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index 2122922..da4c082 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -89,7 +89,7 @@ static void nvm_release_luns_err(struct nvm_dev *dev, int lun_begin,
>  		WARN_ON(!test_and_clear_bit(i, dev->lun_map));
>  }
>
> -static void nvm_remove_tgt_dev(struct nvm_tgt_dev *tgt_dev)
> +static void nvm_remove_tgt_dev(struct nvm_tgt_dev *tgt_dev, int clear)
>  {
>  	struct nvm_dev *dev = tgt_dev->parent;
>  	struct nvm_dev_map *dev_map = tgt_dev->map;
> @@ -100,11 +100,13 @@ static void nvm_remove_tgt_dev(struct nvm_tgt_dev *tgt_dev)
>  		int *lun_offs = ch_map->lun_offs;
>  		int ch = i + ch_map->ch_off;
>
> -		for (j = 0; j < ch_map->nr_luns; j++) {
> -			int lun = j + lun_offs[j];
> -			int lunid = (ch * dev->geo.luns_per_chnl) + lun;
> +		if (clear) {
> +			for (j = 0; j < ch_map->nr_luns; j++) {
> +				int lun = j + lun_offs[j];
> +				int lunid = (ch * dev->geo.luns_per_chnl) + lun;
>
> -			WARN_ON(!test_and_clear_bit(lunid, dev->lun_map));
> +				WARN_ON(!test_and_clear_bit(lunid, dev->lun_map));
> +			}
>  		}
>
>  		kfree(ch_map->lun_offs);
> @@ -309,7 +311,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
>  err_queue:
>  	blk_cleanup_queue(tqueue);
>  err_dev:
> -	nvm_remove_tgt_dev(tgt_dev);
> +	nvm_remove_tgt_dev(tgt_dev, 0);
>  err_t:
>  	kfree(t);
>  err_reserve:
> @@ -332,7 +334,7 @@ static void __nvm_remove_target(struct nvm_target *t)
>  	if (tt->exit)
>  		tt->exit(tdisk->private_data);
>
> -	nvm_remove_tgt_dev(t->dev);
> +	nvm_remove_tgt_dev(t->dev, 1);
>  	put_disk(tdisk);
>
>  	list_del(&t->list);
>

Thanks. Applied for 4.12.

      parent reply	other threads:[~2017-04-11 10:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 18:31 [PATCH 1/4] lightnvm: double-clear of dev->lun_map on target init error Javier González
2017-04-07 18:31 ` [PATCH 2/4] lightnvm: fix cleanup order of disk on " Javier González
2017-04-11 10:41   ` Matias Bjørling
2017-04-07 18:31 ` [PATCH 3/4] lightnvm: bad type conversion for nvme control bits Javier González
2017-04-11 10:41   ` Matias Bjørling
2017-04-07 18:31 ` [PATCH 4/4] lightnvm: allow to init targets on factory mode Javier González
2017-04-11 10:41   ` Matias Bjørling
2017-04-11 10:41 ` Matias Bjørling [this message]

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=64c22c5c-9fd0-ffcf-5762-bef15489ee1b@lightnvm.io \
    --to=mb@lightnvm.io \
    --cc=javier@cnexlabs.com \
    --cc=jg@lightnvm.io \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matias@cnexlabs.com \
    /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;
as well as URLs for NNTP newsgroup(s).