pblk-read.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /*
  2. * Copyright (C) 2016 CNEX Labs
  3. * Initial release: Javier Gonzalez <javier@cnexlabs.com>
  4. * Matias Bjorling <matias@cnexlabs.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * pblk-read.c - pblk's read path
  16. */
  17. #include "pblk.h"
  18. /*
  19. * There is no guarantee that the value read from cache has not been updated and
  20. * resides at another location in the cache. We guarantee though that if the
  21. * value is read from the cache, it belongs to the mapped lba. In order to
  22. * guarantee and order between writes and reads are ordered, a flush must be
  23. * issued.
  24. */
  25. static int pblk_read_from_cache(struct pblk *pblk, struct bio *bio,
  26. sector_t lba, struct ppa_addr ppa,
  27. int bio_iter, bool advanced_bio)
  28. {
  29. #ifdef CONFIG_NVM_DEBUG
  30. /* Callers must ensure that the ppa points to a cache address */
  31. BUG_ON(pblk_ppa_empty(ppa));
  32. BUG_ON(!pblk_addr_in_cache(ppa));
  33. #endif
  34. return pblk_rb_copy_to_bio(&pblk->rwb, bio, lba, ppa,
  35. bio_iter, advanced_bio);
  36. }
  37. static void pblk_read_ppalist_rq(struct pblk *pblk, struct nvm_rq *rqd,
  38. sector_t blba, unsigned long *read_bitmap)
  39. {
  40. struct pblk_sec_meta *meta_list = rqd->meta_list;
  41. struct bio *bio = rqd->bio;
  42. struct ppa_addr ppas[PBLK_MAX_REQ_ADDRS];
  43. int nr_secs = rqd->nr_ppas;
  44. bool advanced_bio = false;
  45. int i, j = 0;
  46. pblk_lookup_l2p_seq(pblk, ppas, blba, nr_secs);
  47. for (i = 0; i < nr_secs; i++) {
  48. struct ppa_addr p = ppas[i];
  49. sector_t lba = blba + i;
  50. retry:
  51. if (pblk_ppa_empty(p)) {
  52. WARN_ON(test_and_set_bit(i, read_bitmap));
  53. meta_list[i].lba = cpu_to_le64(ADDR_EMPTY);
  54. if (unlikely(!advanced_bio)) {
  55. bio_advance(bio, (i) * PBLK_EXPOSED_PAGE_SIZE);
  56. advanced_bio = true;
  57. }
  58. goto next;
  59. }
  60. /* Try to read from write buffer. The address is later checked
  61. * on the write buffer to prevent retrieving overwritten data.
  62. */
  63. if (pblk_addr_in_cache(p)) {
  64. if (!pblk_read_from_cache(pblk, bio, lba, p, i,
  65. advanced_bio)) {
  66. pblk_lookup_l2p_seq(pblk, &p, lba, 1);
  67. goto retry;
  68. }
  69. WARN_ON(test_and_set_bit(i, read_bitmap));
  70. meta_list[i].lba = cpu_to_le64(lba);
  71. advanced_bio = true;
  72. #ifdef CONFIG_NVM_DEBUG
  73. atomic_long_inc(&pblk->cache_reads);
  74. #endif
  75. } else {
  76. /* Read from media non-cached sectors */
  77. rqd->ppa_list[j++] = p;
  78. }
  79. next:
  80. if (advanced_bio)
  81. bio_advance(bio, PBLK_EXPOSED_PAGE_SIZE);
  82. }
  83. if (pblk_io_aligned(pblk, nr_secs))
  84. rqd->flags = pblk_set_read_mode(pblk, PBLK_READ_SEQUENTIAL);
  85. else
  86. rqd->flags = pblk_set_read_mode(pblk, PBLK_READ_RANDOM);
  87. #ifdef CONFIG_NVM_DEBUG
  88. atomic_long_add(nr_secs, &pblk->inflight_reads);
  89. #endif
  90. }
  91. static int pblk_submit_read_io(struct pblk *pblk, struct nvm_rq *rqd)
  92. {
  93. int err;
  94. err = pblk_submit_io(pblk, rqd);
  95. if (err)
  96. return NVM_IO_ERR;
  97. return NVM_IO_OK;
  98. }
  99. static void pblk_read_check(struct pblk *pblk, struct nvm_rq *rqd,
  100. sector_t blba)
  101. {
  102. struct pblk_sec_meta *meta_list = rqd->meta_list;
  103. int nr_lbas = rqd->nr_ppas;
  104. int i;
  105. for (i = 0; i < nr_lbas; i++) {
  106. u64 lba = le64_to_cpu(meta_list[i].lba);
  107. if (lba == ADDR_EMPTY)
  108. continue;
  109. WARN(lba != blba + i, "pblk: corrupted read LBA\n");
  110. }
  111. }
  112. static void pblk_read_put_rqd_kref(struct pblk *pblk, struct nvm_rq *rqd)
  113. {
  114. struct ppa_addr *ppa_list;
  115. int i;
  116. ppa_list = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr;
  117. for (i = 0; i < rqd->nr_ppas; i++) {
  118. struct ppa_addr ppa = ppa_list[i];
  119. struct pblk_line *line;
  120. line = &pblk->lines[pblk_ppa_to_line(ppa)];
  121. kref_put(&line->ref, pblk_line_put_wq);
  122. }
  123. }
  124. static void pblk_end_user_read(struct bio *bio)
  125. {
  126. #ifdef CONFIG_NVM_DEBUG
  127. WARN_ONCE(bio->bi_status, "pblk: corrupted read bio\n");
  128. #endif
  129. bio_endio(bio);
  130. bio_put(bio);
  131. }
  132. static void __pblk_end_io_read(struct pblk *pblk, struct nvm_rq *rqd,
  133. bool put_line)
  134. {
  135. struct nvm_tgt_dev *dev = pblk->dev;
  136. struct pblk_g_ctx *r_ctx = nvm_rq_to_pdu(rqd);
  137. struct bio *bio = rqd->bio;
  138. unsigned long start_time = r_ctx->start_time;
  139. generic_end_io_acct(dev->q, READ, &pblk->disk->part0, start_time);
  140. if (rqd->error)
  141. pblk_log_read_err(pblk, rqd);
  142. #ifdef CONFIG_NVM_DEBUG
  143. else
  144. WARN_ONCE(bio->bi_status, "pblk: corrupted read error\n");
  145. #endif
  146. pblk_read_check(pblk, rqd, r_ctx->lba);
  147. bio_put(bio);
  148. if (r_ctx->private)
  149. pblk_end_user_read((struct bio *)r_ctx->private);
  150. if (put_line)
  151. pblk_read_put_rqd_kref(pblk, rqd);
  152. #ifdef CONFIG_NVM_DEBUG
  153. atomic_long_add(rqd->nr_ppas, &pblk->sync_reads);
  154. atomic_long_sub(rqd->nr_ppas, &pblk->inflight_reads);
  155. #endif
  156. pblk_free_rqd(pblk, rqd, PBLK_READ);
  157. atomic_dec(&pblk->inflight_io);
  158. }
  159. static void pblk_end_io_read(struct nvm_rq *rqd)
  160. {
  161. struct pblk *pblk = rqd->private;
  162. __pblk_end_io_read(pblk, rqd, true);
  163. }
  164. static int pblk_partial_read_bio(struct pblk *pblk, struct nvm_rq *rqd,
  165. unsigned int bio_init_idx,
  166. unsigned long *read_bitmap)
  167. {
  168. struct bio *new_bio, *bio = rqd->bio;
  169. struct pblk_sec_meta *meta_list = rqd->meta_list;
  170. struct bio_vec src_bv, dst_bv;
  171. void *ppa_ptr = NULL;
  172. void *src_p, *dst_p;
  173. dma_addr_t dma_ppa_list = 0;
  174. __le64 *lba_list_mem, *lba_list_media;
  175. int nr_secs = rqd->nr_ppas;
  176. int nr_holes = nr_secs - bitmap_weight(read_bitmap, nr_secs);
  177. int i, ret, hole;
  178. /* Re-use allocated memory for intermediate lbas */
  179. lba_list_mem = (((void *)rqd->ppa_list) + pblk_dma_ppa_size);
  180. lba_list_media = (((void *)rqd->ppa_list) + 2 * pblk_dma_ppa_size);
  181. new_bio = bio_alloc(GFP_KERNEL, nr_holes);
  182. if (pblk_bio_add_pages(pblk, new_bio, GFP_KERNEL, nr_holes))
  183. goto err;
  184. if (nr_holes != new_bio->bi_vcnt) {
  185. pr_err("pblk: malformed bio\n");
  186. goto err;
  187. }
  188. for (i = 0; i < nr_secs; i++)
  189. lba_list_mem[i] = meta_list[i].lba;
  190. new_bio->bi_iter.bi_sector = 0; /* internal bio */
  191. bio_set_op_attrs(new_bio, REQ_OP_READ, 0);
  192. rqd->bio = new_bio;
  193. rqd->nr_ppas = nr_holes;
  194. rqd->flags = pblk_set_read_mode(pblk, PBLK_READ_RANDOM);
  195. if (unlikely(nr_holes == 1)) {
  196. ppa_ptr = rqd->ppa_list;
  197. dma_ppa_list = rqd->dma_ppa_list;
  198. rqd->ppa_addr = rqd->ppa_list[0];
  199. }
  200. ret = pblk_submit_io_sync(pblk, rqd);
  201. if (ret) {
  202. bio_put(rqd->bio);
  203. pr_err("pblk: sync read IO submission failed\n");
  204. goto err;
  205. }
  206. if (rqd->error) {
  207. atomic_long_inc(&pblk->read_failed);
  208. #ifdef CONFIG_NVM_DEBUG
  209. pblk_print_failed_rqd(pblk, rqd, rqd->error);
  210. #endif
  211. }
  212. if (unlikely(nr_holes == 1)) {
  213. struct ppa_addr ppa;
  214. ppa = rqd->ppa_addr;
  215. rqd->ppa_list = ppa_ptr;
  216. rqd->dma_ppa_list = dma_ppa_list;
  217. rqd->ppa_list[0] = ppa;
  218. }
  219. for (i = 0; i < nr_secs; i++) {
  220. lba_list_media[i] = meta_list[i].lba;
  221. meta_list[i].lba = lba_list_mem[i];
  222. }
  223. /* Fill the holes in the original bio */
  224. i = 0;
  225. hole = find_first_zero_bit(read_bitmap, nr_secs);
  226. do {
  227. int line_id = pblk_ppa_to_line(rqd->ppa_list[i]);
  228. struct pblk_line *line = &pblk->lines[line_id];
  229. kref_put(&line->ref, pblk_line_put);
  230. meta_list[hole].lba = lba_list_media[i];
  231. src_bv = new_bio->bi_io_vec[i++];
  232. dst_bv = bio->bi_io_vec[bio_init_idx + hole];
  233. src_p = kmap_atomic(src_bv.bv_page);
  234. dst_p = kmap_atomic(dst_bv.bv_page);
  235. memcpy(dst_p + dst_bv.bv_offset,
  236. src_p + src_bv.bv_offset,
  237. PBLK_EXPOSED_PAGE_SIZE);
  238. kunmap_atomic(src_p);
  239. kunmap_atomic(dst_p);
  240. mempool_free(src_bv.bv_page, pblk->page_bio_pool);
  241. hole = find_next_zero_bit(read_bitmap, nr_secs, hole + 1);
  242. } while (hole < nr_secs);
  243. bio_put(new_bio);
  244. /* Complete the original bio and associated request */
  245. bio_endio(bio);
  246. rqd->bio = bio;
  247. rqd->nr_ppas = nr_secs;
  248. __pblk_end_io_read(pblk, rqd, false);
  249. return NVM_IO_OK;
  250. err:
  251. pr_err("pblk: failed to perform partial read\n");
  252. /* Free allocated pages in new bio */
  253. pblk_bio_free_pages(pblk, bio, 0, new_bio->bi_vcnt);
  254. __pblk_end_io_read(pblk, rqd, false);
  255. return NVM_IO_ERR;
  256. }
  257. static void pblk_read_rq(struct pblk *pblk, struct nvm_rq *rqd,
  258. sector_t lba, unsigned long *read_bitmap)
  259. {
  260. struct pblk_sec_meta *meta_list = rqd->meta_list;
  261. struct bio *bio = rqd->bio;
  262. struct ppa_addr ppa;
  263. pblk_lookup_l2p_seq(pblk, &ppa, lba, 1);
  264. #ifdef CONFIG_NVM_DEBUG
  265. atomic_long_inc(&pblk->inflight_reads);
  266. #endif
  267. retry:
  268. if (pblk_ppa_empty(ppa)) {
  269. WARN_ON(test_and_set_bit(0, read_bitmap));
  270. meta_list[0].lba = cpu_to_le64(ADDR_EMPTY);
  271. return;
  272. }
  273. /* Try to read from write buffer. The address is later checked on the
  274. * write buffer to prevent retrieving overwritten data.
  275. */
  276. if (pblk_addr_in_cache(ppa)) {
  277. if (!pblk_read_from_cache(pblk, bio, lba, ppa, 0, 1)) {
  278. pblk_lookup_l2p_seq(pblk, &ppa, lba, 1);
  279. goto retry;
  280. }
  281. WARN_ON(test_and_set_bit(0, read_bitmap));
  282. meta_list[0].lba = cpu_to_le64(lba);
  283. #ifdef CONFIG_NVM_DEBUG
  284. atomic_long_inc(&pblk->cache_reads);
  285. #endif
  286. } else {
  287. rqd->ppa_addr = ppa;
  288. }
  289. rqd->flags = pblk_set_read_mode(pblk, PBLK_READ_RANDOM);
  290. }
  291. int pblk_submit_read(struct pblk *pblk, struct bio *bio)
  292. {
  293. struct nvm_tgt_dev *dev = pblk->dev;
  294. struct request_queue *q = dev->q;
  295. sector_t blba = pblk_get_lba(bio);
  296. unsigned int nr_secs = pblk_get_secs(bio);
  297. struct pblk_g_ctx *r_ctx;
  298. struct nvm_rq *rqd;
  299. unsigned int bio_init_idx;
  300. unsigned long read_bitmap; /* Max 64 ppas per request */
  301. int ret = NVM_IO_ERR;
  302. /* logic error: lba out-of-bounds. Ignore read request */
  303. if (blba >= pblk->rl.nr_secs || nr_secs > PBLK_MAX_REQ_ADDRS) {
  304. WARN(1, "pblk: read lba out of bounds (lba:%llu, nr:%d)\n",
  305. (unsigned long long)blba, nr_secs);
  306. return NVM_IO_ERR;
  307. }
  308. generic_start_io_acct(q, READ, bio_sectors(bio), &pblk->disk->part0);
  309. bitmap_zero(&read_bitmap, nr_secs);
  310. rqd = pblk_alloc_rqd(pblk, PBLK_READ);
  311. rqd->opcode = NVM_OP_PREAD;
  312. rqd->bio = bio;
  313. rqd->nr_ppas = nr_secs;
  314. rqd->private = pblk;
  315. rqd->end_io = pblk_end_io_read;
  316. r_ctx = nvm_rq_to_pdu(rqd);
  317. r_ctx->start_time = jiffies;
  318. r_ctx->lba = blba;
  319. /* Save the index for this bio's start. This is needed in case
  320. * we need to fill a partial read.
  321. */
  322. bio_init_idx = pblk_get_bi_idx(bio);
  323. rqd->meta_list = nvm_dev_dma_alloc(dev->parent, GFP_KERNEL,
  324. &rqd->dma_meta_list);
  325. if (!rqd->meta_list) {
  326. pr_err("pblk: not able to allocate ppa list\n");
  327. goto fail_rqd_free;
  328. }
  329. if (nr_secs > 1) {
  330. rqd->ppa_list = rqd->meta_list + pblk_dma_meta_size;
  331. rqd->dma_ppa_list = rqd->dma_meta_list + pblk_dma_meta_size;
  332. pblk_read_ppalist_rq(pblk, rqd, blba, &read_bitmap);
  333. } else {
  334. pblk_read_rq(pblk, rqd, blba, &read_bitmap);
  335. }
  336. bio_get(bio);
  337. if (bitmap_full(&read_bitmap, nr_secs)) {
  338. bio_endio(bio);
  339. atomic_inc(&pblk->inflight_io);
  340. __pblk_end_io_read(pblk, rqd, false);
  341. return NVM_IO_OK;
  342. }
  343. /* All sectors are to be read from the device */
  344. if (bitmap_empty(&read_bitmap, rqd->nr_ppas)) {
  345. struct bio *int_bio = NULL;
  346. /* Clone read bio to deal with read errors internally */
  347. int_bio = bio_clone_fast(bio, GFP_KERNEL, pblk_bio_set);
  348. if (!int_bio) {
  349. pr_err("pblk: could not clone read bio\n");
  350. goto fail_end_io;
  351. }
  352. rqd->bio = int_bio;
  353. r_ctx->private = bio;
  354. ret = pblk_submit_read_io(pblk, rqd);
  355. if (ret) {
  356. pr_err("pblk: read IO submission failed\n");
  357. if (int_bio)
  358. bio_put(int_bio);
  359. goto fail_end_io;
  360. }
  361. return NVM_IO_OK;
  362. }
  363. /* The read bio request could be partially filled by the write buffer,
  364. * but there are some holes that need to be read from the drive.
  365. */
  366. return pblk_partial_read_bio(pblk, rqd, bio_init_idx, &read_bitmap);
  367. fail_rqd_free:
  368. pblk_free_rqd(pblk, rqd, PBLK_READ);
  369. return ret;
  370. fail_end_io:
  371. __pblk_end_io_read(pblk, rqd, false);
  372. return ret;
  373. }
  374. static int read_ppalist_rq_gc(struct pblk *pblk, struct nvm_rq *rqd,
  375. struct pblk_line *line, u64 *lba_list,
  376. u64 *paddr_list_gc, unsigned int nr_secs)
  377. {
  378. struct ppa_addr ppa_list_l2p[PBLK_MAX_REQ_ADDRS];
  379. struct ppa_addr ppa_gc;
  380. int valid_secs = 0;
  381. int i;
  382. pblk_lookup_l2p_rand(pblk, ppa_list_l2p, lba_list, nr_secs);
  383. for (i = 0; i < nr_secs; i++) {
  384. if (lba_list[i] == ADDR_EMPTY)
  385. continue;
  386. ppa_gc = addr_to_gen_ppa(pblk, paddr_list_gc[i], line->id);
  387. if (!pblk_ppa_comp(ppa_list_l2p[i], ppa_gc)) {
  388. paddr_list_gc[i] = lba_list[i] = ADDR_EMPTY;
  389. continue;
  390. }
  391. rqd->ppa_list[valid_secs++] = ppa_list_l2p[i];
  392. }
  393. #ifdef CONFIG_NVM_DEBUG
  394. atomic_long_add(valid_secs, &pblk->inflight_reads);
  395. #endif
  396. return valid_secs;
  397. }
  398. static int read_rq_gc(struct pblk *pblk, struct nvm_rq *rqd,
  399. struct pblk_line *line, sector_t lba,
  400. u64 paddr_gc)
  401. {
  402. struct ppa_addr ppa_l2p, ppa_gc;
  403. int valid_secs = 0;
  404. if (lba == ADDR_EMPTY)
  405. goto out;
  406. /* logic error: lba out-of-bounds */
  407. if (lba >= pblk->rl.nr_secs) {
  408. WARN(1, "pblk: read lba out of bounds\n");
  409. goto out;
  410. }
  411. spin_lock(&pblk->trans_lock);
  412. ppa_l2p = pblk_trans_map_get(pblk, lba);
  413. spin_unlock(&pblk->trans_lock);
  414. ppa_gc = addr_to_gen_ppa(pblk, paddr_gc, line->id);
  415. if (!pblk_ppa_comp(ppa_l2p, ppa_gc))
  416. goto out;
  417. rqd->ppa_addr = ppa_l2p;
  418. valid_secs = 1;
  419. #ifdef CONFIG_NVM_DEBUG
  420. atomic_long_inc(&pblk->inflight_reads);
  421. #endif
  422. out:
  423. return valid_secs;
  424. }
  425. int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq)
  426. {
  427. struct nvm_tgt_dev *dev = pblk->dev;
  428. struct nvm_geo *geo = &dev->geo;
  429. struct bio *bio;
  430. struct nvm_rq rqd;
  431. int data_len;
  432. int ret = NVM_IO_OK;
  433. memset(&rqd, 0, sizeof(struct nvm_rq));
  434. rqd.meta_list = nvm_dev_dma_alloc(dev->parent, GFP_KERNEL,
  435. &rqd.dma_meta_list);
  436. if (!rqd.meta_list)
  437. return -ENOMEM;
  438. if (gc_rq->nr_secs > 1) {
  439. rqd.ppa_list = rqd.meta_list + pblk_dma_meta_size;
  440. rqd.dma_ppa_list = rqd.dma_meta_list + pblk_dma_meta_size;
  441. gc_rq->secs_to_gc = read_ppalist_rq_gc(pblk, &rqd, gc_rq->line,
  442. gc_rq->lba_list,
  443. gc_rq->paddr_list,
  444. gc_rq->nr_secs);
  445. if (gc_rq->secs_to_gc == 1)
  446. rqd.ppa_addr = rqd.ppa_list[0];
  447. } else {
  448. gc_rq->secs_to_gc = read_rq_gc(pblk, &rqd, gc_rq->line,
  449. gc_rq->lba_list[0],
  450. gc_rq->paddr_list[0]);
  451. }
  452. if (!(gc_rq->secs_to_gc))
  453. goto out;
  454. data_len = (gc_rq->secs_to_gc) * geo->csecs;
  455. bio = pblk_bio_map_addr(pblk, gc_rq->data, gc_rq->secs_to_gc, data_len,
  456. PBLK_VMALLOC_META, GFP_KERNEL);
  457. if (IS_ERR(bio)) {
  458. pr_err("pblk: could not allocate GC bio (%lu)\n", PTR_ERR(bio));
  459. goto err_free_dma;
  460. }
  461. bio->bi_iter.bi_sector = 0; /* internal bio */
  462. bio_set_op_attrs(bio, REQ_OP_READ, 0);
  463. rqd.opcode = NVM_OP_PREAD;
  464. rqd.nr_ppas = gc_rq->secs_to_gc;
  465. rqd.flags = pblk_set_read_mode(pblk, PBLK_READ_RANDOM);
  466. rqd.bio = bio;
  467. if (pblk_submit_io_sync(pblk, &rqd)) {
  468. ret = -EIO;
  469. pr_err("pblk: GC read request failed\n");
  470. goto err_free_bio;
  471. }
  472. atomic_dec(&pblk->inflight_io);
  473. if (rqd.error) {
  474. atomic_long_inc(&pblk->read_failed_gc);
  475. #ifdef CONFIG_NVM_DEBUG
  476. pblk_print_failed_rqd(pblk, &rqd, rqd.error);
  477. #endif
  478. }
  479. #ifdef CONFIG_NVM_DEBUG
  480. atomic_long_add(gc_rq->secs_to_gc, &pblk->sync_reads);
  481. atomic_long_add(gc_rq->secs_to_gc, &pblk->recov_gc_reads);
  482. atomic_long_sub(gc_rq->secs_to_gc, &pblk->inflight_reads);
  483. #endif
  484. out:
  485. nvm_dev_dma_free(dev->parent, rqd.meta_list, rqd.dma_meta_list);
  486. return ret;
  487. err_free_bio:
  488. bio_put(bio);
  489. err_free_dma:
  490. nvm_dev_dma_free(dev->parent, rqd.meta_list, rqd.dma_meta_list);
  491. return ret;
  492. }