mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 00:21:59 +00:00
lightnvm: store rrpc->soffset in device sector size
Since we mainly use soffset in device sector size, we therefore store this value in rrpc->soffset, instead of the offset in 512byte sector size. This eliminates the "(ilog2(dev->sec_size) - 9)" calculation on each I/O. Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com> Updated patch description. Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
parent
66e3d07f75
commit
909049a719
@ -1039,11 +1039,8 @@ static int rrpc_map_init(struct rrpc *rrpc)
|
|||||||
{
|
{
|
||||||
struct nvm_dev *dev = rrpc->dev;
|
struct nvm_dev *dev = rrpc->dev;
|
||||||
sector_t i;
|
sector_t i;
|
||||||
u64 slba;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
slba = rrpc->soffset >> (ilog2(dev->sec_size) - 9);
|
|
||||||
|
|
||||||
rrpc->trans_map = vzalloc(sizeof(struct rrpc_addr) * rrpc->nr_sects);
|
rrpc->trans_map = vzalloc(sizeof(struct rrpc_addr) * rrpc->nr_sects);
|
||||||
if (!rrpc->trans_map)
|
if (!rrpc->trans_map)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -1065,8 +1062,8 @@ static int rrpc_map_init(struct rrpc *rrpc)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Bring up the mapping table from device */
|
/* Bring up the mapping table from device */
|
||||||
ret = dev->ops->get_l2p_tbl(dev, slba, rrpc->nr_sects, rrpc_l2p_update,
|
ret = dev->ops->get_l2p_tbl(dev, rrpc->soffset, rrpc->nr_sects,
|
||||||
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;
|
||||||
@ -1220,18 +1217,24 @@ static int rrpc_area_init(struct rrpc *rrpc, sector_t *begin)
|
|||||||
struct nvm_dev *dev = rrpc->dev;
|
struct nvm_dev *dev = rrpc->dev;
|
||||||
struct nvmm_type *mt = dev->mt;
|
struct nvmm_type *mt = dev->mt;
|
||||||
sector_t size = rrpc->nr_sects * dev->sec_size;
|
sector_t size = rrpc->nr_sects * dev->sec_size;
|
||||||
|
int ret;
|
||||||
|
|
||||||
size >>= 9;
|
size >>= 9;
|
||||||
|
|
||||||
return mt->get_area(dev, begin, size);
|
ret = mt->get_area(dev, begin, size);
|
||||||
|
if (!ret)
|
||||||
|
*begin >>= (ilog2(dev->sec_size) - 9);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rrpc_area_free(struct rrpc *rrpc)
|
static void rrpc_area_free(struct rrpc *rrpc)
|
||||||
{
|
{
|
||||||
struct nvm_dev *dev = rrpc->dev;
|
struct nvm_dev *dev = rrpc->dev;
|
||||||
struct nvmm_type *mt = dev->mt;
|
struct nvmm_type *mt = dev->mt;
|
||||||
|
sector_t begin = rrpc->soffset << (ilog2(dev->sec_size) - 9);
|
||||||
|
|
||||||
mt->put_area(dev, rrpc->soffset);
|
mt->put_area(dev, begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rrpc_free(struct rrpc *rrpc)
|
static void rrpc_free(struct rrpc *rrpc)
|
||||||
|
Loading…
Reference in New Issue
Block a user