From owner-svn-src-head@FreeBSD.ORG  Mon Dec  8 16:48:58 2014
Return-Path: <owner-svn-src-head@FreeBSD.ORG>
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id CE9D815B;
 Mon,  8 Dec 2014 16:48:58 +0000 (UTC)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id A1177C58;
 Mon,  8 Dec 2014 16:48:58 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sB8GmwUF019054;
 Mon, 8 Dec 2014 16:48:58 GMT (envelope-from kib@FreeBSD.org)
Received: (from kib@localhost)
 by svn.freebsd.org (8.14.9/8.14.9/Submit) id sB8GmwCB019038;
 Mon, 8 Dec 2014 16:48:58 GMT (envelope-from kib@FreeBSD.org)
Message-Id: <201412081648.sB8GmwCB019038@svn.freebsd.org>
X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org
 using -f
From: Konstantin Belousov <kib@FreeBSD.org>
Date: Mon, 8 Dec 2014 16:48:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r275620 - in head/sys: kern sys
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.18-1
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 08 Dec 2014 16:48:58 -0000

Author: kib
Date: Mon Dec  8 16:48:57 2014
New Revision: 275620
URL: https://svnweb.freebsd.org/changeset/base/275620

Log:
  Add functions syncer_suspend() and syncer_resume(), which are supposed
  to be called before suspension and after resume, correspondingly.  The
  syncer_suspend() ensures that all filesystems dirty data and metadata
  are saved to the permanent storage, and stops kernel threads which
  might modify filesystems.  The syncer_resume() restores stopped
  threads.
  
  For now, only syncer is stopped.  This is needed, because each sync
  loop causes superblock updates for UFS.
  
  Tested by:	pho
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/kern/vfs_subr.c
  head/sys/sys/mount.h

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Mon Dec  8 16:42:34 2014	(r275619)
+++ head/sys/kern/vfs_subr.c	Mon Dec  8 16:48:57 2014	(r275620)
@@ -1773,6 +1773,8 @@ sync_vnode(struct synclist *slp, struct 
 	return (0);
 }
 
+static int first_printf = 1;
+
 /*
  * System filesystem synchronizer daemon.
  */
@@ -1791,7 +1793,6 @@ sched_sync(void)
 
 	last_work_seen = 0;
 	syncer_final_iter = 0;
-	first_printf = 1;
 	syncer_state = SYNCER_RUNNING;
 	starttime = time_uptime;
 	td->td_pflags |= TDP_NORUNNINGBUF;
@@ -1955,6 +1956,25 @@ syncer_shutdown(void *arg, int howto)
 	kproc_shutdown(arg, howto);
 }
 
+void
+syncer_suspend(void)
+{
+
+	syncer_shutdown(updateproc, 0);
+}
+
+void
+syncer_resume(void)
+{
+
+	mtx_lock(&sync_mtx);
+	first_printf = 1;
+	syncer_state = SYNCER_RUNNING;
+	mtx_unlock(&sync_mtx);
+	cv_broadcast(&sync_wakeup);
+	kproc_resume(updateproc);
+}
+
 /*
  * Reassign a buffer from one vnode to another.
  * Used to assign file specific control information

Modified: head/sys/sys/mount.h
==============================================================================
--- head/sys/sys/mount.h	Mon Dec  8 16:42:34 2014	(r275619)
+++ head/sys/sys/mount.h	Mon Dec  8 16:48:57 2014	(r275620)
@@ -917,6 +917,9 @@ vfs_uninit_t		vfs_stduninit;
 vfs_extattrctl_t	vfs_stdextattrctl;
 vfs_sysctl_t		vfs_stdsysctl;
 
+void	syncer_suspend(void);
+void	syncer_resume(void);
+
 #else /* !_KERNEL */
 
 #include <sys/cdefs.h>