aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/io_uring.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5818a7b3d29b..6f18b5f27404 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6930,8 +6930,16 @@ static int io_sq_thread(void *data)
* kthread parking. This synchronizes the thread vs users,
* the users are synchronized on the sqd->ctx_lock.
*/
- if (kthread_should_park())
+ if (kthread_should_park()) {
kthread_parkme();
+ /*
+ * When sq thread is unparked, in case the previous park operation
+ * comes from io_put_sq_data(), which means that sq thread is going
+ * to be stopped, so here needs to have a check.
+ */
+ if (kthread_should_stop())
+ break;
+ }
if (unlikely(!list_empty(&sqd->ctx_new_list))) {
io_sqd_init_new(sqd);