diff options
author | Wenwei Tao <ww.tao0320@gmail.com> | 2016-05-06 14:03:01 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-05-06 14:51:10 -0400 |
commit | 909049a7199947abbc6a923e4cf5cff1857d4205 (patch) | |
tree | 01fc1e96698bbeb8f473a20c88f9fea0b6a8b7b7 /drivers/lightnvm | |
parent | 66e3d07f75c6472d7198920488330634c118b255 (diff) |
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>
Diffstat (limited to 'drivers/lightnvm')
-rw-r--r-- | drivers/lightnvm/rrpc.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index c0e303cd9d60..3143b980ac06 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c | |||
@@ -1039,11 +1039,8 @@ static int rrpc_map_init(struct rrpc *rrpc) | |||
1039 | { | 1039 | { |
1040 | struct nvm_dev *dev = rrpc->dev; | 1040 | struct nvm_dev *dev = rrpc->dev; |
1041 | sector_t i; | 1041 | sector_t i; |
1042 | u64 slba; | ||
1043 | int ret; | 1042 | int ret; |
1044 | 1043 | ||
1045 | slba = rrpc->soffset >> (ilog2(dev->sec_size) - 9); | ||
1046 | |||
1047 | rrpc->trans_map = vzalloc(sizeof(struct rrpc_addr) * rrpc->nr_sects); | 1044 | rrpc->trans_map = vzalloc(sizeof(struct rrpc_addr) * rrpc->nr_sects); |
1048 | if (!rrpc->trans_map) | 1045 | if (!rrpc->trans_map) |
1049 | return -ENOMEM; | 1046 | return -ENOMEM; |
@@ -1065,8 +1062,8 @@ static int rrpc_map_init(struct rrpc *rrpc) | |||
1065 | return 0; | 1062 | return 0; |
1066 | 1063 | ||
1067 | /* Bring up the mapping table from device */ | 1064 | /* Bring up the mapping table from device */ |
1068 | ret = dev->ops->get_l2p_tbl(dev, slba, rrpc->nr_sects, rrpc_l2p_update, | 1065 | ret = dev->ops->get_l2p_tbl(dev, rrpc->soffset, rrpc->nr_sects, |
1069 | rrpc); | 1066 | rrpc_l2p_update, rrpc); |
1070 | if (ret) { | 1067 | if (ret) { |
1071 | pr_err("nvm: rrpc: could not read L2P table.\n"); | 1068 | pr_err("nvm: rrpc: could not read L2P table.\n"); |
1072 | return -EINVAL; | 1069 | return -EINVAL; |
@@ -1220,18 +1217,24 @@ static int rrpc_area_init(struct rrpc *rrpc, sector_t *begin) | |||
1220 | struct nvm_dev *dev = rrpc->dev; | 1217 | struct nvm_dev *dev = rrpc->dev; |
1221 | struct nvmm_type *mt = dev->mt; | 1218 | struct nvmm_type *mt = dev->mt; |
1222 | sector_t size = rrpc->nr_sects * dev->sec_size; | 1219 | sector_t size = rrpc->nr_sects * dev->sec_size; |
1220 | int ret; | ||
1223 | 1221 | ||
1224 | size >>= 9; | 1222 | size >>= 9; |
1225 | 1223 | ||
1226 | return mt->get_area(dev, begin, size); | 1224 | ret = mt->get_area(dev, begin, size); |
1225 | if (!ret) | ||
1226 | *begin >>= (ilog2(dev->sec_size) - 9); | ||
1227 | |||
1228 | return ret; | ||
1227 | } | 1229 | } |
1228 | 1230 | ||
1229 | static void rrpc_area_free(struct rrpc *rrpc) | 1231 | static void rrpc_area_free(struct rrpc *rrpc) |
1230 | { | 1232 | { |
1231 | struct nvm_dev *dev = rrpc->dev; | 1233 | struct nvm_dev *dev = rrpc->dev; |
1232 | struct nvmm_type *mt = dev->mt; | 1234 | struct nvmm_type *mt = dev->mt; |
1235 | sector_t begin = rrpc->soffset << (ilog2(dev->sec_size) - 9); | ||
1233 | 1236 | ||
1234 | mt->put_area(dev, rrpc->soffset); | 1237 | mt->put_area(dev, begin); |
1235 | } | 1238 | } |
1236 | 1239 | ||
1237 | static void rrpc_free(struct rrpc *rrpc) | 1240 | static void rrpc_free(struct rrpc *rrpc) |