@@ -699,18 +699,26 @@ static int io_wq_manager(void *data)
699
699
/* create fixed workers */
700
700
refcount_set (& wq -> refs , workers_to_create );
701
701
for_each_node (node ) {
702
+ if (!node_online (node ))
703
+ continue ;
702
704
if (!create_io_worker (wq , wq -> wqes [node ], IO_WQ_ACCT_BOUND ))
703
705
goto err ;
704
706
workers_to_create -- ;
705
707
}
706
708
709
+ while (workers_to_create -- )
710
+ refcount_dec (& wq -> refs );
711
+
707
712
complete (& wq -> done );
708
713
709
714
while (!kthread_should_stop ()) {
710
715
for_each_node (node ) {
711
716
struct io_wqe * wqe = wq -> wqes [node ];
712
717
bool fork_worker [2 ] = { false, false };
713
718
719
+ if (!node_online (node ))
720
+ continue ;
721
+
714
722
spin_lock_irq (& wqe -> lock );
715
723
if (io_wqe_need_worker (wqe , IO_WQ_ACCT_BOUND ))
716
724
fork_worker [IO_WQ_ACCT_BOUND ] = true;
@@ -829,7 +837,9 @@ static bool io_wq_for_each_worker(struct io_wqe *wqe,
829
837
830
838
list_for_each_entry_rcu (worker , & wqe -> all_list , all_list ) {
831
839
if (io_worker_get (worker )) {
832
- ret = func (worker , data );
840
+ /* no task if node is/was offline */
841
+ if (worker -> task )
842
+ ret = func (worker , data );
833
843
io_worker_release (worker );
834
844
if (ret )
835
845
break ;
@@ -1084,6 +1094,8 @@ void io_wq_flush(struct io_wq *wq)
1084
1094
for_each_node (node ) {
1085
1095
struct io_wqe * wqe = wq -> wqes [node ];
1086
1096
1097
+ if (!node_online (node ))
1098
+ continue ;
1087
1099
init_completion (& data .done );
1088
1100
INIT_IO_WORK (& data .work , io_wq_flush_func );
1089
1101
data .work .flags |= IO_WQ_WORK_INTERNAL ;
@@ -1115,20 +1127,22 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
1115
1127
1116
1128
for_each_node (node ) {
1117
1129
struct io_wqe * wqe ;
1130
+ int alloc_node = node ;
1118
1131
1119
- wqe = kzalloc_node (sizeof (struct io_wqe ), GFP_KERNEL , node );
1132
+ if (!node_online (alloc_node ))
1133
+ alloc_node = NUMA_NO_NODE ;
1134
+ wqe = kzalloc_node (sizeof (struct io_wqe ), GFP_KERNEL , alloc_node );
1120
1135
if (!wqe )
1121
1136
goto err ;
1122
1137
wq -> wqes [node ] = wqe ;
1123
- wqe -> node = node ;
1138
+ wqe -> node = alloc_node ;
1124
1139
wqe -> acct [IO_WQ_ACCT_BOUND ].max_workers = bounded ;
1125
1140
atomic_set (& wqe -> acct [IO_WQ_ACCT_BOUND ].nr_running , 0 );
1126
1141
if (wq -> user ) {
1127
1142
wqe -> acct [IO_WQ_ACCT_UNBOUND ].max_workers =
1128
1143
task_rlimit (current , RLIMIT_NPROC );
1129
1144
}
1130
1145
atomic_set (& wqe -> acct [IO_WQ_ACCT_UNBOUND ].nr_running , 0 );
1131
- wqe -> node = node ;
1132
1146
wqe -> wq = wq ;
1133
1147
spin_lock_init (& wqe -> lock );
1134
1148
INIT_WQ_LIST (& wqe -> work_list );
0 commit comments