2015-10-28 18:54:56 +00:00
|
|
|
/*
|
|
|
|
* Copyright: Matias Bjorling <mb@bjorling.me>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version
|
|
|
|
* 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GENNVM_H_
|
|
|
|
#define GENNVM_H_
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
|
|
|
|
#include <linux/lightnvm.h>
|
|
|
|
|
2016-07-07 07:54:15 +00:00
|
|
|
struct gen_dev {
|
2015-11-16 14:34:37 +00:00
|
|
|
struct nvm_dev *dev;
|
|
|
|
|
2015-10-28 18:54:56 +00:00
|
|
|
int nr_luns;
|
2016-03-03 14:06:37 +00:00
|
|
|
struct list_head area_list;
|
2016-07-07 07:54:16 +00:00
|
|
|
|
|
|
|
struct mutex lock;
|
|
|
|
struct list_head targets;
|
2015-10-28 18:54:56 +00:00
|
|
|
};
|
|
|
|
|
lightnvm: eliminate nvm_lun abstraction in mm
In order to naturally support multi-target instances on an Open-Channel
SSD, targets should own the LUNs they get blocks from and manage
provisioning internally. This is done in several steps.
Since targets own the LUNs the are instantiated on top of and manage the
free block list internally, there is no need for a LUN abstraction in
the media manager. LUNs are intrinsically managed as in the physical
layout (ch:0,lun:0, ..., ch:0,lun:n, ch:1,lun:0, ch:1,lun:n, ...,
ch:m,lun:0, ch:m,lun:n) and given to the targets based on the target
creation ioctl. This simplifies LUN management and clears the path for a
partition manager to sit directly underneath LightNVM targets.
Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-28 21:39:10 +00:00
|
|
|
/* Map between virtual and physical channel and lun */
|
|
|
|
struct gen_ch_map {
|
|
|
|
int ch_off;
|
|
|
|
int nr_luns;
|
|
|
|
int *lun_offs;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gen_dev_map {
|
|
|
|
struct gen_ch_map *chnls;
|
|
|
|
int nr_chnls;
|
|
|
|
};
|
|
|
|
|
2016-07-07 07:54:15 +00:00
|
|
|
struct gen_area {
|
2016-03-03 14:06:37 +00:00
|
|
|
struct list_head list;
|
|
|
|
sector_t begin;
|
|
|
|
sector_t end; /* end is excluded */
|
|
|
|
};
|
2016-07-07 07:54:15 +00:00
|
|
|
|
lightnvm: eliminate nvm_lun abstraction in mm
In order to naturally support multi-target instances on an Open-Channel
SSD, targets should own the LUNs they get blocks from and manage
provisioning internally. This is done in several steps.
Since targets own the LUNs the are instantiated on top of and manage the
free block list internally, there is no need for a LUN abstraction in
the media manager. LUNs are intrinsically managed as in the physical
layout (ch:0,lun:0, ..., ch:0,lun:n, ch:1,lun:0, ch:1,lun:n, ...,
ch:m,lun:0, ch:m,lun:n) and given to the targets based on the target
creation ioctl. This simplifies LUN management and clears the path for a
partition manager to sit directly underneath LightNVM targets.
Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-28 21:39:10 +00:00
|
|
|
static inline void *ch_map_to_lun_offs(struct gen_ch_map *ch_map)
|
|
|
|
{
|
|
|
|
return ch_map + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef int (gen_trans_fn)(struct nvm_tgt_dev *, struct ppa_addr *);
|
|
|
|
|
2016-07-07 07:54:15 +00:00
|
|
|
#define gen_for_each_lun(bm, lun, i) \
|
2015-10-28 18:54:56 +00:00
|
|
|
for ((i) = 0, lun = &(bm)->luns[0]; \
|
|
|
|
(i) < (bm)->nr_luns; (i)++, lun = &(bm)->luns[(i)])
|
|
|
|
|
|
|
|
#endif /* GENNVM_H_ */
|