Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Nov 2017 20:36:29 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326409 - head/sys/geom/mirror
Message-ID:  <201711302036.vAUKaT0Q022677@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Thu Nov 30 20:36:29 2017
New Revision: 326409
URL: https://svnweb.freebsd.org/changeset/base/326409

Log:
  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

Modified:
  head/sys/geom/mirror/g_mirror.c
  head/sys/geom/mirror/g_mirror.h

Modified: head/sys/geom/mirror/g_mirror.c
==============================================================================
--- head/sys/geom/mirror/g_mirror.c	Thu Nov 30 20:33:45 2017	(r326408)
+++ head/sys/geom/mirror/g_mirror.c	Thu Nov 30 20:36:29 2017	(r326409)
@@ -71,6 +71,10 @@ SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on
 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
 	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;
 	    }

Modified: head/sys/geom/mirror/g_mirror.h
==============================================================================
--- head/sys/geom/mirror/g_mirror.h	Thu Nov 30 20:33:45 2017	(r326408)
+++ head/sys/geom/mirror/g_mirror.h	Thu Nov 30 20:36:29 2017	(r326409)
@@ -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. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711302036.vAUKaT0Q022677>