diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /fs/ioprio.c | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'fs/ioprio.c')
-rw-r--r-- | fs/ioprio.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c index e50170ca7c3..7da2a06508e 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c | |||
@@ -21,7 +21,6 @@ | |||
21 | */ | 21 | */ |
22 | #include <linux/gfp.h> | 22 | #include <linux/gfp.h> |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/export.h> | ||
25 | #include <linux/ioprio.h> | 24 | #include <linux/ioprio.h> |
26 | #include <linux/blkdev.h> | 25 | #include <linux/blkdev.h> |
27 | #include <linux/capability.h> | 26 | #include <linux/capability.h> |
@@ -37,8 +36,8 @@ int set_task_ioprio(struct task_struct *task, int ioprio) | |||
37 | 36 | ||
38 | rcu_read_lock(); | 37 | rcu_read_lock(); |
39 | tcred = __task_cred(task); | 38 | tcred = __task_cred(task); |
40 | if (!uid_eq(tcred->uid, cred->euid) && | 39 | if (tcred->uid != cred->euid && |
41 | !uid_eq(tcred->uid, cred->uid) && !capable(CAP_SYS_NICE)) { | 40 | tcred->uid != cred->uid && !capable(CAP_SYS_NICE)) { |
42 | rcu_read_unlock(); | 41 | rcu_read_unlock(); |
43 | return -EPERM; | 42 | return -EPERM; |
44 | } | 43 | } |
@@ -48,12 +47,28 @@ int set_task_ioprio(struct task_struct *task, int ioprio) | |||
48 | if (err) | 47 | if (err) |
49 | return err; | 48 | return err; |
50 | 49 | ||
51 | ioc = get_task_io_context(task, GFP_ATOMIC, NUMA_NO_NODE); | 50 | task_lock(task); |
52 | if (ioc) { | 51 | do { |
52 | ioc = task->io_context; | ||
53 | /* see wmb() in current_io_context() */ | ||
54 | smp_read_barrier_depends(); | ||
55 | if (ioc) | ||
56 | break; | ||
57 | |||
58 | ioc = alloc_io_context(GFP_ATOMIC, -1); | ||
59 | if (!ioc) { | ||
60 | err = -ENOMEM; | ||
61 | break; | ||
62 | } | ||
63 | task->io_context = ioc; | ||
64 | } while (1); | ||
65 | |||
66 | if (!err) { | ||
53 | ioc->ioprio = ioprio; | 67 | ioc->ioprio = ioprio; |
54 | put_io_context(ioc); | 68 | ioc->ioprio_changed = 1; |
55 | } | 69 | } |
56 | 70 | ||
71 | task_unlock(task); | ||
57 | return err; | 72 | return err; |
58 | } | 73 | } |
59 | EXPORT_SYMBOL_GPL(set_task_ioprio); | 74 | EXPORT_SYMBOL_GPL(set_task_ioprio); |
@@ -65,7 +80,6 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) | |||
65 | struct task_struct *p, *g; | 80 | struct task_struct *p, *g; |
66 | struct user_struct *user; | 81 | struct user_struct *user; |
67 | struct pid *pgrp; | 82 | struct pid *pgrp; |
68 | kuid_t uid; | ||
69 | int ret; | 83 | int ret; |
70 | 84 | ||
71 | switch (class) { | 85 | switch (class) { |
@@ -111,19 +125,16 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) | |||
111 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); | 125 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); |
112 | break; | 126 | break; |
113 | case IOPRIO_WHO_USER: | 127 | case IOPRIO_WHO_USER: |
114 | uid = make_kuid(current_user_ns(), who); | ||
115 | if (!uid_valid(uid)) | ||
116 | break; | ||
117 | if (!who) | 128 | if (!who) |
118 | user = current_user(); | 129 | user = current_user(); |
119 | else | 130 | else |
120 | user = find_user(uid); | 131 | user = find_user(who); |
121 | 132 | ||
122 | if (!user) | 133 | if (!user) |
123 | break; | 134 | break; |
124 | 135 | ||
125 | do_each_thread(g, p) { | 136 | do_each_thread(g, p) { |
126 | if (!uid_eq(task_uid(p), uid)) | 137 | if (__task_cred(p)->uid != who) |
127 | continue; | 138 | continue; |
128 | ret = set_task_ioprio(p, ioprio); | 139 | ret = set_task_ioprio(p, ioprio); |
129 | if (ret) | 140 | if (ret) |
@@ -178,7 +189,6 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who) | |||
178 | struct task_struct *g, *p; | 189 | struct task_struct *g, *p; |
179 | struct user_struct *user; | 190 | struct user_struct *user; |
180 | struct pid *pgrp; | 191 | struct pid *pgrp; |
181 | kuid_t uid; | ||
182 | int ret = -ESRCH; | 192 | int ret = -ESRCH; |
183 | int tmpio; | 193 | int tmpio; |
184 | 194 | ||
@@ -208,17 +218,16 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who) | |||
208 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); | 218 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); |
209 | break; | 219 | break; |
210 | case IOPRIO_WHO_USER: | 220 | case IOPRIO_WHO_USER: |
211 | uid = make_kuid(current_user_ns(), who); | ||
212 | if (!who) | 221 | if (!who) |
213 | user = current_user(); | 222 | user = current_user(); |
214 | else | 223 | else |
215 | user = find_user(uid); | 224 | user = find_user(who); |
216 | 225 | ||
217 | if (!user) | 226 | if (!user) |
218 | break; | 227 | break; |
219 | 228 | ||
220 | do_each_thread(g, p) { | 229 | do_each_thread(g, p) { |
221 | if (!uid_eq(task_uid(p), user->uid)) | 230 | if (__task_cred(p)->uid != user->uid) |
222 | continue; | 231 | continue; |
223 | tmpio = get_task_ioprio(p); | 232 | tmpio = get_task_ioprio(p); |
224 | if (tmpio < 0) | 233 | if (tmpio < 0) |