floppy: take floppy_lock when rescheduling the timeout in queue_rq
Subsystems (3)
Denis Efremov (Oracle)
maintainerPATCH 1/1 floppy: take floppy_lock when rescheduling the timeout in queue_rq
__reschedule_timeout() expects floppy_lock to be held. floppy_queue_rq() still calls it without the lock, which was fine when the request function ran under the queue lock, i.e. floppy_lock, but not since the conversion to blk-mq. With lockdep_assert_held(&floppy_lock) added to __reschedule_timeout(), the first read from the drive triggers:
WARNING: drivers/block/floppy.c:671 at __reschedule_timeout+0x180/0x1e0, CPU#0: dd/561 Call Trace: <TASK> floppy_queue_rq+0x17e/0x300 blk_mq_dispatch_rq_list+0x3e9/0x1f30 __blk_mq_sched_dispatch_requests+0xcfa/0x16e0 blk_mq_sched_dispatch_requests+0xd5/0x1c0 blk_mq_run_hw_queue+0x341/0x670 blk_mq_dispatch_list+0x50c/0x16f0 blk_mq_flush_plug_list+0x131/0x600 ... blkdev_read_iter+0x2b5/0x4e0 vfs_read+0x7fd/0xaf0 ksys_read+0x12a/0x250 do_syscall_64+0x106/0x5f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
Use reschedule_timeout(), which takes the lock.
---
There is a small ordering conflict with "floppy: select FDC before arming timeout work" [1], which moves the same call below set_fdc(0). I will resolve it when applying the patches, so that the timeout is armed with reschedule_timeout() after set_fdc(0).
That is also why this patch switches to reschedule_timeout() instead of moving __reschedule_timeout() into the floppy_lock section a couple of lines above: there it would be armed before set_fdc(0) again.
[1] https://lore.kernel.org/linux-block/[email protected]/
drivers/block/floppy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/floppy.c +1 -1
@@ -2872,7 +2872,7 @@ static blk_status_t floppy_queue_rq(struct blk_mq_hw_ctx *hctx,spin_unlock_irq (&floppy_lock); command_status =FD_COMMAND_NONE ; -__reschedule_timeout (MAXTIMEOUT ,"fd_request" ); +reschedule_timeout (MAXTIMEOUT ,"fd_request" );set_fdc (0 );process_fd_request ();is_alive (__func__,"" );
base-commit: 22430ae5d90ab288b0ee2ad99ae941f4a666b694
Signature · 1 line
2.55.0