diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-29 08:50:42 +1100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-29 08:50:42 +1100 |
commit | d4928196fe9ec07d18139ba2735876b0c8aa738f (patch) | |
tree | a999ee3f18b0d724b2adb15ec72854e7ade164fa /fs/ioprio.c | |
parent | bb04af0e2e5bcd8d1a5d7f7d5c704f7eb328f241 (diff) | |
parent | febffd61816ef6d4f84189468c1d47f1df55921e (diff) |
Merge branch 'cfq-ioc-share' of git://git.kernel.dk/linux-2.6-block
* 'cfq-ioc-share' of git://git.kernel.dk/linux-2.6-block:
cfq-iosched: kill some big inlines
cfq-iosched: relax IOPRIO_CLASS_IDLE restrictions
kernel: add CLONE_IO to specifically request sharing of IO contexts
io_context sharing - anticipatory changes
block: cfq: make the io contect sharing lockless
io_context sharing - cfq changes
io context sharing: preliminary support
ioprio: move io priority from task_struct to io_context
Diffstat (limited to 'fs/ioprio.c')
-rw-r--r-- | fs/ioprio.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c index e4e01bc7f33..c4a1c3c65aa 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,6 @@ 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) @@ -148,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; } |