[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1455193422-19897-1-git-send-email-javier@javigon.com>
Date: Thu, 11 Feb 2016 13:23:42 +0100
From: "Javier González" <jg@...htnvm.io>
To: mb@...htnvm.io
Cc: linux-kernel@...r.kernel.org, linux-block@...r.kernel.org,
Javier González <javier@...xlabs.com>
Subject: [PATCH] lightnvm: use lun block id when using several LUNs
In rrpc, some calculations using block ids assume only one LUN being
used. This is a problem when an Open-Channel SSD with multiple LUNs is
used. This patch modifies this calculations.
Signed-off-by: Javier González <javier@...xlabs.com>
---
drivers/lightnvm/rrpc.c | 5 +++--
drivers/lightnvm/rrpc.h | 9 +++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
index c2f9a64..c744662 100644
--- a/drivers/lightnvm/rrpc.c
+++ b/drivers/lightnvm/rrpc.c
@@ -119,8 +119,9 @@ static int block_is_full(struct rrpc *rrpc, struct rrpc_block *rblk)
static u64 block_to_addr(struct rrpc *rrpc, struct rrpc_block *rblk)
{
struct nvm_block *blk = rblk->parent;
+ int lun_blk = blk->id % rrpc->nr_luns;
- return blk->id * rrpc->dev->pgs_per_blk;
+ return lun_blk * rrpc->dev->pgs_per_blk;
}
static struct ppa_addr linear_to_generic_addr(struct nvm_dev *dev,
@@ -191,7 +192,7 @@ static struct rrpc_block *rrpc_get_blk(struct rrpc *rrpc, struct rrpc_lun *rlun,
return NULL;
}
- rblk = &rlun->blocks[blk->id];
+ rblk = rrpc_get_rblk(rlun, blk->id);
list_add_tail(&rblk->list, &rlun->open_list);
spin_unlock(&lun->lock);
diff --git a/drivers/lightnvm/rrpc.h b/drivers/lightnvm/rrpc.h
index 1c4b1c9..2653484 100644
--- a/drivers/lightnvm/rrpc.h
+++ b/drivers/lightnvm/rrpc.h
@@ -157,6 +157,15 @@ struct rrpc_rev_addr {
u64 addr;
};
+static inline struct rrpc_block *rrpc_get_rblk(struct rrpc_lun *rlun,
+ int blk_id)
+{
+ struct rrpc *rrpc = rlun->rrpc;
+ int lun_blk = blk_id % rrpc->dev->blks_per_lun;
+
+ return &rlun->blocks[lun_blk];
+}
+
static inline sector_t rrpc_get_laddr(struct bio *bio)
{
return bio->bi_iter.bi_sector / NR_PHY_IN_LOG;
--
2.1.4
Powered by blists - more mailing lists