Skip to content

Commit 8a01a6a

Browse files
jthornbersnitm
authored andcommitted
dm thin: prefetch missing metadata pages
Prefetch metadata at the start of the worker thread and then again every 128th bio processed from the deferred list. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent 4646015 commit 8a01a6a

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

drivers/md/dm-thin-metadata.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,3 +1809,8 @@ bool dm_pool_metadata_needs_check(struct dm_pool_metadata *pmd)
18091809

18101810
return needs_check;
18111811
}
1812+
1813+
void dm_pool_issue_prefetches(struct dm_pool_metadata *pmd)
1814+
{
1815+
dm_tm_issue_prefetches(pmd->tm);
1816+
}

drivers/md/dm-thin-metadata.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd,
213213
int dm_pool_metadata_set_needs_check(struct dm_pool_metadata *pmd);
214214
bool dm_pool_metadata_needs_check(struct dm_pool_metadata *pmd);
215215

216+
/*
217+
* Issue any prefetches that may be useful.
218+
*/
219+
void dm_pool_issue_prefetches(struct dm_pool_metadata *pmd);
220+
216221
/*----------------------------------------------------------------*/
217222

218223
#endif

drivers/md/dm-thin.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@ static void process_thin_deferred_bios(struct thin_c *tc)
15261526
struct bio *bio;
15271527
struct bio_list bios;
15281528
struct blk_plug plug;
1529+
unsigned count = 0;
15291530

15301531
if (tc->requeue_mode) {
15311532
requeue_bio_list(tc, &tc->deferred_bio_list);
@@ -1567,6 +1568,10 @@ static void process_thin_deferred_bios(struct thin_c *tc)
15671568
pool->process_discard(tc, bio);
15681569
else
15691570
pool->process_bio(tc, bio);
1571+
1572+
if ((count++ & 127) == 0) {
1573+
dm_pool_issue_prefetches(pool->pmd);
1574+
}
15701575
}
15711576
blk_finish_plug(&plug);
15721577
}
@@ -1652,6 +1657,7 @@ static void do_worker(struct work_struct *ws)
16521657
{
16531658
struct pool *pool = container_of(ws, struct pool, worker);
16541659

1660+
dm_pool_issue_prefetches(pool->pmd);
16551661
process_prepared(pool, &pool->prepared_mappings, &pool->process_prepared_mapping);
16561662
process_prepared(pool, &pool->prepared_discards, &pool->process_prepared_discard);
16571663
process_deferred_bios(pool);
@@ -1996,10 +2002,6 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
19962002
/* fall through */
19972003

19982004
case -EWOULDBLOCK:
1999-
/*
2000-
* In future, the failed dm_thin_find_block above could
2001-
* provide the hint to load the metadata into cache.
2002-
*/
20032005
thin_defer_bio(tc, bio);
20042006
cell_defer_no_holder_no_free(tc, &cell1);
20052007
return DM_MAPIO_SUBMITTED;

0 commit comments

Comments
 (0)