Skip to content

Commit a96de64

Browse files
igorkonopkoaxboe
authored andcommitted
lightnvm: pblk: simplify partial read path
This patch changes the approach to handling partial read path. In old approach merging of data from round buffer and drive was fully made by drive. This had some disadvantages - code was complex and relies on bio internals, so it was hard to maintain and was strongly dependent on bio changes. In new approach most of the handling is done mostly by block layer functions such as bio_split(), bio_chain() and generic_make request() and generally is less complex and easier to maintain. Below some more details of the new approach. When read bio arrives, it is cloned for pblk internal purposes. All the L2P mapping, which includes copying data from round buffer to bio and thus bio_advance() calls is done on the cloned bio, so the original bio is untouched. If we found that we have partial read case, we still have original bio untouched, so we can split it and continue to process only first part of it in current context, when the rest will be called as separate bio request which is passed to generic_make_request() for further processing. Signed-off-by: Igor Konopko <[email protected]> Reviewed-by: Heiner Litz <[email protected]> Reviewed-by: Javier González <[email protected]> Signed-off-by: Matias Bjørling <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 843f2ed commit a96de64

File tree

4 files changed

+100
-281
lines changed

4 files changed

+100
-281
lines changed

drivers/lightnvm/pblk-core.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,8 +2147,8 @@ void pblk_update_map_dev(struct pblk *pblk, sector_t lba,
21472147
spin_unlock(&pblk->trans_lock);
21482148
}
21492149

2150-
void pblk_lookup_l2p_seq(struct pblk *pblk, struct ppa_addr *ppas,
2151-
sector_t blba, int nr_secs)
2150+
int pblk_lookup_l2p_seq(struct pblk *pblk, struct ppa_addr *ppas,
2151+
sector_t blba, int nr_secs, bool *from_cache)
21522152
{
21532153
int i;
21542154

@@ -2162,10 +2162,19 @@ void pblk_lookup_l2p_seq(struct pblk *pblk, struct ppa_addr *ppas,
21622162
if (!pblk_ppa_empty(ppa) && !pblk_addr_in_cache(ppa)) {
21632163
struct pblk_line *line = pblk_ppa_to_line(pblk, ppa);
21642164

2165+
if (i > 0 && *from_cache)
2166+
break;
2167+
*from_cache = false;
2168+
21652169
kref_get(&line->ref);
2170+
} else {
2171+
if (i > 0 && !*from_cache)
2172+
break;
2173+
*from_cache = true;
21662174
}
21672175
}
21682176
spin_unlock(&pblk->trans_lock);
2177+
return i;
21692178
}
21702179

21712180
void pblk_lookup_l2p_rand(struct pblk *pblk, struct ppa_addr *ppas,

drivers/lightnvm/pblk-rb.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ unsigned int pblk_rb_read_to_bio(struct pblk_rb *rb, struct nvm_rq *rqd,
642642
* be directed to disk.
643643
*/
644644
int pblk_rb_copy_to_bio(struct pblk_rb *rb, struct bio *bio, sector_t lba,
645-
struct ppa_addr ppa, int bio_iter, bool advanced_bio)
645+
struct ppa_addr ppa)
646646
{
647647
struct pblk *pblk = container_of(rb, struct pblk, rwb);
648648
struct pblk_rb_entry *entry;
@@ -673,15 +673,6 @@ int pblk_rb_copy_to_bio(struct pblk_rb *rb, struct bio *bio, sector_t lba,
673673
ret = 0;
674674
goto out;
675675
}
676-
677-
/* Only advance the bio if it hasn't been advanced already. If advanced,
678-
* this bio is at least a partial bio (i.e., it has partially been
679-
* filled with data from the cache). If part of the data resides on the
680-
* media, we will read later on
681-
*/
682-
if (unlikely(!advanced_bio))
683-
bio_advance(bio, bio_iter * PBLK_EXPOSED_PAGE_SIZE);
684-
685676
data = bio_data(bio);
686677
memcpy(data, entry->data, rb->seg_size);
687678

0 commit comments

Comments
 (0)