diff options
Diffstat (limited to 'fs/ioprio.c')
-rw-r--r-- | fs/ioprio.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c index 93aa5715f224..78b1deae3fa2 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c | |||
@@ -44,6 +44,9 @@ static int set_task_ioprio(struct task_struct *task, int ioprio) | |||
44 | task->ioprio = ioprio; | 44 | task->ioprio = ioprio; |
45 | 45 | ||
46 | ioc = task->io_context; | 46 | ioc = task->io_context; |
47 | /* see wmb() in current_io_context() */ | ||
48 | smp_read_barrier_depends(); | ||
49 | |||
47 | if (ioc && ioc->set_ioprio) | 50 | if (ioc && ioc->set_ioprio) |
48 | ioc->set_ioprio(ioc, ioprio); | 51 | ioc->set_ioprio(ioc, ioprio); |
49 | 52 | ||
@@ -111,9 +114,9 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio) | |||
111 | continue; | 114 | continue; |
112 | ret = set_task_ioprio(p, ioprio); | 115 | ret = set_task_ioprio(p, ioprio); |
113 | if (ret) | 116 | if (ret) |
114 | break; | 117 | goto free_uid; |
115 | } while_each_thread(g, p); | 118 | } while_each_thread(g, p); |
116 | 119 | free_uid: | |
117 | if (who) | 120 | if (who) |
118 | free_uid(user); | 121 | free_uid(user); |
119 | break; | 122 | break; |
@@ -137,6 +140,29 @@ out: | |||
137 | return ret; | 140 | return ret; |
138 | } | 141 | } |
139 | 142 | ||
143 | int ioprio_best(unsigned short aprio, unsigned short bprio) | ||
144 | { | ||
145 | unsigned short aclass = IOPRIO_PRIO_CLASS(aprio); | ||
146 | unsigned short bclass = IOPRIO_PRIO_CLASS(bprio); | ||
147 | |||
148 | if (!ioprio_valid(aprio)) | ||
149 | return bprio; | ||
150 | if (!ioprio_valid(bprio)) | ||
151 | return aprio; | ||
152 | |||
153 | if (aclass == IOPRIO_CLASS_NONE) | ||
154 | aclass = IOPRIO_CLASS_BE; | ||
155 | if (bclass == IOPRIO_CLASS_NONE) | ||
156 | bclass = IOPRIO_CLASS_BE; | ||
157 | |||
158 | if (aclass == bclass) | ||
159 | return min(aprio, bprio); | ||
160 | if (aclass > bclass) | ||
161 | return bprio; | ||
162 | else | ||
163 | return aprio; | ||
164 | } | ||
165 | |||
140 | asmlinkage long sys_ioprio_get(int which, int who) | 166 | asmlinkage long sys_ioprio_get(int which, int who) |
141 | { | 167 | { |
142 | struct task_struct *g, *p; | 168 | struct task_struct *g, *p; |