Javier González | 02a1520 | 2018-10-09 13:12:06 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 CNEX Labs |
| 4 | * Initial: Javier Gonzalez <javier@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-recovery.c - pblk's recovery path |
Javier González | 361d889 | 2018-12-11 20:16:19 +0100 | [diff] [blame] | 16 | * |
| 17 | * The L2P recovery path is single threaded as the L2P table is updated in order |
| 18 | * following the line sequence ID. |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include "pblk.h" |
Hans Holmberg | f293723 | 2018-10-09 13:11:53 +0200 | [diff] [blame] | 22 | #include "pblk-trace.h" |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 23 | |
Hans Holmberg | 06bc072 | 2018-01-05 14:16:08 +0100 | [diff] [blame] | 24 | int pblk_recov_check_emeta(struct pblk *pblk, struct line_emeta *emeta_buf) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 25 | { |
| 26 | u32 crc; |
| 27 | |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 28 | crc = pblk_calc_emeta_crc(pblk, emeta_buf); |
| 29 | if (le32_to_cpu(emeta_buf->crc) != crc) |
Hans Holmberg | 06bc072 | 2018-01-05 14:16:08 +0100 | [diff] [blame] | 30 | return 1; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 31 | |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 32 | if (le32_to_cpu(emeta_buf->header.identifier) != PBLK_MAGIC) |
Hans Holmberg | 06bc072 | 2018-01-05 14:16:08 +0100 | [diff] [blame] | 33 | return 1; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 34 | |
Hans Holmberg | 06bc072 | 2018-01-05 14:16:08 +0100 | [diff] [blame] | 35 | return 0; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | static int pblk_recov_l2p_from_emeta(struct pblk *pblk, struct pblk_line *line) |
| 39 | { |
| 40 | struct nvm_tgt_dev *dev = pblk->dev; |
| 41 | struct nvm_geo *geo = &dev->geo; |
| 42 | struct pblk_line_meta *lm = &pblk->lm; |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 43 | struct pblk_emeta *emeta = line->emeta; |
| 44 | struct line_emeta *emeta_buf = emeta->buf; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 45 | __le64 *lba_list; |
Hans Holmberg | 75610cd | 2017-10-13 14:46:38 +0200 | [diff] [blame] | 46 | u64 data_start, data_end; |
| 47 | u64 nr_valid_lbas, nr_lbas = 0; |
| 48 | u64 i; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 49 | |
Hans Holmberg | 06bc072 | 2018-01-05 14:16:08 +0100 | [diff] [blame] | 50 | lba_list = emeta_to_lbas(pblk, emeta_buf); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 51 | if (!lba_list) |
| 52 | return 1; |
| 53 | |
| 54 | data_start = pblk_line_smeta_start(pblk, line) + lm->smeta_sec; |
Hans Holmberg | 75610cd | 2017-10-13 14:46:38 +0200 | [diff] [blame] | 55 | data_end = line->emeta_ssec; |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 56 | nr_valid_lbas = le64_to_cpu(emeta_buf->nr_valid_lbas); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 57 | |
Hans Holmberg | 9295709 | 2017-10-13 14:46:35 +0200 | [diff] [blame] | 58 | for (i = data_start; i < data_end; i++) { |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 59 | struct ppa_addr ppa; |
| 60 | int pos; |
| 61 | |
Javier González | b1bcfda | 2018-01-05 14:16:06 +0100 | [diff] [blame] | 62 | ppa = addr_to_gen_ppa(pblk, i, line->id); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 63 | pos = pblk_ppa_to_pos(geo, ppa); |
| 64 | |
| 65 | /* Do not update bad blocks */ |
| 66 | if (test_bit(pos, line->blk_bitmap)) |
| 67 | continue; |
| 68 | |
| 69 | if (le64_to_cpu(lba_list[i]) == ADDR_EMPTY) { |
| 70 | spin_lock(&line->lock); |
| 71 | if (test_and_set_bit(i, line->invalid_bitmap)) |
Dan Carpenter | 2a79efd | 2017-04-15 20:55:52 +0200 | [diff] [blame] | 72 | WARN_ONCE(1, "pblk: rec. double invalidate:\n"); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 73 | else |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 74 | le32_add_cpu(line->vsc, -1); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 75 | spin_unlock(&line->lock); |
| 76 | |
| 77 | continue; |
| 78 | } |
| 79 | |
| 80 | pblk_update_map(pblk, le64_to_cpu(lba_list[i]), ppa); |
| 81 | nr_lbas++; |
| 82 | } |
| 83 | |
| 84 | if (nr_valid_lbas != nr_lbas) |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 85 | pblk_err(pblk, "line %d - inconsistent lba list(%llu/%llu)\n", |
Hans Holmberg | 75610cd | 2017-10-13 14:46:38 +0200 | [diff] [blame] | 86 | line->id, nr_valid_lbas, nr_lbas); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 87 | |
| 88 | line->left_msecs = 0; |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 93 | static void pblk_update_line_wp(struct pblk *pblk, struct pblk_line *line, |
| 94 | u64 written_secs) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 95 | { |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 96 | int i; |
| 97 | |
| 98 | for (i = 0; i < written_secs; i += pblk->min_write_pgs) |
| 99 | pblk_alloc_page(pblk, line, pblk->min_write_pgs); |
| 100 | } |
| 101 | |
| 102 | static u64 pblk_sec_in_open_line(struct pblk *pblk, struct pblk_line *line) |
| 103 | { |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 104 | struct pblk_line_meta *lm = &pblk->lm; |
| 105 | int nr_bb = bitmap_weight(line->blk_bitmap, lm->blk_per_line); |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 106 | u64 written_secs = 0; |
| 107 | int valid_chunks = 0; |
| 108 | int i; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 109 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 110 | for (i = 0; i < lm->blk_per_line; i++) { |
| 111 | struct nvm_chk_meta *chunk = &line->chks[i]; |
| 112 | |
| 113 | if (chunk->state & NVM_CHK_ST_OFFLINE) |
| 114 | continue; |
| 115 | |
| 116 | written_secs += chunk->wp; |
| 117 | valid_chunks++; |
| 118 | } |
| 119 | |
| 120 | if (lm->blk_per_line - nr_bb != valid_chunks) |
| 121 | pblk_err(pblk, "recovery line %d is bad\n", line->id); |
| 122 | |
| 123 | pblk_update_line_wp(pblk, line, written_secs - lm->smeta_sec); |
| 124 | |
| 125 | return written_secs; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | struct pblk_recov_alloc { |
| 129 | struct ppa_addr *ppa_list; |
Igor Konopko | faa79f2 | 2018-12-11 20:16:23 +0100 | [diff] [blame] | 130 | void *meta_list; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 131 | struct nvm_rq *rqd; |
| 132 | void *data; |
| 133 | dma_addr_t dma_ppa_list; |
| 134 | dma_addr_t dma_meta_list; |
| 135 | }; |
| 136 | |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 137 | static void pblk_recov_complete(struct kref *ref) |
| 138 | { |
| 139 | struct pblk_pad_rq *pad_rq = container_of(ref, struct pblk_pad_rq, ref); |
| 140 | |
| 141 | complete(&pad_rq->wait); |
| 142 | } |
| 143 | |
| 144 | static void pblk_end_io_recov(struct nvm_rq *rqd) |
| 145 | { |
Hans Holmberg | d68a934 | 2018-10-09 13:11:46 +0200 | [diff] [blame] | 146 | struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 147 | struct pblk_pad_rq *pad_rq = rqd->private; |
| 148 | struct pblk *pblk = pad_rq->pblk; |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 149 | |
Matias Bjørling | 43241cf | 2018-10-09 13:11:51 +0200 | [diff] [blame] | 150 | pblk_up_chunk(pblk, ppa_list[0]); |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 151 | |
Javier González | e2cddf2 | 2017-10-13 14:46:19 +0200 | [diff] [blame] | 152 | pblk_free_rqd(pblk, rqd, PBLK_WRITE_INT); |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 153 | |
| 154 | atomic_dec(&pblk->inflight_io); |
| 155 | kref_put(&pad_rq->ref, pblk_recov_complete); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 156 | } |
| 157 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 158 | /* pad line using line bitmap. */ |
| 159 | static int pblk_recov_pad_line(struct pblk *pblk, struct pblk_line *line, |
| 160 | int left_ppas) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 161 | { |
| 162 | struct nvm_tgt_dev *dev = pblk->dev; |
| 163 | struct nvm_geo *geo = &dev->geo; |
Igor Konopko | faa79f2 | 2018-12-11 20:16:23 +0100 | [diff] [blame] | 164 | void *meta_list; |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 165 | struct pblk_pad_rq *pad_rq; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 166 | struct nvm_rq *rqd; |
| 167 | struct bio *bio; |
| 168 | void *data; |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 169 | __le64 *lba_list = emeta_to_lbas(pblk, line->emeta->buf); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 170 | u64 w_ptr = line->cur_sec; |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 171 | int left_line_ppas, rq_ppas, rq_len; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 172 | int i, j; |
| 173 | int ret = 0; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 174 | |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 175 | spin_lock(&line->lock); |
| 176 | left_line_ppas = line->left_msecs; |
| 177 | spin_unlock(&line->lock); |
| 178 | |
| 179 | pad_rq = kmalloc(sizeof(struct pblk_pad_rq), GFP_KERNEL); |
| 180 | if (!pad_rq) |
| 181 | return -ENOMEM; |
| 182 | |
Kees Cook | fad953c | 2018-06-12 14:27:37 -0700 | [diff] [blame] | 183 | data = vzalloc(array_size(pblk->max_write_pgs, geo->csecs)); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 184 | if (!data) { |
| 185 | ret = -ENOMEM; |
| 186 | goto free_rq; |
| 187 | } |
| 188 | |
| 189 | pad_rq->pblk = pblk; |
| 190 | init_completion(&pad_rq->wait); |
| 191 | kref_init(&pad_rq->ref); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 192 | |
| 193 | next_pad_rq: |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 194 | rq_ppas = pblk_calc_secs(pblk, left_ppas, 0, false); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 195 | if (rq_ppas < pblk->min_write_pgs) { |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 196 | pblk_err(pblk, "corrupted pad line %d\n", line->id); |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 197 | goto fail_free_pad; |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 198 | } |
| 199 | |
Javier González | e46f4e4 | 2018-03-30 00:05:10 +0200 | [diff] [blame] | 200 | rq_len = rq_ppas * geo->csecs; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 201 | |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 202 | bio = pblk_bio_map_addr(pblk, data, rq_ppas, rq_len, |
| 203 | PBLK_VMALLOC_META, GFP_KERNEL); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 204 | if (IS_ERR(bio)) { |
| 205 | ret = PTR_ERR(bio); |
Javier González | 45dcf29 | 2018-10-09 13:12:02 +0200 | [diff] [blame] | 206 | goto fail_free_pad; |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 207 | } |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 208 | |
| 209 | bio->bi_iter.bi_sector = 0; /* internal bio */ |
| 210 | bio_set_op_attrs(bio, REQ_OP_WRITE, 0); |
| 211 | |
Javier González | e2cddf2 | 2017-10-13 14:46:19 +0200 | [diff] [blame] | 212 | rqd = pblk_alloc_rqd(pblk, PBLK_WRITE_INT); |
Javier González | 2942f50 | 2017-10-13 14:46:10 +0200 | [diff] [blame] | 213 | |
Javier González | 45dcf29 | 2018-10-09 13:12:02 +0200 | [diff] [blame] | 214 | ret = pblk_alloc_rqd_meta(pblk, rqd); |
| 215 | if (ret) |
| 216 | goto fail_free_rqd; |
| 217 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 218 | rqd->bio = bio; |
| 219 | rqd->opcode = NVM_OP_PWRITE; |
Matias Bjørling | d7b6801 | 2018-10-09 13:11:32 +0200 | [diff] [blame] | 220 | rqd->is_seq = 1; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 221 | rqd->nr_ppas = rq_ppas; |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 222 | rqd->end_io = pblk_end_io_recov; |
| 223 | rqd->private = pad_rq; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 224 | |
Javier González | 45dcf29 | 2018-10-09 13:12:02 +0200 | [diff] [blame] | 225 | meta_list = rqd->meta_list; |
| 226 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 227 | for (i = 0; i < rqd->nr_ppas; ) { |
| 228 | struct ppa_addr ppa; |
| 229 | int pos; |
| 230 | |
| 231 | w_ptr = pblk_alloc_page(pblk, line, pblk->min_write_pgs); |
Javier González | b1bcfda | 2018-01-05 14:16:06 +0100 | [diff] [blame] | 232 | ppa = addr_to_gen_ppa(pblk, w_ptr, line->id); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 233 | pos = pblk_ppa_to_pos(geo, ppa); |
| 234 | |
| 235 | while (test_bit(pos, line->blk_bitmap)) { |
| 236 | w_ptr += pblk->min_write_pgs; |
Javier González | b1bcfda | 2018-01-05 14:16:06 +0100 | [diff] [blame] | 237 | ppa = addr_to_gen_ppa(pblk, w_ptr, line->id); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 238 | pos = pblk_ppa_to_pos(geo, ppa); |
| 239 | } |
| 240 | |
| 241 | for (j = 0; j < pblk->min_write_pgs; j++, i++, w_ptr++) { |
| 242 | struct ppa_addr dev_ppa; |
Igor Konopko | faa79f2 | 2018-12-11 20:16:23 +0100 | [diff] [blame] | 243 | struct pblk_sec_meta *meta; |
Javier González | f417aa0 | 2017-06-30 17:56:34 +0200 | [diff] [blame] | 244 | __le64 addr_empty = cpu_to_le64(ADDR_EMPTY); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 245 | |
| 246 | dev_ppa = addr_to_gen_ppa(pblk, w_ptr, line->id); |
| 247 | |
| 248 | pblk_map_invalidate(pblk, dev_ppa); |
Igor Konopko | faa79f2 | 2018-12-11 20:16:23 +0100 | [diff] [blame] | 249 | lba_list[w_ptr] = addr_empty; |
| 250 | meta = pblk_get_meta(pblk, meta_list, i); |
| 251 | meta->lba = addr_empty; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 252 | rqd->ppa_list[i] = dev_ppa; |
| 253 | } |
| 254 | } |
| 255 | |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 256 | kref_get(&pad_rq->ref); |
Matias Bjørling | 43241cf | 2018-10-09 13:11:51 +0200 | [diff] [blame] | 257 | pblk_down_chunk(pblk, rqd->ppa_list[0]); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 258 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 259 | ret = pblk_submit_io(pblk, rqd); |
| 260 | if (ret) { |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 261 | pblk_err(pblk, "I/O submission failed: %d\n", ret); |
Matias Bjørling | 43241cf | 2018-10-09 13:11:51 +0200 | [diff] [blame] | 262 | pblk_up_chunk(pblk, rqd->ppa_list[0]); |
Javier González | 45dcf29 | 2018-10-09 13:12:02 +0200 | [diff] [blame] | 263 | goto fail_free_rqd; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 264 | } |
| 265 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 266 | left_line_ppas -= rq_ppas; |
| 267 | left_ppas -= rq_ppas; |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 268 | if (left_ppas && left_line_ppas) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 269 | goto next_pad_rq; |
| 270 | |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 271 | kref_put(&pad_rq->ref, pblk_recov_complete); |
| 272 | |
| 273 | if (!wait_for_completion_io_timeout(&pad_rq->wait, |
| 274 | msecs_to_jiffies(PBLK_COMMAND_TIMEOUT_MS))) { |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 275 | pblk_err(pblk, "pad write timed out\n"); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 276 | ret = -ETIME; |
| 277 | } |
| 278 | |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 279 | if (!pblk_line_is_full(line)) |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 280 | pblk_err(pblk, "corrupted padded line: %d\n", line->id); |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 281 | |
| 282 | vfree(data); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 283 | free_rq: |
| 284 | kfree(pad_rq); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 285 | return ret; |
| 286 | |
Javier González | 45dcf29 | 2018-10-09 13:12:02 +0200 | [diff] [blame] | 287 | fail_free_rqd: |
| 288 | pblk_free_rqd(pblk, rqd, PBLK_WRITE_INT); |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 289 | bio_put(bio); |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 290 | fail_free_pad: |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 291 | kfree(pad_rq); |
Javier González | 3eaa11e | 2017-07-07 21:08:52 +0200 | [diff] [blame] | 292 | vfree(data); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 293 | return ret; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 294 | } |
| 295 | |
Javier González | 63dee3a | 2018-10-09 13:11:57 +0200 | [diff] [blame] | 296 | static int pblk_pad_distance(struct pblk *pblk, struct pblk_line *line) |
| 297 | { |
| 298 | struct nvm_tgt_dev *dev = pblk->dev; |
| 299 | struct nvm_geo *geo = &dev->geo; |
| 300 | int distance = geo->mw_cunits * geo->all_luns * geo->ws_opt; |
| 301 | |
| 302 | return (distance > line->left_msecs) ? line->left_msecs : distance; |
| 303 | } |
| 304 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 305 | static int pblk_line_wp_is_unbalanced(struct pblk *pblk, |
| 306 | struct pblk_line *line) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 307 | { |
| 308 | struct nvm_tgt_dev *dev = pblk->dev; |
| 309 | struct nvm_geo *geo = &dev->geo; |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 310 | struct pblk_line_meta *lm = &pblk->lm; |
| 311 | struct pblk_lun *rlun; |
| 312 | struct nvm_chk_meta *chunk; |
| 313 | struct ppa_addr ppa; |
| 314 | u64 line_wp; |
| 315 | int pos, i; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 316 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 317 | rlun = &pblk->luns[0]; |
| 318 | ppa = rlun->bppa; |
| 319 | pos = pblk_ppa_to_pos(geo, ppa); |
| 320 | chunk = &line->chks[pos]; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 321 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 322 | line_wp = chunk->wp; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 323 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 324 | for (i = 1; i < lm->blk_per_line; i++) { |
| 325 | rlun = &pblk->luns[i]; |
| 326 | ppa = rlun->bppa; |
Javier González | b1bcfda | 2018-01-05 14:16:06 +0100 | [diff] [blame] | 327 | pos = pblk_ppa_to_pos(geo, ppa); |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 328 | chunk = &line->chks[pos]; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 329 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 330 | if (chunk->wp > line_wp) |
| 331 | return 1; |
| 332 | else if (chunk->wp < line_wp) |
| 333 | line_wp = chunk->wp; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 334 | } |
| 335 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 336 | return 0; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | static int pblk_recov_scan_oob(struct pblk *pblk, struct pblk_line *line, |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 340 | struct pblk_recov_alloc p) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 341 | { |
| 342 | struct nvm_tgt_dev *dev = pblk->dev; |
Zhoujie Wu | f40a62d | 2018-12-11 20:16:07 +0100 | [diff] [blame] | 343 | struct pblk_line_meta *lm = &pblk->lm; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 344 | struct nvm_geo *geo = &dev->geo; |
| 345 | struct ppa_addr *ppa_list; |
Igor Konopko | faa79f2 | 2018-12-11 20:16:23 +0100 | [diff] [blame] | 346 | void *meta_list; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 347 | struct nvm_rq *rqd; |
| 348 | struct bio *bio; |
| 349 | void *data; |
| 350 | dma_addr_t dma_ppa_list, dma_meta_list; |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 351 | __le64 *lba_list; |
Zhoujie Wu | f40a62d | 2018-12-11 20:16:07 +0100 | [diff] [blame] | 352 | u64 paddr = pblk_line_smeta_start(pblk, line) + lm->smeta_sec; |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 353 | bool padded = false; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 354 | int rq_ppas, rq_len; |
| 355 | int i, j; |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 356 | int ret; |
Zhoujie Wu | f40a62d | 2018-12-11 20:16:07 +0100 | [diff] [blame] | 357 | u64 left_ppas = pblk_sec_in_open_line(pblk, line) - lm->smeta_sec; |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 358 | |
| 359 | if (pblk_line_wp_is_unbalanced(pblk, line)) |
| 360 | pblk_warn(pblk, "recovering unbalanced line (%d)\n", line->id); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 361 | |
| 362 | ppa_list = p.ppa_list; |
| 363 | meta_list = p.meta_list; |
| 364 | rqd = p.rqd; |
| 365 | data = p.data; |
| 366 | dma_ppa_list = p.dma_ppa_list; |
| 367 | dma_meta_list = p.dma_meta_list; |
| 368 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 369 | lba_list = emeta_to_lbas(pblk, line->emeta->buf); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 370 | |
| 371 | next_rq: |
Javier González | 084ec9b | 2017-06-26 16:27:13 -0600 | [diff] [blame] | 372 | memset(rqd, 0, pblk_g_rq_size); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 373 | |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 374 | rq_ppas = pblk_calc_secs(pblk, left_ppas, 0, false); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 375 | if (!rq_ppas) |
| 376 | rq_ppas = pblk->min_write_pgs; |
Javier González | e46f4e4 | 2018-03-30 00:05:10 +0200 | [diff] [blame] | 377 | rq_len = rq_ppas * geo->csecs; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 378 | |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 379 | retry_rq: |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 380 | bio = bio_map_kern(dev->q, data, rq_len, GFP_KERNEL); |
| 381 | if (IS_ERR(bio)) |
| 382 | return PTR_ERR(bio); |
| 383 | |
| 384 | bio->bi_iter.bi_sector = 0; /* internal bio */ |
| 385 | bio_set_op_attrs(bio, REQ_OP_READ, 0); |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 386 | bio_get(bio); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 387 | |
| 388 | rqd->bio = bio; |
| 389 | rqd->opcode = NVM_OP_PREAD; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 390 | rqd->meta_list = meta_list; |
| 391 | rqd->nr_ppas = rq_ppas; |
| 392 | rqd->ppa_list = ppa_list; |
| 393 | rqd->dma_ppa_list = dma_ppa_list; |
| 394 | rqd->dma_meta_list = dma_meta_list; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 395 | |
Javier González | f9c1015 | 2017-06-26 11:57:20 +0200 | [diff] [blame] | 396 | if (pblk_io_aligned(pblk, rq_ppas)) |
Matias Bjørling | d7b6801 | 2018-10-09 13:11:32 +0200 | [diff] [blame] | 397 | rqd->is_seq = 1; |
Javier González | f9c1015 | 2017-06-26 11:57:20 +0200 | [diff] [blame] | 398 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 399 | for (i = 0; i < rqd->nr_ppas; ) { |
| 400 | struct ppa_addr ppa; |
| 401 | int pos; |
| 402 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 403 | ppa = addr_to_gen_ppa(pblk, paddr, line->id); |
Javier González | b1bcfda | 2018-01-05 14:16:06 +0100 | [diff] [blame] | 404 | pos = pblk_ppa_to_pos(geo, ppa); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 405 | |
| 406 | while (test_bit(pos, line->blk_bitmap)) { |
| 407 | paddr += pblk->min_write_pgs; |
| 408 | ppa = addr_to_gen_ppa(pblk, paddr, line->id); |
Javier González | b1bcfda | 2018-01-05 14:16:06 +0100 | [diff] [blame] | 409 | pos = pblk_ppa_to_pos(geo, ppa); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 410 | } |
| 411 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 412 | for (j = 0; j < pblk->min_write_pgs; j++, i++) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 413 | rqd->ppa_list[i] = |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 414 | addr_to_gen_ppa(pblk, paddr + j, line->id); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 415 | } |
| 416 | |
Javier González | 1a94b2d | 2017-10-13 14:46:47 +0200 | [diff] [blame] | 417 | ret = pblk_submit_io_sync(pblk, rqd); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 418 | if (ret) { |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 419 | pblk_err(pblk, "I/O submission failed: %d\n", ret); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 420 | bio_put(bio); |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 421 | bio_put(bio); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 422 | return ret; |
| 423 | } |
| 424 | |
Javier González | 588726d3 | 2017-06-26 11:57:29 +0200 | [diff] [blame] | 425 | atomic_dec(&pblk->inflight_io); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 426 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 427 | /* If a read fails, do a best effort by padding the line and retrying */ |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 428 | if (rqd->error) { |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 429 | int pad_distance, ret; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 430 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 431 | if (padded) { |
| 432 | pblk_log_read_err(pblk, rqd); |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 433 | bio_put(bio); |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 434 | return -EINTR; |
| 435 | } |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 436 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 437 | pad_distance = pblk_pad_distance(pblk, line); |
| 438 | ret = pblk_recov_pad_line(pblk, line, pad_distance); |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 439 | if (ret) { |
| 440 | bio_put(bio); |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 441 | return ret; |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 442 | } |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 443 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 444 | padded = true; |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 445 | bio_put(bio); |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 446 | goto retry_rq; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 447 | } |
| 448 | |
Igor Konopko | 55d8ec3 | 2018-12-11 20:16:26 +0100 | [diff] [blame^] | 449 | pblk_get_packed_meta(pblk, rqd); |
| 450 | bio_put(bio); |
| 451 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 452 | for (i = 0; i < rqd->nr_ppas; i++) { |
Igor Konopko | faa79f2 | 2018-12-11 20:16:23 +0100 | [diff] [blame] | 453 | struct pblk_sec_meta *meta = pblk_get_meta(pblk, meta_list, i); |
| 454 | u64 lba = le64_to_cpu(meta->lba); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 455 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 456 | lba_list[paddr++] = cpu_to_le64(lba); |
| 457 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 458 | if (lba == ADDR_EMPTY || lba > pblk->rl.nr_secs) |
| 459 | continue; |
| 460 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 461 | line->nr_valid_lbas++; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 462 | pblk_update_map(pblk, lba, rqd->ppa_list[i]); |
| 463 | } |
| 464 | |
| 465 | left_ppas -= rq_ppas; |
| 466 | if (left_ppas > 0) |
| 467 | goto next_rq; |
| 468 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 469 | #ifdef CONFIG_NVM_PBLK_DEBUG |
| 470 | WARN_ON(padded && !pblk_line_is_full(line)); |
| 471 | #endif |
| 472 | |
| 473 | return 0; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | /* Scan line for lbas on out of bound area */ |
| 477 | static int pblk_recov_l2p_from_oob(struct pblk *pblk, struct pblk_line *line) |
| 478 | { |
| 479 | struct nvm_tgt_dev *dev = pblk->dev; |
| 480 | struct nvm_geo *geo = &dev->geo; |
| 481 | struct nvm_rq *rqd; |
| 482 | struct ppa_addr *ppa_list; |
Igor Konopko | faa79f2 | 2018-12-11 20:16:23 +0100 | [diff] [blame] | 483 | void *meta_list; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 484 | struct pblk_recov_alloc p; |
| 485 | void *data; |
| 486 | dma_addr_t dma_ppa_list, dma_meta_list; |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 487 | int ret = 0; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 488 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 489 | meta_list = nvm_dev_dma_alloc(dev->parent, GFP_KERNEL, &dma_meta_list); |
Javier González | 2942f50 | 2017-10-13 14:46:10 +0200 | [diff] [blame] | 490 | if (!meta_list) |
| 491 | return -ENOMEM; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 492 | |
Igor Konopko | 24828d0 | 2018-12-11 20:16:24 +0100 | [diff] [blame] | 493 | ppa_list = (void *)(meta_list) + pblk_dma_meta_size(pblk); |
| 494 | dma_ppa_list = dma_meta_list + pblk_dma_meta_size(pblk); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 495 | |
Javier González | e46f4e4 | 2018-03-30 00:05:10 +0200 | [diff] [blame] | 496 | data = kcalloc(pblk->max_write_pgs, geo->csecs, GFP_KERNEL); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 497 | if (!data) { |
| 498 | ret = -ENOMEM; |
| 499 | goto free_meta_list; |
| 500 | } |
| 501 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 502 | rqd = mempool_alloc(&pblk->r_rq_pool, GFP_KERNEL); |
| 503 | memset(rqd, 0, pblk_g_rq_size); |
Javier González | 2942f50 | 2017-10-13 14:46:10 +0200 | [diff] [blame] | 504 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 505 | p.ppa_list = ppa_list; |
| 506 | p.meta_list = meta_list; |
| 507 | p.rqd = rqd; |
| 508 | p.data = data; |
| 509 | p.dma_ppa_list = dma_ppa_list; |
| 510 | p.dma_meta_list = dma_meta_list; |
| 511 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 512 | ret = pblk_recov_scan_oob(pblk, line, p); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 513 | if (ret) { |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 514 | pblk_err(pblk, "could not recover L2P form OOB\n"); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 515 | goto out; |
| 516 | } |
| 517 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 518 | if (pblk_line_is_full(line)) |
| 519 | pblk_line_recov_close(pblk, line); |
| 520 | |
| 521 | out: |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 522 | mempool_free(rqd, &pblk->r_rq_pool); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 523 | kfree(data); |
| 524 | free_meta_list: |
| 525 | nvm_dev_dma_free(dev->parent, meta_list, dma_meta_list); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 526 | |
| 527 | return ret; |
| 528 | } |
| 529 | |
| 530 | /* Insert lines ordered by sequence number (seq_num) on list */ |
| 531 | static void pblk_recov_line_add_ordered(struct list_head *head, |
| 532 | struct pblk_line *line) |
| 533 | { |
| 534 | struct pblk_line *t = NULL; |
| 535 | |
| 536 | list_for_each_entry(t, head, list) |
| 537 | if (t->seq_nr > line->seq_nr) |
| 538 | break; |
| 539 | |
| 540 | __list_add(&line->list, t->list.prev, &t->list); |
| 541 | } |
| 542 | |
Hans Holmberg | 75610cd | 2017-10-13 14:46:38 +0200 | [diff] [blame] | 543 | static u64 pblk_line_emeta_start(struct pblk *pblk, struct pblk_line *line) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 544 | { |
| 545 | struct nvm_tgt_dev *dev = pblk->dev; |
| 546 | struct nvm_geo *geo = &dev->geo; |
| 547 | struct pblk_line_meta *lm = &pblk->lm; |
Hans Holmberg | 75610cd | 2017-10-13 14:46:38 +0200 | [diff] [blame] | 548 | unsigned int emeta_secs; |
| 549 | u64 emeta_start; |
| 550 | struct ppa_addr ppa; |
| 551 | int pos; |
| 552 | |
| 553 | emeta_secs = lm->emeta_sec[0]; |
| 554 | emeta_start = lm->sec_per_line; |
| 555 | |
| 556 | while (emeta_secs) { |
| 557 | emeta_start--; |
Javier González | b1bcfda | 2018-01-05 14:16:06 +0100 | [diff] [blame] | 558 | ppa = addr_to_gen_ppa(pblk, emeta_start, line->id); |
Hans Holmberg | 75610cd | 2017-10-13 14:46:38 +0200 | [diff] [blame] | 559 | pos = pblk_ppa_to_pos(geo, ppa); |
| 560 | if (!test_bit(pos, line->blk_bitmap)) |
| 561 | emeta_secs--; |
| 562 | } |
| 563 | |
| 564 | return emeta_start; |
| 565 | } |
| 566 | |
Hans Holmberg | d0ab0b1 | 2018-03-30 00:04:51 +0200 | [diff] [blame] | 567 | static int pblk_recov_check_line_version(struct pblk *pblk, |
| 568 | struct line_emeta *emeta) |
| 569 | { |
| 570 | struct line_header *header = &emeta->header; |
| 571 | |
| 572 | if (header->version_major != EMETA_VERSION_MAJOR) { |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 573 | pblk_err(pblk, "line major version mismatch: %d, expected: %d\n", |
| 574 | header->version_major, EMETA_VERSION_MAJOR); |
Hans Holmberg | d0ab0b1 | 2018-03-30 00:04:51 +0200 | [diff] [blame] | 575 | return 1; |
| 576 | } |
| 577 | |
Matias Bjørling | 99b8dad | 2018-07-13 10:48:38 +0200 | [diff] [blame] | 578 | #ifdef CONFIG_NVM_PBLK_DEBUG |
Hans Holmberg | d0ab0b1 | 2018-03-30 00:04:51 +0200 | [diff] [blame] | 579 | if (header->version_minor > EMETA_VERSION_MINOR) |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 580 | pblk_info(pblk, "newer line minor version found: %d\n", |
Matias Bjørling | 99b8dad | 2018-07-13 10:48:38 +0200 | [diff] [blame] | 581 | header->version_minor); |
Hans Holmberg | d0ab0b1 | 2018-03-30 00:04:51 +0200 | [diff] [blame] | 582 | #endif |
| 583 | |
| 584 | return 0; |
| 585 | } |
| 586 | |
Hans Holmberg | 7675839 | 2018-03-30 00:04:52 +0200 | [diff] [blame] | 587 | static void pblk_recov_wa_counters(struct pblk *pblk, |
| 588 | struct line_emeta *emeta) |
| 589 | { |
| 590 | struct pblk_line_meta *lm = &pblk->lm; |
| 591 | struct line_header *header = &emeta->header; |
| 592 | struct wa_counters *wa = emeta_to_wa(lm, emeta); |
| 593 | |
| 594 | /* WA counters were introduced in emeta version 0.2 */ |
| 595 | if (header->version_major > 0 || header->version_minor >= 2) { |
| 596 | u64 user = le64_to_cpu(wa->user); |
| 597 | u64 pad = le64_to_cpu(wa->pad); |
| 598 | u64 gc = le64_to_cpu(wa->gc); |
| 599 | |
| 600 | atomic64_set(&pblk->user_wa, user); |
| 601 | atomic64_set(&pblk->pad_wa, pad); |
| 602 | atomic64_set(&pblk->gc_wa, gc); |
| 603 | |
| 604 | pblk->user_rst_wa = user; |
| 605 | pblk->pad_rst_wa = pad; |
| 606 | pblk->gc_rst_wa = gc; |
| 607 | } |
| 608 | } |
| 609 | |
Hans Holmberg | 9156f36 | 2018-03-30 00:05:22 +0200 | [diff] [blame] | 610 | static int pblk_line_was_written(struct pblk_line *line, |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 611 | struct pblk *pblk) |
Hans Holmberg | 9156f36 | 2018-03-30 00:05:22 +0200 | [diff] [blame] | 612 | { |
| 613 | |
Hans Holmberg | b06be28 | 2018-06-01 16:41:12 +0200 | [diff] [blame] | 614 | struct pblk_line_meta *lm = &pblk->lm; |
| 615 | struct nvm_tgt_dev *dev = pblk->dev; |
| 616 | struct nvm_geo *geo = &dev->geo; |
| 617 | struct nvm_chk_meta *chunk; |
| 618 | struct ppa_addr bppa; |
| 619 | int smeta_blk; |
Hans Holmberg | 9156f36 | 2018-03-30 00:05:22 +0200 | [diff] [blame] | 620 | |
Hans Holmberg | b06be28 | 2018-06-01 16:41:12 +0200 | [diff] [blame] | 621 | if (line->state == PBLK_LINESTATE_BAD) |
| 622 | return 0; |
Hans Holmberg | 9156f36 | 2018-03-30 00:05:22 +0200 | [diff] [blame] | 623 | |
Hans Holmberg | b06be28 | 2018-06-01 16:41:12 +0200 | [diff] [blame] | 624 | smeta_blk = find_first_zero_bit(line->blk_bitmap, lm->blk_per_line); |
| 625 | if (smeta_blk >= lm->blk_per_line) |
| 626 | return 0; |
| 627 | |
| 628 | bppa = pblk->luns[smeta_blk].bppa; |
| 629 | chunk = &line->chks[pblk_ppa_to_pos(geo, bppa)]; |
| 630 | |
| 631 | if (chunk->state & NVM_CHK_ST_FREE) |
| 632 | return 0; |
| 633 | |
| 634 | return 1; |
Hans Holmberg | 9156f36 | 2018-03-30 00:05:22 +0200 | [diff] [blame] | 635 | } |
| 636 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 637 | static bool pblk_line_is_open(struct pblk *pblk, struct pblk_line *line) |
| 638 | { |
| 639 | struct pblk_line_meta *lm = &pblk->lm; |
| 640 | int i; |
| 641 | |
| 642 | for (i = 0; i < lm->blk_per_line; i++) |
| 643 | if (line->chks[i].state & NVM_CHK_ST_OPEN) |
| 644 | return true; |
| 645 | |
| 646 | return false; |
| 647 | } |
| 648 | |
Hans Holmberg | 75610cd | 2017-10-13 14:46:38 +0200 | [diff] [blame] | 649 | struct pblk_line *pblk_recov_l2p(struct pblk *pblk) |
| 650 | { |
| 651 | struct pblk_line_meta *lm = &pblk->lm; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 652 | struct pblk_line_mgmt *l_mg = &pblk->l_mg; |
| 653 | struct pblk_line *line, *tline, *data_line = NULL; |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 654 | struct pblk_smeta *smeta; |
| 655 | struct pblk_emeta *emeta; |
| 656 | struct line_smeta *smeta_buf; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 657 | int found_lines = 0, recovered_lines = 0, open_lines = 0; |
| 658 | int is_next = 0; |
| 659 | int meta_line; |
| 660 | int i, valid_uuid = 0; |
| 661 | LIST_HEAD(recov_list); |
| 662 | |
| 663 | /* TODO: Implement FTL snapshot */ |
| 664 | |
| 665 | /* Scan recovery - takes place when FTL snapshot fails */ |
| 666 | spin_lock(&l_mg->free_lock); |
| 667 | meta_line = find_first_zero_bit(&l_mg->meta_bitmap, PBLK_DATA_LINES); |
| 668 | set_bit(meta_line, &l_mg->meta_bitmap); |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 669 | smeta = l_mg->sline_meta[meta_line]; |
| 670 | emeta = l_mg->eline_meta[meta_line]; |
Javier González | 8224cbd | 2017-06-30 17:56:38 +0200 | [diff] [blame] | 671 | smeta_buf = (struct line_smeta *)smeta; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 672 | spin_unlock(&l_mg->free_lock); |
| 673 | |
| 674 | /* Order data lines using their sequence number */ |
| 675 | for (i = 0; i < l_mg->nr_lines; i++) { |
| 676 | u32 crc; |
| 677 | |
| 678 | line = &pblk->lines[i]; |
| 679 | |
| 680 | memset(smeta, 0, lm->smeta_len); |
| 681 | line->smeta = smeta; |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 682 | line->lun_bitmap = ((void *)(smeta_buf)) + |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 683 | sizeof(struct line_smeta); |
| 684 | |
Hans Holmberg | b06be28 | 2018-06-01 16:41:12 +0200 | [diff] [blame] | 685 | if (!pblk_line_was_written(line, pblk)) |
Hans Holmberg | 9156f36 | 2018-03-30 00:05:22 +0200 | [diff] [blame] | 686 | continue; |
| 687 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 688 | /* Lines that cannot be read are assumed as not written here */ |
Javier González | af3fac1 | 2018-10-09 13:12:03 +0200 | [diff] [blame] | 689 | if (pblk_line_smeta_read(pblk, line)) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 690 | continue; |
| 691 | |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 692 | crc = pblk_calc_smeta_crc(pblk, smeta_buf); |
| 693 | if (le32_to_cpu(smeta_buf->crc) != crc) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 694 | continue; |
| 695 | |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 696 | if (le32_to_cpu(smeta_buf->header.identifier) != PBLK_MAGIC) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 697 | continue; |
| 698 | |
Hans Holmberg | d0ab0b1 | 2018-03-30 00:04:51 +0200 | [diff] [blame] | 699 | if (smeta_buf->header.version_major != SMETA_VERSION_MAJOR) { |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 700 | pblk_err(pblk, "found incompatible line version %u\n", |
Hans Holmberg | d0ab0b1 | 2018-03-30 00:04:51 +0200 | [diff] [blame] | 701 | smeta_buf->header.version_major); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 702 | return ERR_PTR(-EINVAL); |
| 703 | } |
| 704 | |
| 705 | /* The first valid instance uuid is used for initialization */ |
| 706 | if (!valid_uuid) { |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 707 | memcpy(pblk->instance_uuid, smeta_buf->header.uuid, 16); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 708 | valid_uuid = 1; |
| 709 | } |
| 710 | |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 711 | if (memcmp(pblk->instance_uuid, smeta_buf->header.uuid, 16)) { |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 712 | pblk_debug(pblk, "ignore line %u due to uuid mismatch\n", |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 713 | i); |
| 714 | continue; |
| 715 | } |
| 716 | |
| 717 | /* Update line metadata */ |
| 718 | spin_lock(&line->lock); |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 719 | line->id = le32_to_cpu(smeta_buf->header.id); |
| 720 | line->type = le16_to_cpu(smeta_buf->header.type); |
| 721 | line->seq_nr = le64_to_cpu(smeta_buf->seq_nr); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 722 | spin_unlock(&line->lock); |
| 723 | |
| 724 | /* Update general metadata */ |
| 725 | spin_lock(&l_mg->free_lock); |
| 726 | if (line->seq_nr >= l_mg->d_seq_nr) |
| 727 | l_mg->d_seq_nr = line->seq_nr + 1; |
| 728 | l_mg->nr_free_lines--; |
| 729 | spin_unlock(&l_mg->free_lock); |
| 730 | |
| 731 | if (pblk_line_recov_alloc(pblk, line)) |
| 732 | goto out; |
| 733 | |
| 734 | pblk_recov_line_add_ordered(&recov_list, line); |
| 735 | found_lines++; |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 736 | pblk_debug(pblk, "recovering data line %d, seq:%llu\n", |
Javier González | dd2a434 | 2017-06-26 11:57:17 +0200 | [diff] [blame] | 737 | line->id, smeta_buf->seq_nr); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | if (!found_lines) { |
| 741 | pblk_setup_uuid(pblk); |
| 742 | |
| 743 | spin_lock(&l_mg->free_lock); |
| 744 | WARN_ON_ONCE(!test_and_clear_bit(meta_line, |
| 745 | &l_mg->meta_bitmap)); |
| 746 | spin_unlock(&l_mg->free_lock); |
| 747 | |
| 748 | goto out; |
| 749 | } |
| 750 | |
| 751 | /* Verify closed blocks and recover this portion of L2P table*/ |
| 752 | list_for_each_entry_safe(line, tline, &recov_list, list) { |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 753 | recovered_lines++; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 754 | |
Hans Holmberg | 75610cd | 2017-10-13 14:46:38 +0200 | [diff] [blame] | 755 | line->emeta_ssec = pblk_line_emeta_start(pblk, line); |
Javier González | 8224cbd | 2017-06-30 17:56:38 +0200 | [diff] [blame] | 756 | line->emeta = emeta; |
| 757 | memset(line->emeta->buf, 0, lm->emeta_len[0]); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 758 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 759 | if (pblk_line_is_open(pblk, line)) { |
| 760 | pblk_recov_l2p_from_oob(pblk, line); |
| 761 | goto next; |
| 762 | } |
| 763 | |
Javier González | af3fac1 | 2018-10-09 13:12:03 +0200 | [diff] [blame] | 764 | if (pblk_line_emeta_read(pblk, line, line->emeta->buf)) { |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 765 | pblk_recov_l2p_from_oob(pblk, line); |
| 766 | goto next; |
| 767 | } |
| 768 | |
Hans Holmberg | 06bc072 | 2018-01-05 14:16:08 +0100 | [diff] [blame] | 769 | if (pblk_recov_check_emeta(pblk, line->emeta->buf)) { |
| 770 | pblk_recov_l2p_from_oob(pblk, line); |
| 771 | goto next; |
| 772 | } |
| 773 | |
Hans Holmberg | d0ab0b1 | 2018-03-30 00:04:51 +0200 | [diff] [blame] | 774 | if (pblk_recov_check_line_version(pblk, line->emeta->buf)) |
| 775 | return ERR_PTR(-EINVAL); |
| 776 | |
Hans Holmberg | 7675839 | 2018-03-30 00:04:52 +0200 | [diff] [blame] | 777 | pblk_recov_wa_counters(pblk, line->emeta->buf); |
| 778 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 779 | if (pblk_recov_l2p_from_emeta(pblk, line)) |
| 780 | pblk_recov_l2p_from_oob(pblk, line); |
| 781 | |
| 782 | next: |
| 783 | if (pblk_line_is_full(line)) { |
| 784 | struct list_head *move_list; |
| 785 | |
| 786 | spin_lock(&line->lock); |
| 787 | line->state = PBLK_LINESTATE_CLOSED; |
Hans Holmberg | f293723 | 2018-10-09 13:11:53 +0200 | [diff] [blame] | 788 | trace_pblk_line_state(pblk_disk_name(pblk), line->id, |
| 789 | line->state); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 790 | move_list = pblk_line_gc_list(pblk, line); |
| 791 | spin_unlock(&line->lock); |
| 792 | |
| 793 | spin_lock(&l_mg->gc_lock); |
| 794 | list_move_tail(&line->list, move_list); |
| 795 | spin_unlock(&l_mg->gc_lock); |
| 796 | |
Hans Holmberg | 53d82db | 2018-10-09 13:11:47 +0200 | [diff] [blame] | 797 | mempool_free(line->map_bitmap, l_mg->bitmap_pool); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 798 | line->map_bitmap = NULL; |
| 799 | line->smeta = NULL; |
| 800 | line->emeta = NULL; |
| 801 | } else { |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 802 | spin_lock(&line->lock); |
| 803 | line->state = PBLK_LINESTATE_OPEN; |
| 804 | spin_unlock(&line->lock); |
| 805 | |
| 806 | line->emeta->mem = 0; |
| 807 | atomic_set(&line->emeta->sync, 0); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 808 | |
Hans Holmberg | f293723 | 2018-10-09 13:11:53 +0200 | [diff] [blame] | 809 | trace_pblk_line_state(pblk_disk_name(pblk), line->id, |
| 810 | line->state); |
| 811 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 812 | data_line = line; |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 813 | line->meta_line = meta_line; |
| 814 | |
| 815 | open_lines++; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 816 | } |
| 817 | } |
| 818 | |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 819 | if (!open_lines) { |
Jia-Ju Bai | 7325b4b | 2018-10-09 13:12:00 +0200 | [diff] [blame] | 820 | spin_lock(&l_mg->free_lock); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 821 | WARN_ON_ONCE(!test_and_clear_bit(meta_line, |
| 822 | &l_mg->meta_bitmap)); |
Jia-Ju Bai | 7325b4b | 2018-10-09 13:12:00 +0200 | [diff] [blame] | 823 | spin_unlock(&l_mg->free_lock); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 824 | } else { |
Jia-Ju Bai | 7325b4b | 2018-10-09 13:12:00 +0200 | [diff] [blame] | 825 | spin_lock(&l_mg->free_lock); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 826 | /* Allocate next line for preparation */ |
| 827 | l_mg->data_next = pblk_line_get(pblk); |
| 828 | if (l_mg->data_next) { |
| 829 | l_mg->data_next->seq_nr = l_mg->d_seq_nr++; |
| 830 | l_mg->data_next->type = PBLK_LINETYPE_DATA; |
| 831 | is_next = 1; |
| 832 | } |
Jia-Ju Bai | 7325b4b | 2018-10-09 13:12:00 +0200 | [diff] [blame] | 833 | spin_unlock(&l_mg->free_lock); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 834 | } |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 835 | |
Javier González | a768993 | 2018-01-05 14:16:13 +0100 | [diff] [blame] | 836 | if (is_next) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 837 | pblk_line_erase(pblk, l_mg->data_next); |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 838 | |
| 839 | out: |
| 840 | if (found_lines != recovered_lines) |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 841 | pblk_err(pblk, "failed to recover all found lines %d/%d\n", |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 842 | found_lines, recovered_lines); |
| 843 | |
| 844 | return data_line; |
| 845 | } |
| 846 | |
| 847 | /* |
Javier González | 588726d3 | 2017-06-26 11:57:29 +0200 | [diff] [blame] | 848 | * Pad current line |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 849 | */ |
Javier González | 588726d3 | 2017-06-26 11:57:29 +0200 | [diff] [blame] | 850 | int pblk_recov_pad(struct pblk *pblk) |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 851 | { |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 852 | struct pblk_line *line; |
| 853 | struct pblk_line_mgmt *l_mg = &pblk->l_mg; |
Javier González | 588726d3 | 2017-06-26 11:57:29 +0200 | [diff] [blame] | 854 | int left_msecs; |
| 855 | int ret = 0; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 856 | |
| 857 | spin_lock(&l_mg->free_lock); |
| 858 | line = l_mg->data_line; |
Javier González | 588726d3 | 2017-06-26 11:57:29 +0200 | [diff] [blame] | 859 | left_msecs = line->left_msecs; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 860 | spin_unlock(&l_mg->free_lock); |
| 861 | |
Javier González | 6ad2f61 | 2018-10-09 13:12:05 +0200 | [diff] [blame] | 862 | ret = pblk_recov_pad_line(pblk, line, left_msecs); |
Javier González | 588726d3 | 2017-06-26 11:57:29 +0200 | [diff] [blame] | 863 | if (ret) { |
Matias Bjørling | 4e495a4 | 2018-07-13 10:48:42 +0200 | [diff] [blame] | 864 | pblk_err(pblk, "tear down padding failed (%d)\n", ret); |
Javier González | ee8d5c1 | 2017-06-30 17:56:40 +0200 | [diff] [blame] | 865 | return ret; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 866 | } |
| 867 | |
Javier González | 588726d3 | 2017-06-26 11:57:29 +0200 | [diff] [blame] | 868 | pblk_line_close_meta(pblk, line); |
Javier González | 588726d3 | 2017-06-26 11:57:29 +0200 | [diff] [blame] | 869 | return ret; |
Javier González | a4bd217 | 2017-04-15 20:55:50 +0200 | [diff] [blame] | 870 | } |