All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matias Bjørling" <mb@lightnvm.io>
To: Wenwei Tao <ww.tao0320@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH v2 1/2] lightnvm: specify target's logical address area
Date: Tue, 26 Jan 2016 15:52:26 +0100	[thread overview]
Message-ID: <56A7882A.50108@lightnvm.io> (raw)
In-Reply-To: <1453811633-3721-1-git-send-email-ww.tao0320@gmail.com>

On 01/26/2016 01:33 PM, Wenwei Tao wrote:
> We can create more than one target on a lightnvm
> device by specifying its begin lun and end lun.
> 
> But only specify the physical address area is not
> enough, we need to get the corresponding non-
> intersection logical address area division from
> the backend device's logcial address space.
> Otherwise the targets on the device might use
> the same logical addresses cause incorrect
> information in the device's l2p table.
> 
> Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
> ---
> Changes since v1:
> - rename some variables
> - add parentheses for clarity
> - make gennvm_get_area return int, and add one more sector_t*  parameter
> to pass the begin sector of the corresponding target
> - rebase to v4.5-rc1
> 
>  drivers/lightnvm/core.c   |  1 +
>  drivers/lightnvm/gennvm.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/lightnvm/gennvm.h |  6 +++++
>  drivers/lightnvm/rrpc.c   | 45 +++++++++++++++++++++++++++++++++---
>  drivers/lightnvm/rrpc.h   |  1 +
>  include/linux/lightnvm.h  |  8 +++++++
>  6 files changed, 117 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index 33224cb..27a59e8 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -470,6 +470,7 @@ static int nvm_core_init(struct nvm_dev *dev)
>  	dev->total_pages = dev->total_blocks * dev->pgs_per_blk;
>  	INIT_LIST_HEAD(&dev->online_targets);
>  	mutex_init(&dev->mlock);
> +	spin_lock_init(&dev->lock);
>  
>  	return 0;
>  }
> diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
> index 7fb725b..34ea4ff 100644
> --- a/drivers/lightnvm/gennvm.c
> +++ b/drivers/lightnvm/gennvm.c
> @@ -20,6 +20,60 @@
>  
>  #include "gennvm.h"
>  
> +static int gennvm_get_area(struct nvm_dev *dev, sector_t *begin_sect,
> +							sector_t size)
> +{
> +	struct gen_nvm *gn = dev->mp;
> +	struct gennvm_area *area, *prev;
> +	sector_t begin = 0;
> +	int page_size = dev->sec_size * dev->sec_per_pg;
> +	sector_t max_sectors = (page_size * dev->total_pages) >> 9;
> +
> +	if (size > max_sectors)
> +		return -EINVAL;
> +	area = kmalloc(sizeof(struct gennvm_area), GFP_KERNEL);
> +	if (!area)
> +		return -ENOMEM;
> +
> +	spin_lock(&dev->lock);
> +	list_for_each_entry(prev, &gn->area_list, list) {
> +		if (begin + size > prev->begin) {
> +			begin = prev->end;
> +			continue;
> +		}
> +		break;
> +	}
> +
> +	if ((begin + size) > max_sectors) {
> +		spin_unlock(&dev->lock);
> +		kfree(area);
> +		return -EINVAL;
> +	}
> +
> +	area->begin = *begin_sect =  begin;
> +	area->end = begin + size;
> +	list_add(&area->list, &prev->list);
> +	spin_unlock(&dev->lock);
> +	return 0;
> +}
> +
> +static void gennvm_put_area(struct nvm_dev *dev, sector_t begin)
> +{
> +	struct gen_nvm *gn = dev->mp;
> +	struct gennvm_area *area;
> +
> +	spin_lock(&dev->lock);
> +	list_for_each_entry(area, &gn->area_list, list) {
> +		if (area->begin == begin) {
> +			list_del(&area->list);
> +			spin_unlock(&dev->lock);
> +			kfree(area);
> +			return;
> +		}
> +	}
> +	spin_unlock(&dev->lock);
> +}
> +
>  static void gennvm_blocks_free(struct nvm_dev *dev)
>  {
>  	struct gen_nvm *gn = dev->mp;
> @@ -230,6 +284,7 @@ static int gennvm_register(struct nvm_dev *dev)
>  
>  	gn->dev = dev;
>  	gn->nr_luns = dev->nr_luns;
> +	INIT_LIST_HEAD(&gn->area_list);
>  	dev->mp = gn;
>  
>  	ret = gennvm_luns_init(dev, gn);
> @@ -466,6 +521,10 @@ static struct nvmm_type gennvm = {
>  
>  	.get_lun		= gennvm_get_lun,
>  	.lun_info_print		= gennvm_lun_info_print,
> +
> +	.get_area		= gennvm_get_area,
> +	.put_area		= gennvm_put_area,
> +
>  };
>  
>  static int __init gennvm_module_init(void)
> diff --git a/drivers/lightnvm/gennvm.h b/drivers/lightnvm/gennvm.h
> index 9c24b5b..04d7c23 100644
> --- a/drivers/lightnvm/gennvm.h
> +++ b/drivers/lightnvm/gennvm.h
> @@ -39,8 +39,14 @@ struct gen_nvm {
>  
>  	int nr_luns;
>  	struct gen_lun *luns;
> +	struct list_head area_list;
>  };
>  
> +struct gennvm_area {
> +	struct list_head list;
> +	sector_t begin;
> +	sector_t end;	/* end is excluded */
> +};
>  #define gennvm_for_each_lun(bm, lun, i) \
>  		for ((i) = 0, lun = &(bm)->luns[0]; \
>  			(i) < (bm)->nr_luns; (i)++, lun = &(bm)->luns[(i)])
> diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
> index d8c7595..c8c27f9 100644
> --- a/drivers/lightnvm/rrpc.c
> +++ b/drivers/lightnvm/rrpc.c
> @@ -1042,7 +1042,18 @@ static int rrpc_map_init(struct rrpc *rrpc)
>  {
>  	struct nvm_dev *dev = rrpc->dev;
>  	sector_t i;
> -	int ret;
> +	u64 slba;
> +	int ret, page_size;
> +	int page_shfit, nr_pages;

Did you mean page_shift here?

  parent reply	other threads:[~2016-01-26 14:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-26 12:33 [PATCH v2 1/2] lightnvm: specify target's logical address area Wenwei Tao
2016-01-26 12:33 ` [PATCH v2 2/2] lightnvm: add non-continuous lun target creation support Wenwei Tao
2016-01-27  9:44   ` Matias Bjørling
2016-01-28  8:50     ` Wenwei Tao
2016-01-28  9:09       ` Matias Bjørling
2016-01-28 10:19         ` Wenwei Tao
2016-01-26 14:52 ` Matias Bjørling [this message]
2016-01-27  2:21   ` [PATCH v2 1/2] lightnvm: specify target's logical address area Wenwei Tao
2016-01-27  5:52     ` Matias Bjørling
2016-01-27  6:06       ` Wenwei Tao
2016-01-27  9:36         ` Matias Bjørling
2016-01-27 12:47           ` Wenwei Tao
2016-01-27 13:26             ` Matias Bjørling
2016-01-27 14:58               ` Wenwei Tao
2016-01-27 19:46                 ` 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=56A7882A.50108@lightnvm.io \
    --to=mb@lightnvm.io \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ww.tao0320@gmail.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 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.