scsi: scsi_transport_srp: switch to SPDX tags
[linux-2.6-microblaze.git] / fs / io_uring.c
index ac04076..310f8d1 100644 (file)
@@ -231,7 +231,6 @@ struct io_ring_ctx {
        struct task_struct      *sqo_thread;    /* if using sq thread polling */
        struct mm_struct        *sqo_mm;
        wait_queue_head_t       sqo_wait;
-       unsigned                sqo_stop;
 
        struct {
                /* CQ ring */
@@ -2015,7 +2014,7 @@ static int io_sq_thread(void *data)
        set_fs(USER_DS);
 
        timeout = inflight = 0;
-       while (!kthread_should_stop() && !ctx->sqo_stop) {
+       while (!kthread_should_park()) {
                bool all_fixed, mm_fault = false;
                int i;
 
@@ -2077,7 +2076,7 @@ static int io_sq_thread(void *data)
                        smp_mb();
 
                        if (!io_get_sqring(ctx, &sqes[0])) {
-                               if (kthread_should_stop()) {
+                               if (kthread_should_park()) {
                                        finish_wait(&ctx->sqo_wait, &wait);
                                        break;
                                }
@@ -2127,8 +2126,7 @@ static int io_sq_thread(void *data)
                mmput(cur_mm);
        }
 
-       if (kthread_should_park())
-               kthread_parkme();
+       kthread_parkme();
 
        return 0;
 }
@@ -2169,6 +2167,8 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit)
 
 static unsigned io_cqring_events(struct io_cq_ring *ring)
 {
+       /* See comment at the top of this file */
+       smp_rmb();
        return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head);
 }
 
@@ -2181,11 +2181,8 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
 {
        struct io_cq_ring *ring = ctx->cq_ring;
        sigset_t ksigmask, sigsaved;
-       DEFINE_WAIT(wait);
        int ret;
 
-       /* See comment at the top of this file */
-       smp_rmb();
        if (io_cqring_events(ring) >= min_events)
                return 0;
 
@@ -2203,23 +2200,9 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
                        return ret;
        }
 
-       do {
-               prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE);
-
-               ret = 0;
-               /* See comment at the top of this file */
-               smp_rmb();
-               if (io_cqring_events(ring) >= min_events)
-                       break;
-
-               schedule();
-
+       ret = wait_event_interruptible(ctx->wait, io_cqring_events(ring) >= min_events);
+       if (ret == -ERESTARTSYS)
                ret = -EINTR;
-               if (signal_pending(current))
-                       break;
-       } while (1);
-
-       finish_wait(&ctx->wait, &wait);
 
        if (sig)
                restore_user_sigmask(sig, &sigsaved);
@@ -2260,8 +2243,11 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx)
 static void io_sq_thread_stop(struct io_ring_ctx *ctx)
 {
        if (ctx->sqo_thread) {
-               ctx->sqo_stop = 1;
-               mb();
+               /*
+                * The park is a bit of a work-around, without it we get
+                * warning spews on shutdown with SQPOLL set and affinity
+                * set to a single CPU.
+                */
                kthread_park(ctx->sqo_thread);
                kthread_stop(ctx->sqo_thread);
                ctx->sqo_thread = NULL;
@@ -2685,8 +2671,9 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
 
                ret = 0;
                down_read(&current->mm->mmap_sem);
-               pret = get_user_pages_longterm(ubuf, nr_pages, FOLL_WRITE,
-                                               pages, vmas);
+               pret = get_user_pages(ubuf, nr_pages,
+                                     FOLL_WRITE | FOLL_LONGTERM,
+                                     pages, vmas);
                if (pret == nr_pages) {
                        /* don't support file backed memory */
                        for (j = 0; j < nr_pages; j++) {