Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.25-rc7 /fs/ioprio.c

Filename:/fs/ioprio.c
Lines Added:20
Lines Deleted:10
Also changed in: (Previous) 2.6.25-rc6  2.6.25-rc5  2.6.25-rc4  2.6.25-rc3  2.6.25-rc2  2.6.25-rc1 
(Following) 2.6.25-rc8  2.6.25-rc9  2.6.25  2.6.27-rc3-git7  2.6.27-rc4  2.6.27-rc5 

Location
[  2.6.25-rc7
  [  fs
     o  ioprio.c

Patch

diff --git a/fs/ioprio.c b/fs/ioprio.c
index e4e01bc..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,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;
 }


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.