Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Oct 2002 22:32:50 -0700
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        hackers@freebsd.org
Subject:   adding a delay before background fsck
Message-ID:  <20021019223250.A14311@Odin.AC.HMC.Edu>

next in thread | raw e-mail | index | archive | help

--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Please comment on the following patch to add a delay before starting
background fsck.  The issues this addresses is that it takes a long time
to start X or other large apps like mozilla while a background fsck
is running (at least on my laptop).  Once they are up and in cache,
performance is slightly bumpy, but acceptable.  Thus, being able to set
a delay (I use 120s) to allow those applications to be started, makes
background fsck much more useful.  I suspect this feature would also be
useful in aiding recover on servers.

-- Brooks

Index: share/man/man5/rc.conf.5
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/share/man/man5/rc.conf.5,v
retrieving revision 1.164
diff -u -p -r1.164 rc.conf.5
--- share/man/man5/rc.conf.5	5 Sep 2002 20:19:03 -0000	1.164
+++ share/man/man5/rc.conf.5	20 Oct 2002 05:21:36 -0000
@@ -729,6 +729,11 @@ If set to
 the system will attempt to run
 .Xr fsck 8
 in the background where possible.
+.It Va background_fsck_delay
+.Pq Vt int
+The amount of time in seconds to sleep before starting a background fsck.
+Setting this to a non-zero number may allow large applications such as
+the X server to start before disk I/O bandwidth is monopolized by fsck.
 .It Va extra_netfs_types
 .Pq Vt str
 If set to something other than
Index: etc/defaults/rc.conf
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/etc/defaults/rc.conf,v
retrieving revision 1.159
diff -u -p -r1.159 rc.conf
--- etc/defaults/rc.conf	5 Sep 2002 20:14:40 -0000	1.159
+++ etc/defaults/rc.conf	9 Oct 2002 23:12:49 -0000
@@ -39,6 +39,7 @@ script_name_sep=3D" "	# Change if your sta
 rc_conf_files=3D"/etc/rc.conf /etc/rc.conf.local"
 fsck_y_enable=3D"NO"	# Set to YES to do fsck -y if the initial preen fails.
 background_fsck=3D"YES"	# Attempt to run fsck in the background where poss=
ible.
+background_fsck_delay=3D"0" # Time to wait (seconds) before starting the f=
sck.
 extra_netfs_types=3D"NO"	# List of network extra filesystem types for dela=
yed
 			# mount at startup (or NO).
=20
Index: etc/rc.d/bgfsck
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/etc/rc.d/bgfsck,v
retrieving revision 1.2
diff -u -p -r1.2 bgfsck
--- etc/rc.d/bgfsck	28 Jul 2002 03:38:10 -0000	1.2
+++ etc/rc.d/bgfsck	9 Oct 2002 23:31:45 -0000
@@ -11,9 +11,20 @@
=20
 name=3D"background-fsck"
 rcvar=3D"background_fsck"
-start_precmd=3D"echo 'Starting background file system checks.'"
-start_cmd=3D"nice -4 fsck -B -p 2>&1 | logger -p daemon.notice &"
+start_cmd=3D"bgfsck_start"
 stop_cmd=3D":"
+
+bgfsck_start ()
+{
+	bgfsck_msg=3D'Starting background file system checks'
+	if [ ${background_fsck_delay:=3D0} -gt 0 ]; then
+		bgfsck_msg=3D"${bgfsck_msg} in ${background_fsck_delay} seconds"
+	fi
+	echo "${bgfsck_msg}."
+
+	(sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \
+	    logger -p daemon.notice &
+}
=20
 load_rc_config $name
 run_rc_command "$1"
Index: etc/rc
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/etc/rc,v
retrieving revision 1.322
diff -u -p -r1.322 rc
--- etc/rc	12 Oct 2002 07:21:18 -0000	1.322
+++ etc/rc	20 Oct 2002 05:24:06 -0000
@@ -982,8 +982,14 @@ esac
 # Start background fsck checks if necessary
 case ${background_fsck} in
 [Yy][Ee][Ss])
-	echo 'Starting background filesystem checks'
-	nice -4 fsck -B -p 2>&1 | logger -p daemon.notice &
+	bgfsck_msg=3D'Starting background file system checks'
+	if [ ${background_fsck_delay:=3D0} -gt 0 ]; then
+		bgfsck_msg=3D"${bgfsck_msg} in ${background_fsck_delay} seconds"
+	fi
+	echo "${bgfsck_msg}."
+
+	(sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \
+	    logger -p daemon.notice &
 	;;
 esac
=20

--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--OgqxwSJOaUobr8KG
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9skABXY6L6fI4GtQRAvzsAKDDBctiI4HzEb3b5jwysgFtpApwmwCg5jc4
L4ArQl+YtZzRpn2RUJ5lMmg=
=zEPc
-----END PGP SIGNATURE-----

--OgqxwSJOaUobr8KG--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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