aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2017-11-30 20:36:29 +0000
committerMark Johnston <markj@FreeBSD.org>2017-11-30 20:36:29 +0000
commit2ceafb776e4d7fc5c46ce3ba67f37ba3e419c04b (patch)
treedb5365421d6f6bafba14755e8922ae90f42cce9b /sys
parent64de3fdd5893e55c8aa20df2dcf1d9e86d851b34 (diff)
downloadsrc-2ceafb776e4d7fc5c46ce3ba67f37ba3e419c04b.tar.gz
src-2ceafb776e4d7fc5c46ce3ba67f37ba3e419c04b.zip
Update gmirror metadata less frequently when synchronizing.
We periodically record synchronization progress in the metadata block of the disk being synchronized; this allows an interrupted synchronization to be resumed. However, the frequency of these updates heavily pessimized synchronization time on some media. This change modifies gmirror to update metadata based on a time period, and adds a sysctl to control that period. The default value results in a much lower update frequency and increases the completion time for an interrupted rebuild only marginally. Reported by: Andre Albsmeier <andre@fbsd.e4m.org> MFC after: 3 weeks
Notes
Notes: svn path=/head/; revision=326409
Diffstat (limited to 'sys')
-rw-r--r--sys/geom/mirror/g_mirror.c10
-rw-r--r--sys/geom/mirror/g_mirror.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c
index baa4c1f28fa8..7aec8f24c285 100644
--- a/sys/geom/mirror/g_mirror.c
+++ b/sys/geom/mirror/g_mirror.c
@@ -71,6 +71,10 @@ SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN,
static u_int g_mirror_syncreqs = 2;
SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, sync_requests, CTLFLAG_RDTUN,
&g_mirror_syncreqs, 0, "Parallel synchronization I/O requests.");
+static u_int g_mirror_sync_period = 5;
+SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, sync_update_period, CTLFLAG_RWTUN,
+ &g_mirror_sync_period, 0,
+ "Metadata update period during synchroniztion, in seconds");
#define MSLEEP(ident, mtx, priority, wmesg, timeout) do { \
G_MIRROR_DEBUG(4, "%s: Sleeping %p.", __func__, (ident)); \
@@ -465,6 +469,7 @@ g_mirror_init_disk(struct g_mirror_softc *sc, struct g_provider *pp,
disk->d_sync.ds_consumer = NULL;
disk->d_sync.ds_offset = md->md_sync_offset;
disk->d_sync.ds_offset_done = md->md_sync_offset;
+ disk->d_sync.ds_update_ts = time_uptime;
disk->d_genid = md->md_genid;
disk->d_sync.ds_syncid = md->md_syncid;
if (errorp != NULL)
@@ -1459,10 +1464,11 @@ g_mirror_sync_request(struct bio *bp)
if (bp != NULL && bp->bio_offset < offset)
offset = bp->bio_offset;
}
- if (sync->ds_offset_done + (MAXPHYS * 100) < offset) {
- /* Update offset_done on every 100 blocks. */
+ if (g_mirror_sync_period > 0 &&
+ time_uptime - sync->ds_update_ts > g_mirror_sync_period) {
sync->ds_offset_done = offset;
g_mirror_update_metadata(disk);
+ sync->ds_update_ts = time_uptime;
}
return;
}
diff --git a/sys/geom/mirror/g_mirror.h b/sys/geom/mirror/g_mirror.h
index c29fc53ebde0..84b31100de5f 100644
--- a/sys/geom/mirror/g_mirror.h
+++ b/sys/geom/mirror/g_mirror.h
@@ -110,6 +110,7 @@ struct g_mirror_disk_sync {
off_t ds_offset; /* Offset of next request to send. */
off_t ds_offset_done; /* Offset of already synchronized
region. */
+ time_t ds_update_ts; /* Time of last metadata update. */
u_int ds_syncid; /* Disk's synchronization ID. */
u_int ds_inflight; /* Number of in-flight sync requests. */
struct bio **ds_bios; /* BIOs for synchronization I/O. */