X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=fs%2Fioprio.c;h=c4a1c3c65aac35ba999a4739fb3ed6549b5e1b75;hb=2c6b8c030cfca334c3d700ee504036c585c4c6a3;hp=0a615f87142eaeb61581aeb31ddb1f486d2445bd;hpb=b488893a390edfe027bae7a46e9af8083e740668;p=safe%2Fjmp%2Flinux-2.6 diff --git a/fs/ioprio.c b/fs/ioprio.c index 0a615f8..c4a1c3c 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c @@ -41,18 +41,28 @@ static int set_task_ioprio(struct task_struct *task, int ioprio) return err; task_lock(task); + do { + ioc = task->io_context; + /* see wmb() in current_io_context() */ + smp_read_barrier_depends(); + if (ioc) + break; - task->ioprio = ioprio; - - ioc = task->io_context; - /* see wmb() in current_io_context() */ - smp_read_barrier_depends(); + ioc = alloc_io_context(GFP_ATOMIC, -1); + if (!ioc) { + err = -ENOMEM; + break; + } + task->io_context = ioc; + } while (1); - if (ioc) + if (!err) { + ioc->ioprio = ioprio; ioc->ioprio_changed = 1; + } task_unlock(task); - return 0; + return err; } asmlinkage long sys_ioprio_set(int which, int who, int ioprio) @@ -75,8 +85,10 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio) break; case IOPRIO_CLASS_IDLE: - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; + break; + case IOPRIO_CLASS_NONE: + if (data) + return -EINVAL; break; default: return -EINVAL; @@ -94,8 +106,7 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio) if (!who) p = current; else - p = find_task_by_pid_ns(who, - current->nsproxy->pid_ns); + p = find_task_by_vpid(who); if (p) ret = set_task_ioprio(p, ioprio); break; @@ -145,7 +156,9 @@ static int get_task_ioprio(struct task_struct *p) ret = security_task_getioprio(p); if (ret) goto out; - ret = p->ioprio; + ret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM); + if (p->io_context) + ret = p->io_context->ioprio; out: return ret; } @@ -182,8 +195,7 @@ asmlinkage long sys_ioprio_get(int which, int who) if (!who) p = current; else - p = find_task_by_pid_ns(who, - current->nsproxy->pid_ns); + p = find_task_by_vpid(who); if (p) ret = get_task_ioprio(p); break;