Difference between blk_run_queue() and generic_unplug_device()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

By reading the code of kernel 2.6, I don't understand what's the
exact difference between blk_run_queue() and generic_unplug_device().

Here is the code of generic_unplug_device() :

1279 void generic_unplug_device(request_queue_t *q)
1280 {
1281         spin_lock_irq(q->queue_lock);
1282         __generic_unplug_device(q);
1283         spin_unlock_irq(q->queue_lock);
1284 }

What it does is:

1252 void __generic_unplug_device(request_queue_t *q)
1253 {
1254         if (test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags))
1255                 return;
1256 
1257         if (!blk_remove_plug(q))
1258                 return;
1259 
1260         /*
1261          * was plugged, fire request_fn if queue has stuff to do
1262          */
1263         if (elv_next_request(q))
1264                 q->request_fn(q);

Which seems quite similar to the code of blk_run_queue():

1387 void blk_run_queue(struct request_queue *q)
1388 {
1389         unsigned long flags;
1390 
1391         spin_lock_irqsave(q->queue_lock, flags);
1392         blk_remove_plug(q);
1393         q->request_fn(q);
1394         spin_unlock_irqrestore(q->queue_lock, flags);
1395 }

What's the difference between them ? Which one should be used in which
case ?

I have a block driver that issues some requests using submit_bio(). For
most of the request, I let the kernel decides when to unplug the queue,
but for some requests that need to be processed immediatly, I ask the
kernel to forcefully unplug the queue. In 2.4, I used
generic_unplug_device(), but with the introduction of blk_run_queue()
in 2.6, I don't know which one should be used.

Thanks,

Thomas
-- 
Thomas Petazzoni - thomas.petazzoni@xxxxxxxx
http://{thomas,sos,kos}.enix.org - http://www.toulibre.org
http://www.{livret,agenda}dulibre.org

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux