@@ -323,10 +323,14 @@ flush(const char __user *str, size_t cnt, int exiting)
323
323
}
324
324
325
325
flush_scheduled_work ();
326
- /* pass one: without sleeping, do aoedev_downdev */
326
+ /* pass one: do aoedev_downdev, which might sleep */
327
+ restart1 :
327
328
spin_lock_irqsave (& devlist_lock , flags );
328
329
for (d = devlist ; d ; d = d -> next ) {
329
330
spin_lock (& d -> lock );
331
+ if (d -> flags & DEVFL_TKILL )
332
+ goto cont ;
333
+
330
334
if (exiting ) {
331
335
/* unconditionally take each device down */
332
336
} else if (specified ) {
@@ -338,8 +342,11 @@ flush(const char __user *str, size_t cnt, int exiting)
338
342
|| d -> ref )
339
343
goto cont ;
340
344
345
+ spin_unlock (& d -> lock );
346
+ spin_unlock_irqrestore (& devlist_lock , flags );
341
347
aoedev_downdev (d );
342
348
d -> flags |= DEVFL_TKILL ;
349
+ goto restart1 ;
343
350
cont :
344
351
spin_unlock (& d -> lock );
345
352
}
@@ -348,7 +355,7 @@ flush(const char __user *str, size_t cnt, int exiting)
348
355
/* pass two: call freedev, which might sleep,
349
356
* for aoedevs marked with DEVFL_TKILL
350
357
*/
351
- restart :
358
+ restart2 :
352
359
spin_lock_irqsave (& devlist_lock , flags );
353
360
for (d = devlist ; d ; d = d -> next ) {
354
361
spin_lock (& d -> lock );
@@ -357,7 +364,7 @@ flush(const char __user *str, size_t cnt, int exiting)
357
364
spin_unlock (& d -> lock );
358
365
spin_unlock_irqrestore (& devlist_lock , flags );
359
366
freedev (d );
360
- goto restart ;
367
+ goto restart2 ;
361
368
}
362
369
spin_unlock (& d -> lock );
363
370
}
0 commit comments