Skip to contentSkip to conversation

blk: start bypass mode in blk_unregister_queue

PATCH In review Aaron Lu 2 participants 5 messages Apr 4, 2013 1 message not in the archive Block layer

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Aaron Lu

author
#1 lore raw

PATCH 1/1 blk: start bypass mode in blk_unregister_queue

In blk_register_queue, we will end bypass mode for the queue; but in blk_unregister_queue, we didn't start bypass mode for it. This would cause the WARN_ON_ONCE(q->bypass_depth < 0) to trigger if the queue gets registered, unregistered and then again registered, e.g. unload scsi cdrom module driver sr_mod and then reload it will trigger such a warning.

---
 block/blk-sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
block/blk-sysfs.c +2 -0
index 6206a93..bd322a1 100644
@@ -615,4 +615,6 @@ void blk_unregister_queue(struct gendisk *disk)
 	kobject_del(&q->kobj);
 	blk_trace_remove_sysfs(disk_to_dev(disk));
 	kobject_put(&disk_to_dev(disk)->kobj);
+
+	blk_queue_bypass_start(q);
 }
Signature · 1 line
1.8.1.5
#2 lore raw
Quoted 8 lines · Aaron Lu

In blk_register_queue, we will end bypass mode for the queue; but in blk_unregister_queue, we didn't start bypass mode for it. This would cause the WARN_ON_ONCE(q->bypass_depth < 0) to trigger if the queue gets registered, unregistered and then again registered, e.g. unload scsi cdrom module driver sr_mod and then reload it will trigger such a warning.

Is this something which actually happens? Why would an unregistered queue registered again? Do we even support that?

Starting a bypass mode can be very expensive and some drivers create and destroy a lot of queues during probing. We don't want a call to blk_queue_bypass_start() on every queue creation / destruction cycle.

Thanks.

Signature · 1 line
tejun
author
#3 lore raw
Quoted 8 lines · Tejun Heo
Quoted 7 lines · Aaron Lu

In blk_register_queue, we will end bypass mode for the queue; but in blk_unregister_queue, we didn't start bypass mode for it. This would cause the WARN_ON_ONCE(q->bypass_depth < 0) to trigger if the queue gets registered, unregistered and then again registered, e.g. unload scsi cdrom module driver sr_mod and then reload it will trigger such a warning.

Quoted 4 lines
Quoted 1 line

Is this something which actually happens? Why would an unregistered queue registered again? Do we even support that?

It probably wouldn't happen for normal user, only for some SCSI driver developers like me, e.g. the sr_mod will normally load during boot, and when I made some changes to the code, I'll unload the driver and reload it. This is found when I was developing ZPODD code and I just found some time to see what happened.

The queue for the scsi device will always be there, the queue(and the device) will not go away on driver unregistration. So it will be left in normal mode, and on next blk_register_queue call, the warning will show up.

Quoted 4 lines

Starting a bypass mode can be very expensive and some drivers create and destroy a lot of queues during probing. We don't want a call to blk_queue_bypass_start() on every queue creation / destruction cycle.

By expensive, do you mean the drain of the queue? Since the queue is to be unregistered, I suppose the queue has to be drained somewhere?

Thanks,
Aaron

#4 lore raw

Hello,

Quoted 5 lines · Aaron Lu

It probably wouldn't happen for normal user, only for some SCSI driver developers like me, e.g. the sr_mod will normally load during boot, and when I made some changes to the code, I'll unload the driver and reload it. This is found when I was developing ZPODD code and I just found some time to see what happened.

Does that unregister and register the same queue? Ah, crap, it does.

Quoted 11 lines

The queue for the scsi device will always be there, the queue(and the device) will not go away on driver unregistration. So it will be left in normal mode, and on next blk_register_queue call, the warning will show up.

Quoted 3 lines

Starting a bypass mode can be very expensive and some drivers create and destroy a lot of queues during probing. We don't want a call to blk_queue_bypass_start() on every queue creation / destruction cycle.

By expensive, do you mean the drain of the queue? Since the queue is to be unregistered, I suppose the queue has to be drained somewhere?

The problematic one is synchronize_rcu(). It adds up pretty quickly. I'd suggest just skipping blk_queue_bypass_end() during registration if the queue is not bypassing.

Thanks.

Signature · 1 line
tejun
author
#5 lore raw
Quoted 20 lines · Tejun Heo

Hello,

Quoted 5 lines · Aaron Lu

It probably wouldn't happen for normal user, only for some SCSI driver developers like me, e.g. the sr_mod will normally load during boot, and when I made some changes to the code, I'll unload the driver and reload it. This is found when I was developing ZPODD code and I just found some time to see what happened.

Does that unregister and register the same queue? Ah, crap, it does.

Quoted 9 lines

The queue for the scsi device will always be there, the queue(and the device) will not go away on driver unregistration. So it will be left in normal mode, and on next blk_register_queue call, the warning will show up.

Quoted 3 lines

Starting a bypass mode can be very expensive and some drivers create and destroy a lot of queues during probing. We don't want a call to blk_queue_bypass_start() on every queue creation / destruction cycle.

Quoted 6 lines
Quoted 2 lines

By expensive, do you mean the drain of the queue? Since the queue is to be unregistered, I suppose the queue has to be drained somewhere?

The problematic one is synchronize_rcu(). It adds up pretty quickly. I'd suggest just skipping blk_queue_bypass_end() during registration if the queue is not bypassing.

OK, thanks for the suggestion!

-Aaron