int set_task_ioprio(struct task_struct *task, int ioprio) { int err; struct io_context *ioc; const struct cred *cred = current_cred(), *tcred; rcu_read_lock(); tcred = __task_cred(task); if (!uid_eq(tcred->uid, cred->euid) && !uid_eq(tcred->uid, cred->uid) && !capable(CAP_SYS_NICE)) { rcu_read_unlock(); return -EPERM; } rcu_read_unlock(); err = security_task_setioprio(task, ioprio); if (err) return err; ioc = get_task_io_context(task, GFP_ATOMIC, NUMA_NO_NODE); if (ioc) { ioc->ioprio = ioprio; put_io_context(ioc); } return err; }
int set_task_ioprio(struct task_struct *task, int ioprio) { #ifdef CONFIG_IOSCHED_BFQ int err, i; #else int err; #endif struct io_context *ioc; const struct cred *cred = current_cred(), *tcred; rcu_read_lock(); tcred = __task_cred(task); if (tcred->uid != cred->euid && tcred->uid != cred->uid && !capable(CAP_SYS_NICE)) { rcu_read_unlock(); return -EPERM; } rcu_read_unlock(); err = security_task_setioprio(task, ioprio); if (err) return err; task_lock(task); do { ioc = task->io_context; /* see wmb() in current_io_context() */ smp_read_barrier_depends(); if (ioc) break; ioc = alloc_io_context(GFP_ATOMIC, -1); if (!ioc) { err = -ENOMEM; break; } #ifdef CONFIG_IOSCHED_BFQ /* let other ioc users see the new values */ smp_wmb(); #endif task->io_context = ioc; } while (1); if (!err) { ioc->ioprio = ioprio; #ifdef CONFIG_IOSCHED_BFQ /* make sure schedulers see the new ioprio value */ wmb(); for (i = 0; i < IOC_IOPRIO_CHANGED_BITS; i++) set_bit(i, ioc->ioprio_changed); #else ioc->ioprio_changed = 1; #endif } task_unlock(task); return err; }
int set_task_ioprio(struct task_struct *task, int ioprio) { int err, i; struct io_context *ioc; const struct cred *cred = current_cred(), *tcred; rcu_read_lock(); tcred = __task_cred(task); if (tcred->uid != cred->euid && tcred->uid != cred->uid && !capable(CAP_SYS_NICE)) { rcu_read_unlock(); return -EPERM; } rcu_read_unlock(); err = security_task_setioprio(task, ioprio); if (err) return err; task_lock(task); do { ioc = task->io_context; /* see wmb() in current_io_context() */ smp_read_barrier_depends(); if (ioc) break; ioc = alloc_io_context(GFP_ATOMIC, -1); if (!ioc) { err = -ENOMEM; break; } smp_wmb(); task->io_context = ioc; } while (1); if (!err) { ioc->ioprio = ioprio; wmb(); for (i = 0; i < IOC_IOPRIO_CHANGED_BITS; i++) set_bit(i, ioc->ioprio_changed); } task_unlock(task); return err; }