|
@@ -18,6 +18,8 @@
|
|
|
#define DM_MSG_PREFIX "persistent snapshot"
|
|
|
#define DM_CHUNK_SIZE_DEFAULT_SECTORS 32 /* 16KB */
|
|
|
|
|
|
+#define DM_PREFETCH_CHUNKS 12
|
|
|
+
|
|
|
/*-----------------------------------------------------------------
|
|
|
* Persistent snapshots, by persistent we mean that the snapshot
|
|
|
* will survive a reboot.
|
|
@@ -497,6 +499,7 @@ static int read_exceptions(struct pstore *ps,
|
|
|
{
|
|
|
int r, full = 1;
|
|
|
struct dm_bufio_client *client;
|
|
|
+ chunk_t prefetch_area = 0;
|
|
|
|
|
|
client = dm_bufio_client_create(dm_snap_cow(ps->store->snap)->bdev,
|
|
|
ps->store->chunk_size << SECTOR_SHIFT,
|
|
@@ -505,6 +508,11 @@ static int read_exceptions(struct pstore *ps,
|
|
|
if (IS_ERR(client))
|
|
|
return PTR_ERR(client);
|
|
|
|
|
|
+ /*
|
|
|
+ * Setup for one current buffer + desired readahead buffers.
|
|
|
+ */
|
|
|
+ dm_bufio_set_minimum_buffers(client, 1 + DM_PREFETCH_CHUNKS);
|
|
|
+
|
|
|
/*
|
|
|
* Keeping reading chunks and inserting exceptions until
|
|
|
* we find a partially full area.
|
|
@@ -512,7 +520,22 @@ static int read_exceptions(struct pstore *ps,
|
|
|
for (ps->current_area = 0; full; ps->current_area++) {
|
|
|
struct dm_buffer *bp;
|
|
|
void *area;
|
|
|
- chunk_t chunk = area_location(ps, ps->current_area);
|
|
|
+ chunk_t chunk;
|
|
|
+
|
|
|
+ if (unlikely(prefetch_area < ps->current_area))
|
|
|
+ prefetch_area = ps->current_area;
|
|
|
+
|
|
|
+ if (DM_PREFETCH_CHUNKS) do {
|
|
|
+ chunk_t pf_chunk = area_location(ps, prefetch_area);
|
|
|
+ if (unlikely(pf_chunk >= dm_bufio_get_device_size(client)))
|
|
|
+ break;
|
|
|
+ dm_bufio_prefetch(client, pf_chunk, 1);
|
|
|
+ prefetch_area++;
|
|
|
+ if (unlikely(!prefetch_area))
|
|
|
+ break;
|
|
|
+ } while (prefetch_area <= ps->current_area + DM_PREFETCH_CHUNKS);
|
|
|
+
|
|
|
+ chunk = area_location(ps, ps->current_area);
|
|
|
|
|
|
area = dm_bufio_read(client, chunk, &bp);
|
|
|
if (unlikely(IS_ERR(area))) {
|