aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-init.c
diff options
context:
space:
mode:
authorMatias Bjørling <mb@lightnvm.io>2018-07-13 04:48:42 -0400
committerJens Axboe <axboe@kernel.dk>2018-07-13 10:14:43 -0400
commit4e495a46b1039252f4af0c883e2cb31cc5f44145 (patch)
treea73da1351db3dee14fc043e8f4425203704084d2 /drivers/lightnvm/pblk-init.c
parent59a8f43b6341b6964a9956640bb0f21b083ccd66 (diff)
lightnvm: pblk: expose generic disk name on pr_* msgs
The error messages in pblk does not say which pblk instance that a message occurred from. Update each error message to reflect the instance it belongs to, and also prefix it with pblk, so we know the message comes from the pblk module. Signed-off-by: Matias Bjørling <mb@lightnvm.io> Reviewed-by: Javier González <javier@cnexlabs.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r--drivers/lightnvm/pblk-init.c76
1 files changed, 39 insertions, 37 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 9ea30102f61c..d023ea6116bc 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -117,13 +117,13 @@ static int pblk_l2p_recover(struct pblk *pblk, bool factory_init)
117 } else { 117 } else {
118 line = pblk_recov_l2p(pblk); 118 line = pblk_recov_l2p(pblk);
119 if (IS_ERR(line)) { 119 if (IS_ERR(line)) {
120 pr_err("pblk: could not recover l2p table\n"); 120 pblk_err(pblk, "could not recover l2p table\n");
121 return -EFAULT; 121 return -EFAULT;
122 } 122 }
123 } 123 }
124 124
125#ifdef CONFIG_NVM_PBLK_DEBUG 125#ifdef CONFIG_NVM_PBLK_DEBUG
126 pr_info("pblk init: L2P CRC: %x\n", pblk_l2p_crc(pblk)); 126 pblk_info(pblk, "init: L2P CRC: %x\n", pblk_l2p_crc(pblk));
127#endif 127#endif
128 128
129 /* Free full lines directly as GC has not been started yet */ 129 /* Free full lines directly as GC has not been started yet */
@@ -166,7 +166,7 @@ static int pblk_l2p_init(struct pblk *pblk, bool factory_init)
166static void pblk_rwb_free(struct pblk *pblk) 166static void pblk_rwb_free(struct pblk *pblk)
167{ 167{
168 if (pblk_rb_tear_down_check(&pblk->rwb)) 168 if (pblk_rb_tear_down_check(&pblk->rwb))
169 pr_err("pblk: write buffer error on tear down\n"); 169 pblk_err(pblk, "write buffer error on tear down\n");
170 170
171 pblk_rb_data_free(&pblk->rwb); 171 pblk_rb_data_free(&pblk->rwb);
172 vfree(pblk_rb_entries_ref(&pblk->rwb)); 172 vfree(pblk_rb_entries_ref(&pblk->rwb));
@@ -203,7 +203,8 @@ static int pblk_rwb_init(struct pblk *pblk)
203/* Minimum pages needed within a lun */ 203/* Minimum pages needed within a lun */
204#define ADDR_POOL_SIZE 64 204#define ADDR_POOL_SIZE 64
205 205
206static int pblk_set_addrf_12(struct nvm_geo *geo, struct nvm_addrf_12 *dst) 206static int pblk_set_addrf_12(struct pblk *pblk, struct nvm_geo *geo,
207 struct nvm_addrf_12 *dst)
207{ 208{
208 struct nvm_addrf_12 *src = (struct nvm_addrf_12 *)&geo->addrf; 209 struct nvm_addrf_12 *src = (struct nvm_addrf_12 *)&geo->addrf;
209 int power_len; 210 int power_len;
@@ -211,14 +212,14 @@ static int pblk_set_addrf_12(struct nvm_geo *geo, struct nvm_addrf_12 *dst)
211 /* Re-calculate channel and lun format to adapt to configuration */ 212 /* Re-calculate channel and lun format to adapt to configuration */
212 power_len = get_count_order(geo->num_ch); 213 power_len = get_count_order(geo->num_ch);
213 if (1 << power_len != geo->num_ch) { 214 if (1 << power_len != geo->num_ch) {
214 pr_err("pblk: supports only power-of-two channel config.\n"); 215 pblk_err(pblk, "supports only power-of-two channel config.\n");
215 return -EINVAL; 216 return -EINVAL;
216 } 217 }
217 dst->ch_len = power_len; 218 dst->ch_len = power_len;
218 219
219 power_len = get_count_order(geo->num_lun); 220 power_len = get_count_order(geo->num_lun);
220 if (1 << power_len != geo->num_lun) { 221 if (1 << power_len != geo->num_lun) {
221 pr_err("pblk: supports only power-of-two LUN config.\n"); 222 pblk_err(pblk, "supports only power-of-two LUN config.\n");
222 return -EINVAL; 223 return -EINVAL;
223 } 224 }
224 dst->lun_len = power_len; 225 dst->lun_len = power_len;
@@ -285,18 +286,19 @@ static int pblk_set_addrf(struct pblk *pblk)
285 case NVM_OCSSD_SPEC_12: 286 case NVM_OCSSD_SPEC_12:
286 div_u64_rem(geo->clba, pblk->min_write_pgs, &mod); 287 div_u64_rem(geo->clba, pblk->min_write_pgs, &mod);
287 if (mod) { 288 if (mod) {
288 pr_err("pblk: bad configuration of sectors/pages\n"); 289 pblk_err(pblk, "bad configuration of sectors/pages\n");
289 return -EINVAL; 290 return -EINVAL;
290 } 291 }
291 292
292 pblk->addrf_len = pblk_set_addrf_12(geo, (void *)&pblk->addrf); 293 pblk->addrf_len = pblk_set_addrf_12(pblk, geo,
294 (void *)&pblk->addrf);
293 break; 295 break;
294 case NVM_OCSSD_SPEC_20: 296 case NVM_OCSSD_SPEC_20:
295 pblk->addrf_len = pblk_set_addrf_20(geo, (void *)&pblk->addrf, 297 pblk->addrf_len = pblk_set_addrf_20(geo, (void *)&pblk->addrf,
296 &pblk->uaddrf); 298 &pblk->uaddrf);
297 break; 299 break;
298 default: 300 default:
299 pr_err("pblk: OCSSD revision not supported (%d)\n", 301 pblk_err(pblk, "OCSSD revision not supported (%d)\n",
300 geo->version); 302 geo->version);
301 return -EINVAL; 303 return -EINVAL;
302 } 304 }
@@ -375,7 +377,7 @@ static int pblk_core_init(struct pblk *pblk)
375 pblk_set_sec_per_write(pblk, pblk->min_write_pgs); 377 pblk_set_sec_per_write(pblk, pblk->min_write_pgs);
376 378
377 if (pblk->max_write_pgs > PBLK_MAX_REQ_ADDRS) { 379 if (pblk->max_write_pgs > PBLK_MAX_REQ_ADDRS) {
378 pr_err("pblk: vector list too big(%u > %u)\n", 380 pblk_err(pblk, "vector list too big(%u > %u)\n",
379 pblk->max_write_pgs, PBLK_MAX_REQ_ADDRS); 381 pblk->max_write_pgs, PBLK_MAX_REQ_ADDRS);
380 return -EINVAL; 382 return -EINVAL;
381 } 383 }
@@ -608,7 +610,7 @@ static int pblk_luns_init(struct pblk *pblk)
608 610
609 /* TODO: Implement unbalanced LUN support */ 611 /* TODO: Implement unbalanced LUN support */
610 if (geo->num_lun < 0) { 612 if (geo->num_lun < 0) {
611 pr_err("pblk: unbalanced LUN config.\n"); 613 pblk_err(pblk, "unbalanced LUN config.\n");
612 return -EINVAL; 614 return -EINVAL;
613 } 615 }
614 616
@@ -1027,7 +1029,7 @@ add_emeta_page:
1027 lm->emeta_sec[0], geo->clba); 1029 lm->emeta_sec[0], geo->clba);
1028 1030
1029 if (lm->min_blk_line > lm->blk_per_line) { 1031 if (lm->min_blk_line > lm->blk_per_line) {
1030 pr_err("pblk: config. not supported. Min. LUN in line:%d\n", 1032 pblk_err(pblk, "config. not supported. Min. LUN in line:%d\n",
1031 lm->blk_per_line); 1033 lm->blk_per_line);
1032 return -EINVAL; 1034 return -EINVAL;
1033 } 1035 }
@@ -1079,7 +1081,7 @@ static int pblk_lines_init(struct pblk *pblk)
1079 } 1081 }
1080 1082
1081 if (!nr_free_chks) { 1083 if (!nr_free_chks) {
1082 pr_err("pblk: too many bad blocks prevent for sane instance\n"); 1084 pblk_err(pblk, "too many bad blocks prevent for sane instance\n");
1083 return -EINTR; 1085 return -EINTR;
1084 } 1086 }
1085 1087
@@ -1109,7 +1111,7 @@ static int pblk_writer_init(struct pblk *pblk)
1109 int err = PTR_ERR(pblk->writer_ts); 1111 int err = PTR_ERR(pblk->writer_ts);
1110 1112
1111 if (err != -EINTR) 1113 if (err != -EINTR)
1112 pr_err("pblk: could not allocate writer kthread (%d)\n", 1114 pblk_err(pblk, "could not allocate writer kthread (%d)\n",
1113 err); 1115 err);
1114 return err; 1116 return err;
1115 } 1117 }
@@ -1155,7 +1157,7 @@ static void pblk_tear_down(struct pblk *pblk, bool graceful)
1155 pblk_rb_sync_l2p(&pblk->rwb); 1157 pblk_rb_sync_l2p(&pblk->rwb);
1156 pblk_rl_free(&pblk->rl); 1158 pblk_rl_free(&pblk->rl);
1157 1159
1158 pr_debug("pblk: consistent tear down (graceful:%d)\n", graceful); 1160 pblk_debug(pblk, "consistent tear down (graceful:%d)\n", graceful);
1159} 1161}
1160 1162
1161static void pblk_exit(void *private, bool graceful) 1163static void pblk_exit(void *private, bool graceful)
@@ -1167,7 +1169,7 @@ static void pblk_exit(void *private, bool graceful)
1167 pblk_tear_down(pblk, graceful); 1169 pblk_tear_down(pblk, graceful);
1168 1170
1169#ifdef CONFIG_NVM_PBLK_DEBUG 1171#ifdef CONFIG_NVM_PBLK_DEBUG
1170 pr_info("pblk exit: L2P CRC: %x\n", pblk_l2p_crc(pblk)); 1172 pblk_info(pblk, "exit: L2P CRC: %x\n", pblk_l2p_crc(pblk));
1171#endif 1173#endif
1172 1174
1173 pblk_free(pblk); 1175 pblk_free(pblk);
@@ -1190,29 +1192,30 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
1190 struct pblk *pblk; 1192 struct pblk *pblk;
1191 int ret; 1193 int ret;
1192 1194
1193 /* pblk supports 1.2 and 2.0 versions */ 1195 pblk = kzalloc(sizeof(struct pblk), GFP_KERNEL);
1196 if (!pblk)
1197 return ERR_PTR(-ENOMEM);
1198
1199 pblk->dev = dev;
1200 pblk->disk = tdisk;
1201 pblk->state = PBLK_STATE_RUNNING;
1202 pblk->gc.gc_enabled = 0;
1203
1194 if (!(geo->version == NVM_OCSSD_SPEC_12 || 1204 if (!(geo->version == NVM_OCSSD_SPEC_12 ||
1195 geo->version == NVM_OCSSD_SPEC_20)) { 1205 geo->version == NVM_OCSSD_SPEC_20)) {
1196 pr_err("pblk: OCSSD version not supported (%u)\n", 1206 pblk_err(pblk, "OCSSD version not supported (%u)\n",
1197 geo->version); 1207 geo->version);
1208 kfree(pblk);
1198 return ERR_PTR(-EINVAL); 1209 return ERR_PTR(-EINVAL);
1199 } 1210 }
1200 1211
1201 if (geo->version == NVM_OCSSD_SPEC_12 && geo->dom & NVM_RSP_L2P) { 1212 if (geo->version == NVM_OCSSD_SPEC_12 && geo->dom & NVM_RSP_L2P) {
1202 pr_err("pblk: host-side L2P table not supported. (%x)\n", 1213 pblk_err(pblk, "host-side L2P table not supported. (%x)\n",
1203 geo->dom); 1214 geo->dom);
1215 kfree(pblk);
1204 return ERR_PTR(-EINVAL); 1216 return ERR_PTR(-EINVAL);
1205 } 1217 }
1206 1218
1207 pblk = kzalloc(sizeof(struct pblk), GFP_KERNEL);
1208 if (!pblk)
1209 return ERR_PTR(-ENOMEM);
1210
1211 pblk->dev = dev;
1212 pblk->disk = tdisk;
1213 pblk->state = PBLK_STATE_RUNNING;
1214 pblk->gc.gc_enabled = 0;
1215
1216 spin_lock_init(&pblk->resubmit_lock); 1219 spin_lock_init(&pblk->resubmit_lock);
1217 spin_lock_init(&pblk->trans_lock); 1220 spin_lock_init(&pblk->trans_lock);
1218 spin_lock_init(&pblk->lock); 1221 spin_lock_init(&pblk->lock);
@@ -1242,38 +1245,38 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
1242 1245
1243 ret = pblk_core_init(pblk); 1246 ret = pblk_core_init(pblk);
1244 if (ret) { 1247 if (ret) {
1245 pr_err("pblk: could not initialize core\n"); 1248 pblk_err(pblk, "could not initialize core\n");
1246 goto fail; 1249 goto fail;
1247 } 1250 }
1248 1251
1249 ret = pblk_lines_init(pblk); 1252 ret = pblk_lines_init(pblk);
1250 if (ret) { 1253 if (ret) {
1251 pr_err("pblk: could not initialize lines\n"); 1254 pblk_err(pblk, "could not initialize lines\n");
1252 goto fail_free_core; 1255 goto fail_free_core;
1253 } 1256 }
1254 1257
1255 ret = pblk_rwb_init(pblk); 1258 ret = pblk_rwb_init(pblk);
1256 if (ret) { 1259 if (ret) {
1257 pr_err("pblk: could not initialize write buffer\n"); 1260 pblk_err(pblk, "could not initialize write buffer\n");
1258 goto fail_free_lines; 1261 goto fail_free_lines;
1259 } 1262 }
1260 1263
1261 ret = pblk_l2p_init(pblk, flags & NVM_TARGET_FACTORY); 1264 ret = pblk_l2p_init(pblk, flags & NVM_TARGET_FACTORY);
1262 if (ret) { 1265 if (ret) {
1263 pr_err("pblk: could not initialize maps\n"); 1266 pblk_err(pblk, "could not initialize maps\n");
1264 goto fail_free_rwb; 1267 goto fail_free_rwb;
1265 } 1268 }
1266 1269
1267 ret = pblk_writer_init(pblk); 1270 ret = pblk_writer_init(pblk);
1268 if (ret) { 1271 if (ret) {
1269 if (ret != -EINTR) 1272 if (ret != -EINTR)
1270 pr_err("pblk: could not initialize write thread\n"); 1273 pblk_err(pblk, "could not initialize write thread\n");
1271 goto fail_free_l2p; 1274 goto fail_free_l2p;
1272 } 1275 }
1273 1276
1274 ret = pblk_gc_init(pblk); 1277 ret = pblk_gc_init(pblk);
1275 if (ret) { 1278 if (ret) {
1276 pr_err("pblk: could not initialize gc\n"); 1279 pblk_err(pblk, "could not initialize gc\n");
1277 goto fail_stop_writer; 1280 goto fail_stop_writer;
1278 } 1281 }
1279 1282
@@ -1288,8 +1291,7 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
1288 blk_queue_max_discard_sectors(tqueue, UINT_MAX >> 9); 1291 blk_queue_max_discard_sectors(tqueue, UINT_MAX >> 9);
1289 blk_queue_flag_set(QUEUE_FLAG_DISCARD, tqueue); 1292 blk_queue_flag_set(QUEUE_FLAG_DISCARD, tqueue);
1290 1293
1291 pr_info("pblk(%s): luns:%u, lines:%d, secs:%llu, buf entries:%u\n", 1294 pblk_info(pblk, "luns:%u, lines:%d, secs:%llu, buf entries:%u\n",
1292 tdisk->disk_name,
1293 geo->all_luns, pblk->l_mg.nr_lines, 1295 geo->all_luns, pblk->l_mg.nr_lines,
1294 (unsigned long long)pblk->rl.nr_secs, 1296 (unsigned long long)pblk->rl.nr_secs,
1295 pblk->rwb.nr_entries); 1297 pblk->rwb.nr_entries);