]> err.no Git - linux-2.6/commitdiff
kernel: add CLONE_IO to specifically request sharing of IO contexts
authorJens Axboe <jens.axboe@oracle.com>
Thu, 24 Jan 2008 07:54:47 +0000 (08:54 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 28 Jan 2008 09:50:36 +0000 (10:50 +0100)
syslets (or other threads/processes that want io context sharing) can
set this to enforce sharing of io context.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
include/linux/sched.h
kernel/fork.c

index 80837e7d527e61f9a8c8ceba5d8656bd802c5639..2d0546e884ea0fe443f88a74a01f39bbd5f86cb4 100644 (file)
@@ -27,6 +27,7 @@
 #define CLONE_NEWUSER          0x10000000      /* New user namespace */
 #define CLONE_NEWPID           0x20000000      /* New pid namespace */
 #define CLONE_NEWNET           0x40000000      /* New network namespace */
+#define CLONE_IO               0x80000000      /* Clone io context */
 
 /*
  * Scheduling policies
index 1987c57abb08a6ffa84bc63ef0d706d40c401cc5..314f5101d2b0e5f864f22fce25c4255c7305f789 100644 (file)
@@ -792,15 +792,21 @@ out:
        return error;
 }
 
-static int copy_io(struct task_struct *tsk)
+static int copy_io(unsigned long clone_flags, struct task_struct *tsk)
 {
 #ifdef CONFIG_BLOCK
        struct io_context *ioc = current->io_context;
 
        if (!ioc)
                return 0;
-
-       if (ioprio_valid(ioc->ioprio)) {
+       /*
+        * Share io context with parent, if CLONE_IO is set
+        */
+       if (clone_flags & CLONE_IO) {
+               tsk->io_context = ioc_task_link(ioc);
+               if (unlikely(!tsk->io_context))
+                       return -ENOMEM;
+       } else if (ioprio_valid(ioc->ioprio)) {
                tsk->io_context = alloc_io_context(GFP_KERNEL, -1);
                if (unlikely(!tsk->io_context))
                        return -ENOMEM;
@@ -1176,7 +1182,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
                goto bad_fork_cleanup_mm;
        if ((retval = copy_namespaces(clone_flags, p)))
                goto bad_fork_cleanup_keys;
-       if ((retval = copy_io(p)))
+       if ((retval = copy_io(clone_flags, p)))
                goto bad_fork_cleanup_namespaces;
        retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs);
        if (retval)