aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvme
diff options
context:
space:
mode:
authorJavier González <jg@lightnvm.io>2016-11-28 16:39:06 -0500
committerJens Axboe <axboe@fb.com>2016-11-29 14:12:51 -0500
commit8e79b5cb1d3b8eceaf6862995952dd4de431dd99 (patch)
tree85f4647731c3678e9fec4e3cac412aff66a86a86 /drivers/nvme
parent8176117b82e49e043d045f214ba7a892fba6b827 (diff)
lightnvm: move block provisioning to targets
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. This patch moves the block provisioning inside of the target and removes the get/put block interface from the media manager. 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>
Diffstat (limited to 'drivers/nvme')
-rw-r--r--drivers/nvme/host/lightnvm.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 037dff5951d4..1cdc8124c8c0 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -352,6 +352,7 @@ static int nvme_nvm_get_l2p_tbl(struct nvm_dev *nvmdev, u64 slba, u32 nlb,
352 352
353 while (nlb) { 353 while (nlb) {
354 u32 cmd_nlb = min(nlb_pr_rq, nlb); 354 u32 cmd_nlb = min(nlb_pr_rq, nlb);
355 u64 elba = slba + cmd_nlb;
355 356
356 c.l2p.slba = cpu_to_le64(cmd_slba); 357 c.l2p.slba = cpu_to_le64(cmd_slba);
357 c.l2p.nlb = cpu_to_le32(cmd_nlb); 358 c.l2p.nlb = cpu_to_le32(cmd_nlb);
@@ -365,6 +366,11 @@ static int nvme_nvm_get_l2p_tbl(struct nvm_dev *nvmdev, u64 slba, u32 nlb,
365 goto out; 366 goto out;
366 } 367 }
367 368
369 if (unlikely(elba > nvmdev->total_secs)) {
370 pr_err("nvm: L2P data from device is out of bounds!\n");
371 return -EINVAL;
372 }
373
368 if (update_l2p(cmd_slba, cmd_nlb, entries, priv)) { 374 if (update_l2p(cmd_slba, cmd_nlb, entries, priv)) {
369 ret = -EINTR; 375 ret = -EINTR;
370 goto out; 376 goto out;
@@ -383,11 +389,12 @@ static int nvme_nvm_get_bb_tbl(struct nvm_dev *nvmdev, struct ppa_addr ppa,
383 u8 *blks) 389 u8 *blks)
384{ 390{
385 struct request_queue *q = nvmdev->q; 391 struct request_queue *q = nvmdev->q;
392 struct nvm_geo *geo = &nvmdev->geo;
386 struct nvme_ns *ns = q->queuedata; 393 struct nvme_ns *ns = q->queuedata;
387 struct nvme_ctrl *ctrl = ns->ctrl; 394 struct nvme_ctrl *ctrl = ns->ctrl;
388 struct nvme_nvm_command c = {}; 395 struct nvme_nvm_command c = {};
389 struct nvme_nvm_bb_tbl *bb_tbl; 396 struct nvme_nvm_bb_tbl *bb_tbl;
390 int nr_blks = nvmdev->blks_per_lun * nvmdev->plane_mode; 397 int nr_blks = geo->blks_per_lun * geo->plane_mode;
391 int tblsz = sizeof(struct nvme_nvm_bb_tbl) + nr_blks; 398 int tblsz = sizeof(struct nvme_nvm_bb_tbl) + nr_blks;
392 int ret = 0; 399 int ret = 0;
393 400
@@ -428,7 +435,7 @@ static int nvme_nvm_get_bb_tbl(struct nvm_dev *nvmdev, struct ppa_addr ppa,
428 goto out; 435 goto out;
429 } 436 }
430 437
431 memcpy(blks, bb_tbl->blk, nvmdev->blks_per_lun * nvmdev->plane_mode); 438 memcpy(blks, bb_tbl->blk, geo->blks_per_lun * geo->plane_mode);
432out: 439out:
433 kfree(bb_tbl); 440 kfree(bb_tbl);
434 return ret; 441 return ret;