aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ioprio.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2008-01-24 02:52:45 -0500
committerJens Axboe <jens.axboe@oracle.com>2008-01-28 04:50:29 -0500
commitfd0928df98b9578be8a786ac0cb78a47a5e17a20 (patch)
tree70a34cf207bea1bec28e59cf0dba7d20e7f8b0f1 /fs/ioprio.c
parent91525300baf162e83e923b09ca286f9205e21522 (diff)
ioprio: move io priority from task_struct to io_context
This is where it belongs and then it doesn't take up space for a process that doesn't do IO. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'fs/ioprio.c')
-rw-r--r--fs/ioprio.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c
index e4e01bc7f338..a7600401ecf7 100644
--- a/fs/ioprio.c
+++ b/fs/ioprio.c
@@ -41,18 +41,29 @@ static int set_task_ioprio(struct task_struct *task, int ioprio)
41 return err; 41 return err;
42 42
43 task_lock(task); 43 task_lock(task);
44 do {
45 ioc = task->io_context;
46 /* see wmb() in current_io_context() */
47 smp_read_barrier_depends();
48 if (ioc)
49 break;
44 50
45 task->ioprio = ioprio; 51 ioc = alloc_io_context(GFP_ATOMIC, -1);
46 52 if (!ioc) {
47 ioc = task->io_context; 53 err = -ENOMEM;
48 /* see wmb() in current_io_context() */ 54 break;
49 smp_read_barrier_depends(); 55 }
56 task->io_context = ioc;
57 ioc->task = task;
58 } while (1);
50 59
51 if (ioc) 60 if (!err) {
61 ioc->ioprio = ioprio;
52 ioc->ioprio_changed = 1; 62 ioc->ioprio_changed = 1;
63 }
53 64
54 task_unlock(task); 65 task_unlock(task);
55 return 0; 66 return err;
56} 67}
57 68
58asmlinkage long sys_ioprio_set(int which, int who, int ioprio) 69asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
@@ -148,7 +159,9 @@ static int get_task_ioprio(struct task_struct *p)
148 ret = security_task_getioprio(p); 159 ret = security_task_getioprio(p);
149 if (ret) 160 if (ret)
150 goto out; 161 goto out;
151 ret = p->ioprio; 162 ret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM);
163 if (p->io_context)
164 ret = p->io_context->ioprio;
152out: 165out:
153 return ret; 166 return ret;
154} 167}