Commit da2d7cb8 authored by Javier González's avatar Javier González Committed by Jens Axboe

lightnvm: use target nvm on target-specific ops.

On target-specific operations pass on nvm_tgt_dev instead of the generic
nvm device.
Signed-off-by: default avatarJavier González <javier@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <m@bjorling.me>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent a279006a
...@@ -86,8 +86,7 @@ void *nvm_dev_dma_alloc(struct nvm_dev *dev, gfp_t mem_flags, ...@@ -86,8 +86,7 @@ void *nvm_dev_dma_alloc(struct nvm_dev *dev, gfp_t mem_flags,
} }
EXPORT_SYMBOL(nvm_dev_dma_alloc); EXPORT_SYMBOL(nvm_dev_dma_alloc);
void nvm_dev_dma_free(struct nvm_dev *dev, void *addr, void nvm_dev_dma_free(struct nvm_dev *dev, void *addr, dma_addr_t dma_handler)
dma_addr_t dma_handler)
{ {
dev->ops->dev_dma_free(dev->dma_pool, addr, dma_handler); dev->ops->dev_dma_free(dev->dma_pool, addr, dma_handler);
} }
...@@ -227,9 +226,11 @@ int nvm_erase_blk(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p, int flags) ...@@ -227,9 +226,11 @@ int nvm_erase_blk(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p, int flags)
} }
EXPORT_SYMBOL(nvm_erase_blk); EXPORT_SYMBOL(nvm_erase_blk);
int nvm_get_l2p_tbl(struct nvm_dev *dev, u64 slba, u32 nlb, int nvm_get_l2p_tbl(struct nvm_tgt_dev *tgt_dev, u64 slba, u32 nlb,
nvm_l2p_update_fn *update_l2p, void *priv) nvm_l2p_update_fn *update_l2p, void *priv)
{ {
struct nvm_dev *dev = tgt_dev->parent;
if (!dev->ops->get_l2p_tbl) if (!dev->ops->get_l2p_tbl)
return 0; return 0;
...@@ -237,14 +238,18 @@ int nvm_get_l2p_tbl(struct nvm_dev *dev, u64 slba, u32 nlb, ...@@ -237,14 +238,18 @@ int nvm_get_l2p_tbl(struct nvm_dev *dev, u64 slba, u32 nlb,
} }
EXPORT_SYMBOL(nvm_get_l2p_tbl); EXPORT_SYMBOL(nvm_get_l2p_tbl);
int nvm_get_area(struct nvm_dev *dev, sector_t *lba, sector_t len) int nvm_get_area(struct nvm_tgt_dev *tgt_dev, sector_t *lba, sector_t len)
{ {
struct nvm_dev *dev = tgt_dev->parent;
return dev->mt->get_area(dev, lba, len); return dev->mt->get_area(dev, lba, len);
} }
EXPORT_SYMBOL(nvm_get_area); EXPORT_SYMBOL(nvm_get_area);
void nvm_put_area(struct nvm_dev *dev, sector_t lba) void nvm_put_area(struct nvm_tgt_dev *tgt_dev, sector_t lba)
{ {
struct nvm_dev *dev = tgt_dev->parent;
dev->mt->put_area(dev, lba); dev->mt->put_area(dev, lba);
} }
EXPORT_SYMBOL(nvm_put_area); EXPORT_SYMBOL(nvm_put_area);
......
...@@ -983,8 +983,8 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio, ...@@ -983,8 +983,8 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio,
if (!(flags & NVM_IOTYPE_GC)) { if (!(flags & NVM_IOTYPE_GC)) {
rrpc_unlock_rq(rrpc, rqd); rrpc_unlock_rq(rrpc, rqd);
if (rqd->nr_ppas > 1) if (rqd->nr_ppas > 1)
nvm_dev_dma_free(dev->parent, nvm_dev_dma_free(dev->parent, rqd->ppa_list,
rqd->ppa_list, rqd->dma_ppa_list); rqd->dma_ppa_list);
} }
return NVM_IO_ERR; return NVM_IO_ERR;
} }
...@@ -1116,7 +1116,7 @@ static int rrpc_l2p_update(u64 slba, u32 nlb, __le64 *entries, void *private) ...@@ -1116,7 +1116,7 @@ static int rrpc_l2p_update(u64 slba, u32 nlb, __le64 *entries, void *private)
div_u64_rem(pba, rrpc->nr_sects, &mod); div_u64_rem(pba, rrpc->nr_sects, &mod);
gaddr = rrpc_recov_addr(dev->parent, pba); gaddr = rrpc_recov_addr(dev, pba);
rlun = rrpc_ppa_to_lun(rrpc, gaddr); rlun = rrpc_ppa_to_lun(rrpc, gaddr);
if (!rlun) { if (!rlun) {
pr_err("rrpc: l2p corruption on lba %llu\n", pr_err("rrpc: l2p corruption on lba %llu\n",
...@@ -1167,8 +1167,8 @@ static int rrpc_map_init(struct rrpc *rrpc) ...@@ -1167,8 +1167,8 @@ static int rrpc_map_init(struct rrpc *rrpc)
} }
/* Bring up the mapping table from device */ /* Bring up the mapping table from device */
ret = nvm_get_l2p_tbl(dev->parent, rrpc->soffset, rrpc->nr_sects, ret = nvm_get_l2p_tbl(dev, rrpc->soffset, rrpc->nr_sects,
rrpc_l2p_update, rrpc); rrpc_l2p_update, rrpc);
if (ret) { if (ret) {
pr_err("nvm: rrpc: could not read L2P table.\n"); pr_err("nvm: rrpc: could not read L2P table.\n");
return -EINVAL; return -EINVAL;
...@@ -1376,7 +1376,7 @@ static int rrpc_area_init(struct rrpc *rrpc, sector_t *begin) ...@@ -1376,7 +1376,7 @@ static int rrpc_area_init(struct rrpc *rrpc, sector_t *begin)
size >>= 9; size >>= 9;
ret = nvm_get_area(dev->parent, begin, size); ret = nvm_get_area(dev, begin, size);
if (!ret) if (!ret)
*begin >>= (ilog2(dev->geo.sec_size) - 9); *begin >>= (ilog2(dev->geo.sec_size) - 9);
...@@ -1388,7 +1388,7 @@ static void rrpc_area_free(struct rrpc *rrpc) ...@@ -1388,7 +1388,7 @@ static void rrpc_area_free(struct rrpc *rrpc)
struct nvm_tgt_dev *dev = rrpc->dev; struct nvm_tgt_dev *dev = rrpc->dev;
sector_t begin = rrpc->soffset << (ilog2(dev->geo.sec_size) - 9); sector_t begin = rrpc->soffset << (ilog2(dev->geo.sec_size) - 9);
nvm_put_area(dev->parent, begin); nvm_put_area(dev, begin);
} }
static void rrpc_free(struct rrpc *rrpc) static void rrpc_free(struct rrpc *rrpc)
......
...@@ -184,7 +184,7 @@ static inline struct ppa_addr rrpc_linear_to_generic_addr(struct nvm_geo *geo, ...@@ -184,7 +184,7 @@ static inline struct ppa_addr rrpc_linear_to_generic_addr(struct nvm_geo *geo,
return l; return l;
} }
static inline struct ppa_addr rrpc_recov_addr(struct nvm_dev *dev, u64 pba) static inline struct ppa_addr rrpc_recov_addr(struct nvm_tgt_dev *dev, u64 pba)
{ {
return linear_to_generic_addr(&dev->geo, pba); return linear_to_generic_addr(&dev->geo, pba);
} }
......
...@@ -538,10 +538,10 @@ extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *, ...@@ -538,10 +538,10 @@ extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *,
extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *); extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *);
extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr *, int, int); extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr *, int, int);
extern int nvm_erase_blk(struct nvm_tgt_dev *, struct ppa_addr *, int); extern int nvm_erase_blk(struct nvm_tgt_dev *, struct ppa_addr *, int);
extern int nvm_get_l2p_tbl(struct nvm_dev *, u64, u32, nvm_l2p_update_fn *, extern int nvm_get_l2p_tbl(struct nvm_tgt_dev *, u64, u32, nvm_l2p_update_fn *,
void *); void *);
extern int nvm_get_area(struct nvm_dev *, sector_t *, sector_t); extern int nvm_get_area(struct nvm_tgt_dev *, sector_t *, sector_t);
extern void nvm_put_area(struct nvm_dev *, sector_t); extern void nvm_put_area(struct nvm_tgt_dev *, sector_t);
extern void nvm_end_io(struct nvm_rq *, int); extern void nvm_end_io(struct nvm_rq *, int);
extern int nvm_submit_ppa(struct nvm_dev *, struct ppa_addr *, int, int, int, extern int nvm_submit_ppa(struct nvm_dev *, struct ppa_addr *, int, int, int,
void *, int); void *, int);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment