@@ -182,8 +182,7 @@ struct ublk_device {
182
182
unsigned int nr_queues_ready ;
183
183
unsigned int nr_privileged_daemon ;
184
184
185
- struct work_struct quiesce_work ;
186
- struct work_struct stop_work ;
185
+ struct work_struct nosrv_work ;
187
186
};
188
187
189
188
/* header of ublk_params */
@@ -1261,10 +1260,7 @@ static enum blk_eh_timer_return ublk_timeout(struct request *rq)
1261
1260
struct ublk_device * ub = ubq -> dev ;
1262
1261
1263
1262
if (ublk_abort_requests (ub , ubq )) {
1264
- if (ublk_nosrv_should_stop_dev (ub ))
1265
- schedule_work (& ub -> stop_work );
1266
- else
1267
- schedule_work (& ub -> quiesce_work );
1263
+ schedule_work (& ub -> nosrv_work );
1268
1264
}
1269
1265
return BLK_EH_DONE ;
1270
1266
}
@@ -1514,10 +1510,7 @@ static void ublk_uring_cmd_cancel_fn(struct io_uring_cmd *cmd,
1514
1510
ublk_cancel_cmd (ubq , io , issue_flags );
1515
1511
1516
1512
if (need_schedule ) {
1517
- if (ublk_nosrv_should_stop_dev (ub ))
1518
- schedule_work (& ub -> stop_work );
1519
- else
1520
- schedule_work (& ub -> quiesce_work );
1513
+ schedule_work (& ub -> nosrv_work );
1521
1514
}
1522
1515
}
1523
1516
@@ -1580,20 +1573,6 @@ static void __ublk_quiesce_dev(struct ublk_device *ub)
1580
1573
ub -> dev_info .state = UBLK_S_DEV_QUIESCED ;
1581
1574
}
1582
1575
1583
- static void ublk_quiesce_work_fn (struct work_struct * work )
1584
- {
1585
- struct ublk_device * ub =
1586
- container_of (work , struct ublk_device , quiesce_work );
1587
-
1588
- mutex_lock (& ub -> mutex );
1589
- if (ub -> dev_info .state != UBLK_S_DEV_LIVE )
1590
- goto unlock ;
1591
- __ublk_quiesce_dev (ub );
1592
- unlock :
1593
- mutex_unlock (& ub -> mutex );
1594
- ublk_cancel_dev (ub );
1595
- }
1596
-
1597
1576
static void ublk_unquiesce_dev (struct ublk_device * ub )
1598
1577
{
1599
1578
int i ;
@@ -1642,6 +1621,25 @@ static void ublk_stop_dev(struct ublk_device *ub)
1642
1621
ublk_cancel_dev (ub );
1643
1622
}
1644
1623
1624
+ static void ublk_nosrv_work (struct work_struct * work )
1625
+ {
1626
+ struct ublk_device * ub =
1627
+ container_of (work , struct ublk_device , nosrv_work );
1628
+
1629
+ if (ublk_nosrv_should_stop_dev (ub )) {
1630
+ ublk_stop_dev (ub );
1631
+ return ;
1632
+ }
1633
+
1634
+ mutex_lock (& ub -> mutex );
1635
+ if (ub -> dev_info .state != UBLK_S_DEV_LIVE )
1636
+ goto unlock ;
1637
+ __ublk_quiesce_dev (ub );
1638
+ unlock :
1639
+ mutex_unlock (& ub -> mutex );
1640
+ ublk_cancel_dev (ub );
1641
+ }
1642
+
1645
1643
/* device can only be started after all IOs are ready */
1646
1644
static void ublk_mark_io_ready (struct ublk_device * ub , struct ublk_queue * ubq )
1647
1645
{
@@ -2155,14 +2153,6 @@ static int ublk_add_chdev(struct ublk_device *ub)
2155
2153
return ret ;
2156
2154
}
2157
2155
2158
- static void ublk_stop_work_fn (struct work_struct * work )
2159
- {
2160
- struct ublk_device * ub =
2161
- container_of (work , struct ublk_device , stop_work );
2162
-
2163
- ublk_stop_dev (ub );
2164
- }
2165
-
2166
2156
/* align max io buffer size with PAGE_SIZE */
2167
2157
static void ublk_align_max_io_size (struct ublk_device * ub )
2168
2158
{
@@ -2187,8 +2177,7 @@ static int ublk_add_tag_set(struct ublk_device *ub)
2187
2177
static void ublk_remove (struct ublk_device * ub )
2188
2178
{
2189
2179
ublk_stop_dev (ub );
2190
- cancel_work_sync (& ub -> stop_work );
2191
- cancel_work_sync (& ub -> quiesce_work );
2180
+ cancel_work_sync (& ub -> nosrv_work );
2192
2181
cdev_device_del (& ub -> cdev , & ub -> cdev_dev );
2193
2182
ublk_put_device (ub );
2194
2183
ublks_added -- ;
@@ -2457,8 +2446,7 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd)
2457
2446
goto out_unlock ;
2458
2447
mutex_init (& ub -> mutex );
2459
2448
spin_lock_init (& ub -> lock );
2460
- INIT_WORK (& ub -> quiesce_work , ublk_quiesce_work_fn );
2461
- INIT_WORK (& ub -> stop_work , ublk_stop_work_fn );
2449
+ INIT_WORK (& ub -> nosrv_work , ublk_nosrv_work );
2462
2450
2463
2451
ret = ublk_alloc_dev_number (ub , header -> dev_id );
2464
2452
if (ret < 0 )
@@ -2593,9 +2581,7 @@ static inline void ublk_ctrl_cmd_dump(struct io_uring_cmd *cmd)
2593
2581
static int ublk_ctrl_stop_dev (struct ublk_device * ub )
2594
2582
{
2595
2583
ublk_stop_dev (ub );
2596
- cancel_work_sync (& ub -> stop_work );
2597
- cancel_work_sync (& ub -> quiesce_work );
2598
-
2584
+ cancel_work_sync (& ub -> nosrv_work );
2599
2585
return 0 ;
2600
2586
}
2601
2587
0 commit comments