[GFS2] Split gfs2_writepage into three cases
[pandora-kernel.git] / fs / ioprio.c
index 89e8da1..e4e01bc 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/capability.h>
 #include <linux/syscalls.h>
 #include <linux/security.h>
+#include <linux/pid_namespace.h>
 
 static int set_task_ioprio(struct task_struct *task, int ioprio)
 {
@@ -60,6 +61,7 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
        int data = IOPRIO_PRIO_DATA(ioprio);
        struct task_struct *p, *g;
        struct user_struct *user;
+       struct pid *pgrp;
        int ret;
 
        switch (class) {
@@ -76,6 +78,10 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
                        if (!capable(CAP_SYS_ADMIN))
                                return -EPERM;
                        break;
+               case IOPRIO_CLASS_NONE:
+                       if (data)
+                               return -EINVAL;
+                       break;
                default:
                        return -EINVAL;
        }
@@ -92,18 +98,20 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
                        if (!who)
                                p = current;
                        else
-                               p = find_task_by_pid(who);
+                               p = find_task_by_vpid(who);
                        if (p)
                                ret = set_task_ioprio(p, ioprio);
                        break;
                case IOPRIO_WHO_PGRP:
                        if (!who)
-                               who = process_group(current);
-                       do_each_task_pid(who, PIDTYPE_PGID, p) {
+                               pgrp = task_pgrp(current);
+                       else
+                               pgrp = find_vpid(who);
+                       do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
                                ret = set_task_ioprio(p, ioprio);
                                if (ret)
                                        break;
-                       } while_each_task_pid(who, PIDTYPE_PGID, p);
+                       } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
                        break;
                case IOPRIO_WHO_USER:
                        if (!who)
@@ -167,6 +175,7 @@ asmlinkage long sys_ioprio_get(int which, int who)
 {
        struct task_struct *g, *p;
        struct user_struct *user;
+       struct pid *pgrp;
        int ret = -ESRCH;
        int tmpio;
 
@@ -176,14 +185,16 @@ asmlinkage long sys_ioprio_get(int which, int who)
                        if (!who)
                                p = current;
                        else
-                               p = find_task_by_pid(who);
+                               p = find_task_by_vpid(who);
                        if (p)
                                ret = get_task_ioprio(p);
                        break;
                case IOPRIO_WHO_PGRP:
                        if (!who)
-                               who = process_group(current);
-                       do_each_task_pid(who, PIDTYPE_PGID, p) {
+                               pgrp = task_pgrp(current);
+                       else
+                               pgrp = find_vpid(who);
+                       do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
                                tmpio = get_task_ioprio(p);
                                if (tmpio < 0)
                                        continue;
@@ -191,7 +202,7 @@ asmlinkage long sys_ioprio_get(int which, int who)
                                        ret = tmpio;
                                else
                                        ret = ioprio_best(ret, tmpio);
-                       } while_each_task_pid(who, PIDTYPE_PGID, p);
+                       } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
                        break;
                case IOPRIO_WHO_USER:
                        if (!who)