jbd2: fix a kernel-doc markup
[linux-2.6-microblaze.git] / fs / io-wq.c
index 0a182f1..7cb3b4c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/fs_struct.h>
 #include <linux/task_work.h>
 #include <linux/blk-cgroup.h>
+#include <linux/audit.h>
 
 #include "io-wq.h"
 
@@ -429,14 +430,10 @@ static void io_wq_switch_mm(struct io_worker *worker, struct io_wq_work *work)
                mmput(worker->mm);
                worker->mm = NULL;
        }
-       if (!work->mm)
-               return;
 
-       if (mmget_not_zero(work->mm)) {
-               kthread_use_mm(work->mm);
-               worker->mm = work->mm;
-               /* hang on to this mm */
-               work->mm = NULL;
+       if (mmget_not_zero(work->identity->mm)) {
+               kthread_use_mm(work->identity->mm);
+               worker->mm = work->identity->mm;
                return;
        }
 
@@ -448,9 +445,11 @@ static inline void io_wq_switch_blkcg(struct io_worker *worker,
                                      struct io_wq_work *work)
 {
 #ifdef CONFIG_BLK_CGROUP
-       if (work->blkcg_css != worker->blkcg_css) {
-               kthread_associate_blkcg(work->blkcg_css);
-               worker->blkcg_css = work->blkcg_css;
+       if (!(work->flags & IO_WQ_WORK_BLKCG))
+               return;
+       if (work->identity->blkcg_css != worker->blkcg_css) {
+               kthread_associate_blkcg(work->identity->blkcg_css);
+               worker->blkcg_css = work->identity->blkcg_css;
        }
 #endif
 }
@@ -458,9 +457,9 @@ static inline void io_wq_switch_blkcg(struct io_worker *worker,
 static void io_wq_switch_creds(struct io_worker *worker,
                               struct io_wq_work *work)
 {
-       const struct cred *old_creds = override_creds(work->creds);
+       const struct cred *old_creds = override_creds(work->identity->creds);
 
-       worker->cur_creds = work->creds;
+       worker->cur_creds = work->identity->creds;
        if (worker->saved_creds)
                put_cred(old_creds); /* creds set by previous switch */
        else
@@ -470,20 +469,26 @@ static void io_wq_switch_creds(struct io_worker *worker,
 static void io_impersonate_work(struct io_worker *worker,
                                struct io_wq_work *work)
 {
-       if (work->files && current->files != work->files) {
+       if ((work->flags & IO_WQ_WORK_FILES) &&
+           current->files != work->identity->files) {
                task_lock(current);
-               current->files = work->files;
-               current->nsproxy = work->nsproxy;
+               current->files = work->identity->files;
+               current->nsproxy = work->identity->nsproxy;
                task_unlock(current);
        }
-       if (work->fs && current->fs != work->fs)
-               current->fs = work->fs;
-       if (work->mm != worker->mm)
+       if ((work->flags & IO_WQ_WORK_FS) && current->fs != work->identity->fs)
+               current->fs = work->identity->fs;
+       if ((work->flags & IO_WQ_WORK_MM) && work->identity->mm != worker->mm)
                io_wq_switch_mm(worker, work);
-       if (worker->cur_creds != work->creds)
+       if ((work->flags & IO_WQ_WORK_CREDS) &&
+           worker->cur_creds != work->identity->creds)
                io_wq_switch_creds(worker, work);
-       current->signal->rlim[RLIMIT_FSIZE].rlim_cur = work->fsize;
+       current->signal->rlim[RLIMIT_FSIZE].rlim_cur = work->identity->fsize;
        io_wq_switch_blkcg(worker, work);
+#ifdef CONFIG_AUDIT
+       current->loginuid = work->identity->loginuid;
+       current->sessionid = work->identity->sessionid;
+#endif
 }
 
 static void io_assign_current_work(struct io_worker *worker,
@@ -496,6 +501,11 @@ static void io_assign_current_work(struct io_worker *worker,
                cond_resched();
        }
 
+#ifdef CONFIG_AUDIT
+       current->loginuid = KUIDT_INIT(AUDIT_UID_UNSET);
+       current->sessionid = AUDIT_SID_UNSET;
+#endif
+
        spin_lock_irq(&worker->lock);
        worker->cur_work = work;
        spin_unlock_irq(&worker->lock);
@@ -676,6 +686,7 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
                kfree(worker);
                return false;
        }
+       kthread_bind_mask(worker->task, cpumask_of_node(wqe->node));
 
        raw_spin_lock_irq(&wqe->lock);
        hlist_nulls_add_head_rcu(&worker->nulls_node, &wqe->free_list);