Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: man/, src/rc/, etc/
Date: Tue, 26 Jul 2016 17:32:53
Message-Id: 1469554239.94b98430cb83a8f4e62d837100fc357e9eb12ca6.williamh@OpenRC
1 commit: 94b98430cb83a8f4e62d837100fc357e9eb12ca6
2 Author: Kenneth Lakin <kennethlakin <AT> gmail <DOT> com>
3 AuthorDate: Tue Nov 3 11:33:06 2015 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 26 17:30:39 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=94b98430
7
8 start-stop-daemon: Add SSD_IONICELEVEL
9
10 This is the disk IO counterpart to SSD_NICELEVEL.
11 Modified by William Hubbs to add the variable to the start-stop-daemon
12 man page.
13
14 This fixes #69.
15
16 etc/rc.conf | 3 +++
17 man/start-stop-daemon.8 | 4 ++++
18 src/rc/start-stop-daemon.c | 14 +++++++++++++-
19 3 files changed, 20 insertions(+), 1 deletion(-)
20
21 diff --git a/etc/rc.conf b/etc/rc.conf
22 index 80f68dd..cbb660a 100644
23 --- a/etc/rc.conf
24 +++ b/etc/rc.conf
25 @@ -117,6 +117,9 @@
26 # Some daemons are started and stopped via start-stop-daemon.
27 # We can set some things on a per service basis, like the nicelevel.
28 #SSD_NICELEVEL="-19"
29 +# Or the ionice level. The format is class[:data] , just like the
30 +# --ionice start-stop-daemon parameter.
31 +#SSD_IONICELEVEL="2:2"
32
33 # Pass ulimit parameters
34 # If you are using bash in POSIX mode for your shell, note that the
35
36 diff --git a/man/start-stop-daemon.8 b/man/start-stop-daemon.8
37 index c328895..112cd5f 100644
38 --- a/man/start-stop-daemon.8
39 +++ b/man/start-stop-daemon.8
40 @@ -153,6 +153,10 @@ The retry specification can be either a timeout in seconds or multiple
41 signal/timeout pairs (like SIGTERM/5).
42 .El
43 .Sh ENVIRONMENT
44 +.Va SSD_IONICELEVEL
45 +can also set the IO scheduling priority of the daemon, but the command line
46 +option takes precedence.
47 +.Pp
48 .Va SSD_NICELEVEL
49 can also set the scheduling priority of the daemon, but the command line
50 option takes precedence.
51
52 diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
53 index 27939c2..188169f 100644
54 --- a/src/rc/start-stop-daemon.c
55 +++ b/src/rc/start-stop-daemon.c
56 @@ -696,6 +696,17 @@ int main(int argc, char **argv)
57 if (sscanf(tmp, "%d", &nicelevel) != 1)
58 eerror("%s: invalid nice level `%s' (SSD_NICELEVEL)",
59 applet, tmp);
60 + if ((tmp = getenv("SSD_IONICELEVEL"))) {
61 + int n = sscanf(tmp, "%d:%d", &ionicec, &ioniced);
62 + if (n != 1 && n != 2)
63 + eerror("%s: invalid ionice level `%s' (SSD_IONICELEVEL)",
64 + applet, tmp);
65 + if (ionicec == 0)
66 + ioniced = 0;
67 + else if (ionicec == 3)
68 + ioniced = 7;
69 + ionicec <<= 13; /* class shift */
70 + }
71
72 /* Get our user name and initial dir */
73 p = getenv("USER");
74 @@ -1195,7 +1206,8 @@ int main(int argc, char **argv)
75 if ((strncmp(env->value, "RC_", 3) == 0 &&
76 strncmp(env->value, "RC_SERVICE=", 10) != 0 &&
77 strncmp(env->value, "RC_SVCNAME=", 10) != 0) ||
78 - strncmp(env->value, "SSD_NICELEVEL=", 14) == 0)
79 + strncmp(env->value, "SSD_NICELEVEL=", 14) == 0 ||
80 + strncmp(env->value, "SSD_IONICELEVEL=", 16) == 0)
81 {
82 p = strchr(env->value, '=');
83 *p = '\0';