All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: dm-devel@redhat.com, "Alasdair G. Kergon" <agk@redhat.com>
Subject: [PATCH v2 7/7] dm snapshot: use bufio prefetch
Date: Mon, 13 Jan 2014 16:37:59 -0500	[thread overview]
Message-ID: <20140113213758.GC3268@redhat.com> (raw)
In-Reply-To: <alpine.LRH.2.02.1401111231420.4018@file01.intranet.prod.int.rdu2.redhat.com>

From: Mikulas Patocka <mpatocka@redhat.com>

This patch modifies dm-snapshot so that it prefetches the buffers when
loading the exceptions.

The number of chunk-sized buffers read ahead is specified in the
DM_PREFETCH_CHUNKS macro.  The current default for DM_PREFETCH_CHUNKS
(12) may need to be adjusted to improve performance on different types
of storage -- a future patch should make this configurable.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 drivers/md/dm-snap-persistent.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index 1692750..ea45b3b 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -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.
@@ -490,6 +492,30 @@ static int insert_exceptions(struct pstore *ps, void *ps_area,
 	return 0;
 }
 
+static void bufio_prefetch_chunks(struct dm_bufio_client *client,
+				  struct pstore *ps)
+{
+	chunk_t prefetch_area = 0;
+	chunk_t pf_chunk;
+
+	if (!DM_PREFETCH_CHUNKS)
+		return;
+
+	if (prefetch_area < ps->current_area)
+		prefetch_area = ps->current_area;
+
+	do {
+		pf_chunk = area_location(ps, prefetch_area);
+		if (unlikely(pf_chunk >= dm_bufio_get_device_size(client)))
+			break;
+		if (unlikely(!dm_bufio_prefetch(client, pf_chunk, 1)))
+			break;
+		prefetch_area++;
+		if (unlikely(!prefetch_area))
+			break;
+	} while (prefetch_area <= ps->current_area + DM_PREFETCH_CHUNKS);
+}
+
 static int read_exceptions(struct pstore *ps,
 			   int (*callback)(void *callback_context, chunk_t old,
 					   chunk_t new),
@@ -505,6 +531,8 @@ static int read_exceptions(struct pstore *ps,
 	if (IS_ERR(client))
 		return PTR_ERR(client);
 
+	dm_bufio_set_minimum_buffers(client, DM_PREFETCH_CHUNKS + 1);
+
 	/*
 	 * Keeping reading chunks and inserting exceptions until
 	 * we find a partially full area.
@@ -512,7 +540,11 @@ 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;
+
+		bufio_prefetch_chunks(client, ps);
+
+		chunk = area_location(ps, ps->current_area);
 
 		area = dm_bufio_read(client, chunk, &bp);
 		if (unlikely(IS_ERR(area))) {
-- 
1.7.4.4

  parent reply	other threads:[~2014-01-13 21:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-11 17:28 [PATCH 0/7] dm-snapshot prefetch patches Mikulas Patocka
2014-01-11 17:29 ` [PATCH 1/7] dm-bufio: return success or failure on prefetch Mikulas Patocka
2014-01-11 17:29   ` [PATCH 2/7] dm-bufio: introduce dm_bufio_forget Mikulas Patocka
2014-01-11 17:30     ` [PATCH 3/7] dm-bufio: introduce dm_bufio_set_minimum_buffers Mikulas Patocka
2014-01-11 17:30       ` [PATCH 4/7] dm-snapshot: use GFP_KERNEL when initializing the snapshot Mikulas Patocka
2014-01-11 17:30         ` [PATCH 5/7] dm-snapshot: make ps->area explicit Mikulas Patocka
2014-01-11 17:31           ` [PATCH 6/7] dm-snapshot: use dm-bufio Mikulas Patocka
2014-01-11 17:32             ` [PATCH 7/7] dm-snapshot: use bufio prefetch Mikulas Patocka
2014-01-13 21:27               ` Mike Snitzer
2014-01-13 22:03                 ` Mikulas Patocka
2014-01-13 21:37               ` Mike Snitzer [this message]
2014-01-13 22:00                 ` [PATCH v2 7/7] dm snapshot: " Mikulas Patocka
2014-01-13 22:56                   ` Mike Snitzer
2014-01-13 23:45                     ` Mikulas Patocka
2014-01-13 23:59                       ` Mike Snitzer
2014-01-14  0:11                         ` Mikulas Patocka
2014-01-13 21:21   ` [PATCH 1/7] dm-bufio: return success or failure on prefetch Mike Snitzer
2014-01-14  0:11     ` Mikulas Patocka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140113213758.GC3268@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mpatocka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.