aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Lakin <kennethlakin@gmail.com>2015-11-03 03:33:06 -0800
committerWilliam Hubbs <w.d.hubbs@gmail.com>2016-07-26 12:30:39 -0500
commit94b98430cb83a8f4e62d837100fc357e9eb12ca6 (patch)
tree65ddba6cb989ebf217902aba415a7fed15479be6
parentb19d0a40d7f20987323d5af91469c720ead39561 (diff)
start-stop-daemon: Add SSD_IONICELEVEL
This is the disk IO counterpart to SSD_NICELEVEL. Modified by William Hubbs to add the variable to the start-stop-daemon man page. This fixes #69.
-rw-r--r--etc/rc.conf3
-rw-r--r--man/start-stop-daemon.84
-rw-r--r--src/rc/start-stop-daemon.c14
3 files changed, 20 insertions, 1 deletions
diff --git a/etc/rc.conf b/etc/rc.conf
index 80f68ddf..cbb660a6 100644
--- a/etc/rc.conf
+++ b/etc/rc.conf
@@ -117,6 +117,9 @@
# Some daemons are started and stopped via start-stop-daemon.
# We can set some things on a per service basis, like the nicelevel.
#SSD_NICELEVEL="-19"
+# Or the ionice level. The format is class[:data] , just like the
+# --ionice start-stop-daemon parameter.
+#SSD_IONICELEVEL="2:2"
# Pass ulimit parameters
# If you are using bash in POSIX mode for your shell, note that the
diff --git a/man/start-stop-daemon.8 b/man/start-stop-daemon.8
index c3288955..112cd5fb 100644
--- a/man/start-stop-daemon.8
+++ b/man/start-stop-daemon.8
@@ -153,6 +153,10 @@ The retry specification can be either a timeout in seconds or multiple
signal/timeout pairs (like SIGTERM/5).
.El
.Sh ENVIRONMENT
+.Va SSD_IONICELEVEL
+can also set the IO scheduling priority of the daemon, but the command line
+option takes precedence.
+.Pp
.Va SSD_NICELEVEL
can also set the scheduling priority of the daemon, but the command line
option takes precedence.
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 27939c2c..188169fd 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -696,6 +696,17 @@ int main(int argc, char **argv)
if (sscanf(tmp, "%d", &nicelevel) != 1)
eerror("%s: invalid nice level `%s' (SSD_NICELEVEL)",
applet, tmp);
+ if ((tmp = getenv("SSD_IONICELEVEL"))) {
+ int n = sscanf(tmp, "%d:%d", &ionicec, &ioniced);
+ if (n != 1 && n != 2)
+ eerror("%s: invalid ionice level `%s' (SSD_IONICELEVEL)",
+ applet, tmp);
+ if (ionicec == 0)
+ ioniced = 0;
+ else if (ionicec == 3)
+ ioniced = 7;
+ ionicec <<= 13; /* class shift */
+ }
/* Get our user name and initial dir */
p = getenv("USER");
@@ -1195,7 +1206,8 @@ int main(int argc, char **argv)
if ((strncmp(env->value, "RC_", 3) == 0 &&
strncmp(env->value, "RC_SERVICE=", 10) != 0 &&
strncmp(env->value, "RC_SVCNAME=", 10) != 0) ||
- strncmp(env->value, "SSD_NICELEVEL=", 14) == 0)
+ strncmp(env->value, "SSD_NICELEVEL=", 14) == 0 ||
+ strncmp(env->value, "SSD_IONICELEVEL=", 16) == 0)
{
p = strchr(env->value, '=');
*p = '\0';