diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2014-01-13 19:13:05 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2014-01-14 23:23:03 -0500 |
commit | 55b082e614e219fb5199a6f93e648ed35d3c96d5 (patch) | |
tree | a2707e62bdd914e9651e78cde6cb55a5f0b88d7f /drivers/md/dm-snap-persistent.c | |
parent | 55494bf2947dccdf2d98b62374fea7365dfead84 (diff) |
dm snapshot: use dm-bufio prefetch
This patch modifies dm-snapshot so that it prefetches the buffers when
loading the exceptions.
The number of buffers read ahead is specified in the DM_PREFETCH_CHUNKS
macro. The current value for DM_PREFETCH_CHUNKS (12) was found to
provide the best performance on a single 15k SCSI spindle. In the
future we may modify this default or make it configurable.
Also, introduce the function dm_bufio_set_minimum_buffers to setup
bufio's number of internal buffers before freeing happens. dm-bufio may
hold more buffers if enough memory is available. There is no guarantee
that the specified number of buffers will be available - if you need a
guarantee, use the argument reserved_buffers for
dm_bufio_client_create.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-snap-persistent.c')
-rw-r--r-- | drivers/md/dm-snap-persistent.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c index 169275050c0b..afc3d017de4c 100644 --- a/drivers/md/dm-snap-persistent.c +++ b/drivers/md/dm-snap-persistent.c | |||
@@ -18,6 +18,8 @@ | |||
18 | #define DM_MSG_PREFIX "persistent snapshot" | 18 | #define DM_MSG_PREFIX "persistent snapshot" |
19 | #define DM_CHUNK_SIZE_DEFAULT_SECTORS 32 /* 16KB */ | 19 | #define DM_CHUNK_SIZE_DEFAULT_SECTORS 32 /* 16KB */ |
20 | 20 | ||
21 | #define DM_PREFETCH_CHUNKS 12 | ||
22 | |||
21 | /*----------------------------------------------------------------- | 23 | /*----------------------------------------------------------------- |
22 | * Persistent snapshots, by persistent we mean that the snapshot | 24 | * Persistent snapshots, by persistent we mean that the snapshot |
23 | * will survive a reboot. | 25 | * will survive a reboot. |
@@ -497,6 +499,7 @@ static int read_exceptions(struct pstore *ps, | |||
497 | { | 499 | { |
498 | int r, full = 1; | 500 | int r, full = 1; |
499 | struct dm_bufio_client *client; | 501 | struct dm_bufio_client *client; |
502 | chunk_t prefetch_area = 0; | ||
500 | 503 | ||
501 | client = dm_bufio_client_create(dm_snap_cow(ps->store->snap)->bdev, | 504 | client = dm_bufio_client_create(dm_snap_cow(ps->store->snap)->bdev, |
502 | ps->store->chunk_size << SECTOR_SHIFT, | 505 | ps->store->chunk_size << SECTOR_SHIFT, |
@@ -506,13 +509,33 @@ static int read_exceptions(struct pstore *ps, | |||
506 | return PTR_ERR(client); | 509 | return PTR_ERR(client); |
507 | 510 | ||
508 | /* | 511 | /* |
512 | * Setup for one current buffer + desired readahead buffers. | ||
513 | */ | ||
514 | dm_bufio_set_minimum_buffers(client, 1 + DM_PREFETCH_CHUNKS); | ||
515 | |||
516 | /* | ||
509 | * Keeping reading chunks and inserting exceptions until | 517 | * Keeping reading chunks and inserting exceptions until |
510 | * we find a partially full area. | 518 | * we find a partially full area. |
511 | */ | 519 | */ |
512 | for (ps->current_area = 0; full; ps->current_area++) { | 520 | for (ps->current_area = 0; full; ps->current_area++) { |
513 | struct dm_buffer *bp; | 521 | struct dm_buffer *bp; |
514 | void *area; | 522 | void *area; |
515 | chunk_t chunk = area_location(ps, ps->current_area); | 523 | chunk_t chunk; |
524 | |||
525 | if (unlikely(prefetch_area < ps->current_area)) | ||
526 | prefetch_area = ps->current_area; | ||
527 | |||
528 | if (DM_PREFETCH_CHUNKS) do { | ||
529 | chunk_t pf_chunk = area_location(ps, prefetch_area); | ||
530 | if (unlikely(pf_chunk >= dm_bufio_get_device_size(client))) | ||
531 | break; | ||
532 | dm_bufio_prefetch(client, pf_chunk, 1); | ||
533 | prefetch_area++; | ||
534 | if (unlikely(!prefetch_area)) | ||
535 | break; | ||
536 | } while (prefetch_area <= ps->current_area + DM_PREFETCH_CHUNKS); | ||
537 | |||
538 | chunk = area_location(ps, ps->current_area); | ||
516 | 539 | ||
517 | area = dm_bufio_read(client, chunk, &bp); | 540 | area = dm_bufio_read(client, chunk, &bp); |
518 | if (unlikely(IS_ERR(area))) { | 541 | if (unlikely(IS_ERR(area))) { |