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
This commit is contained in:
Mark Johnston 2017-11-30 20:36:29 +00:00
parent 64de3fdd58
commit 2ceafb776e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326409
2 changed files with 9 additions and 2 deletions

View File

@ -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;
}

View File

@ -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. */