Skip to contentSkip to conversation

lightnvm: calc right rblk when having several luns

PATCH New Javier González 1 participant 1 message Feb 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lightnvm: calc right rblk when having several luns

When getting a new block from the media manager, calculate the right rblk, considering that the pool of flash blocks has been divided among the different luns exposed by the underlying device.

---
 drivers/lightnvm/rrpc.c | 2 +-
 drivers/lightnvm/rrpc.h | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/lightnvm/rrpc.c +1 -1
index c2f9a64..d8416ad 100644
@@ -191,7 +191,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);
 
drivers/lightnvm/rrpc.h +9 -0
index 1c4b1c9..8bcb827 100644
@@ -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 blk_pos = blk_id % rrpc->dev->blks_per_lun;
+
+	return &rlun->blocks[blk_pos];
+}
+
 static inline sector_t rrpc_get_laddr(struct bio *bio)
 {
 	return bio->bi_iter.bi_sector / NR_PHY_IN_LOG;
Signature · 1 line
2.1.4