1
0
forked from pool/util-linux
util-linux/util-linux-2.13-schedutils_ionice_idle.patch

56 lines
1.7 KiB
Diff

From 19ab897e353f5a418590e2dcc07b91c3610f08bf Mon Sep 17 00:00:00 2001
From: Matthias Koenig <mkoenig@suse.de>
Date: Tue, 17 Jul 2007 14:58:42 +0200
Subject: [PATCH] schedutils: cleanup ionice usage for idle class
The idle class has no class data. It will print a warning if
a prio argument is given for it, since this will be ignored.
Output for idle class will not contain prio data.
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
---
schedutils/ionice.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/schedutils/ionice.c b/schedutils/ionice.c
index ac72121..2d23dd0 100644
--- a/schedutils/ionice.c
+++ b/schedutils/ionice.c
@@ -95,11 +95,11 @@ int main(int argc, char *argv[])
switch (c) {
case 'n':
ioprio = strtol(optarg, NULL, 10);
- set = 1;
+ set |= 1;
break;
case 'c':
ioprio_class = strtol(optarg, NULL, 10);
- set = 1;
+ set |= 2;
break;
case 'p':
pid = strtol(optarg, NULL, 10);
@@ -119,6 +119,8 @@ int main(int argc, char *argv[])
case IOPRIO_CLASS_BE:
break;
case IOPRIO_CLASS_IDLE:
+ if (set & 1)
+ printf("Ignoring given class data for idle class\n");
ioprio = 7;
break;
default:
@@ -136,8 +138,11 @@ int main(int argc, char *argv[])
perror("ioprio_get");
else {
ioprio_class = ioprio >> IOPRIO_CLASS_SHIFT;
- ioprio = ioprio & 0xff;
- printf("%s: prio %d\n", to_prio[ioprio_class], ioprio);
+ if (ioprio_class != IOPRIO_CLASS_IDLE) {
+ ioprio = ioprio & 0xff;
+ printf("%s: prio %d\n", to_prio[ioprio_class], ioprio);
+ } else
+ printf("%s\n", to_prio[ioprio_class]);
}
} else {
if (ioprio_set(IOPRIO_WHO_PROCESS, pid, ioprio | ioprio_class << IOPRIO_CLASS_SHIFT) == -1) {